Modify

Opened 3 years ago

Last modified 2 years ago

#9560 new defect

GitPlugin not loading, error in git_fs.py:415

Reported by: mihail.kotov@… Owned by: hvr
Priority: high Component: GitPlugin
Severity: blocker Keywords:
Cc: andersk@… 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 (2)

9560.patch (1.3 KB) - added by lionel 3 years ago.
patch for ticket 9560
PyGIT.py.patch (1.1 KB) - added by natewlew 3 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 3 years ago 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.

Changed 3 years ago by lionel

patch for ticket 9560

comment:2 follow-up: Changed 3 years ago by mihail.kotov@…

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) ?

comment:3 in reply to: ↑ 2 Changed 3 years ago by andersk

  • Cc andersk@… added

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.)

comment:4 Changed 3 years ago 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

comment:5 follow-up: Changed 3 years ago 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?

comment:6 in reply to: ↑ 5 Changed 3 years ago 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:).

Changed 3 years ago by natewlew

comment:7 Changed 3 years ago 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

comment:8 follow-ups: Changed 2 years ago by Dalius Lapenas

Please replace p[0].terminate with:

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

and include signal at the top.

comment:9 in reply to: ↑ 8 Changed 2 years ago 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

comment:10 in reply to: ↑ 8 ; follow-up: Changed 2 years ago 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.

comment:11 in reply to: ↑ 10 Changed 2 years ago 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 Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.