Ticket #9560 (new defect)

Opened 1 year ago

Last modified 11 months ago

GitPlugin not loading, error in git_fs.py:415

Reported by: mihail.kotov@gmail.com Assigned to: hvr
Priority: high Component: GitPlugin
Severity: blocker Keywords:
Cc: andersk@mit.edu Trac Release: 0.12

Description

When installing GitPlugin on Trac 0.12:

easy_install-2.4 hvr-trac-git-plugin-v0.12.0.5-20-g722342e.tar.gz 
Processing hvr-trac-git-plugin-v0.12.0.5-20-g722342e.tar.gz
Running hvr-trac-git-plugin-722342e/setup.py -q bdist_egg --dist-dir /tmp/easy_install-8nGFm-/hvr-trac-git-plugin-722342e/egg-dist-tmp-EGId1i
build/bdist.linux-i686/egg/tracext/git/git_fs.py:415: Warning: 'with' will become a reserved keyword in Python 2.6
  File "build/bdist.linux-i686/egg/tracext/git/git_fs.py", line 415
    with self.git.get_historian(old_rev, old_path.strip('/')) as old_historian:
            ^
SyntaxError: invalid syntax

  File "build/bdist.linux-i686/egg/tracext/git/PyGIT.py", line 64
    p = self.__pipe(git_cmd, *cmd_args, stdout=PIPE, stderr=PIPE)
                                             ^
SyntaxError: invalid syntax

On Trac pages:

Warning: Can't synchronize with repository "(default)" (Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.

Trac log:

2011-11-28 18:27:00,974 Trac[loader] ERROR: Skipping "git = tracext.git.git_fs": 
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1912, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.5/site-packages/TracGit-0.12.0.5dev-py2.5.egg/tracext/git/git_fs.py", line 415
     with self.git.get_historian(old_rev, old_path.strip('/')) as old_historian:
             ^
SyntaxError: invalid syntax (git_fs.py, line 415))
Trac 0.12
Genshi 0.6
mod_python 3.3.1
MySQL server: "5.0.51a-24+lenny5-log", client: "5.0.51a", thread-safe: 1
MySQLdb 1.2.2
Pygments 0.10
Python 2.5.2 (r252:60911, Jan 24 2010, 15:24:24) [GCC 4.3.2]
pytz 2008c
setuptools 0.6c8
Subversion 1.5.1 (r32289)
jQuery: 1.4.2

Attachments

9560.patch (1.3 kB) - added by lionel on 11/29/11 00:51:14.
patch for ticket 9560
PyGIT.py.patch (1.1 kB) - added by natewlew on 01/24/12 00:57:46.

Change History

11/29/11 00:49:59 changed by lionel

Hello,

There are two main issues

  • an import is missing for the with_statement in git_fs.py
  • named arguments for pipe should be provided before the argument list in PyGIT.py.

I've attached a patch for review.

Regards,

Lionel.

11/29/11 00:51:14 changed by lionel

  • attachment 9560.patch added.

patch for ticket 9560

(follow-up: ↓ 3 ) 11/29/11 08:27:35 changed by mihail.kotov@gmail.com

Plugin with patch loaded successfully. 'trac-admin resync' works fine. But in "Browse Source" I get this error:

2011-11-29 10:24:10,642 Trac[main] ERROR: Internal Server Error:.
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 513, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 235, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/trac/versioncontrol/web_ui/browser.py", line 391, in process_request
    dir_data = self._render_dir(req, repos, node, rev, order, desc)
  File "build/bdist.linux-i686/egg/trac/versioncontrol/web_ui/browser.py", line 535, in _render_dir
    entries = [entry(n) for n in node.get_entries()
  File "build/bdist.linux-i686/egg/tracext/git/git_fs.py", line 545, in get_entries
    yield GitNode(self.repos, ent[-1], self.rev, self.log, ent, historian)
  File "/usr/lib/python2.5/contextlib.py", line 22, in __exit__
    self.gen.next()
  File "build/bdist.linux-i686/egg/tracext/git/PyGIT.py", line 760, in get_historian
    p[0].terminate()

It seems to me, what it happens because of object pipe in Python 2.5 not have terminate function. Сan I replace it by send_signal(SIGTERM) ?

(in reply to: ↑ 2 ) 11/29/11 10:49:21 changed by andersk

  • cc set to andersk@mit.edu.

Replying to lionel:

* an import is missing for the with_statement in git_fs.py * named arguments for pipe should be provided before the argument list in PyGIT.py. I've attached a patch for review.

That patch looks fine to me.

Replying to mihail.kotov@gmail.com:

It seems to me, what it happens because of object pipe in Python 2.5 not have terminate function. Сan I replace it by send_signal(SIGTERM) ?

Hmm, that sounds like it wouldn’t be portable to Windows? (Not being a Windows user myself, I don’t know whether the Git plugin works on Windows to begin with.)

11/29/11 10:51:48 changed by anonymous

maybe http://stackoverflow.com/questions/552423/use-python-2-6-subprocess-module-in-python-2-5 is helpful

Popen.terminate doesn't seem to be too hard to implement for both, unix and windows

(follow-up: ↓ 6 ) 12/12/11 16:01:45 changed by anonymous

what happens if we just ignore that Popen.terminate() doesn't exist (i.e. by wrapping it into a "try: ... ; except:pass" exception catcher?). Wouldn't the git process die anyway once the stdin/stdout descriptors are gone?

(in reply to: ↑ 5 ) 12/12/11 20:05:03 changed by andersk

Replying to anonymous:

what happens if we just ignore that Popen.terminate() doesn't exist (i.e. by wrapping it into a "try: ... ; except:pass" exception catcher?). Wouldn't the git process die anyway once the stdin/stdout descriptors are gone?

Well, sure, it will die on the next thing it tries to write to stdout. That’s probably good enough.

Please catch the specific exception (except AttributeError:, not just except:).

01/24/12 00:57:46 changed by natewlew

  • attachment PyGIT.py.patch added.

01/24/12 00:59:26 changed by natewlew

I got the same error and am stuck on Python 2.5 for now. I put the .terminate() in a try catch block. Not really sure what to do with it once the error is caught. Just taking the suggestion from andersk.

Patch to show all changes to PyGIT.py: attachment:PyGIT.py.patch

(follow-ups: ↓ 9 ↓ 10 ) 02/07/12 08:59:49 changed by Dalius Lapenas

Please replace p[0].terminate with:

os.kill(p[0].pid, signal.SIGTERM)

and include signal at the top.

(in reply to: ↑ 8 ) 02/07/12 09:03:23 changed by anonymous

Replying to Dalius Lapenas:

Please replace p[0].terminate with: os.kill(p[0].pid, signal.SIGTERM) and include signal at the top.

Resolved my issues with Python 2.5.2

(in reply to: ↑ 8 ; follow-up: ↓ 11 ) 02/07/12 09:05:06 changed by andersk

Replying to Dalius Lapenas:

os.kill(p[0].pid, signal.SIGTERM)

That was already suggested, and I replied that AFAIK it isn’t portable to Windows. Read the rest of the comments.

(in reply to: ↑ 10 ) 02/07/12 09:17:17 changed by Dalius Lapenas

Replying to andersk:

Replying to Dalius Lapenas:

os.kill(p[0].pid, signal.SIGTERM)

That was already suggested, and I replied that AFAIK it isn’t portable to Windows. Read the rest of the comments.

Couldn't find a solution and can't see it in comment, hence posting here.


Add/Change #9560 (GitPlugin not loading, error in git_fs.py:415)




Change Properties
Action