Modify

Opened 13 years ago

Closed 9 years ago

#9560 closed defect (wontfix)

GitPlugin not loading, error in git_fs.py:415

Reported by: mihail.kotov@… Owned by: Herbert Valerio Riedel
Priority: high Component: GitPlugin
Severity: blocker Keywords:
Cc: Anders Kaseorg 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 13 years ago.
patch for ticket 9560
PyGIT.py.patch (1.1 KB) - added by Nathan Lewis 13 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 13 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 13 years ago by lionel

Attachment: 9560.patch added

patch for ticket 9560

comment:2 Changed 13 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 13 years ago by Anders Kaseorg

Cc: Anders Kaseorg added; anonymous removed

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 13 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 Changed 13 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 13 years ago by Anders Kaseorg

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 13 years ago by Nathan Lewis

Attachment: PyGIT.py.patch added

comment:7 Changed 13 years ago by Nathan Lewis

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 Changed 13 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 13 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 ; Changed 13 years ago by Anders Kaseorg

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

comment:12 Changed 9 years ago by Ryan J Ollos

Resolution: wontfix
Status: newclosed

GitPlugin is deprecated. Please upgrade to Trac 1.0 and use TracGit.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Herbert Valerio Riedel.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.