I found my problem in above code. In my trac-post-commit-hook.cmd
file,this line:
SET TRAC_ENV=C:\trac\myProject
should be
SET TRAC_ENV=C:/trac

Also, the above trac-post-commit-hook script was wrong. I used trac-
pre-commit-hook script.
However, it still does not resolve the problem. If I use command line
to test trac-commit-hook script, it works,  When I use TSVN commit, it
does not change any trac ticket status. From my debug log file, I got
this:

Trac[loader] DEBUG: Skipping "trac.mimeview.txtl = trac.mimeview.txtl
[textile]": ("DistributionNotFound: textile>=2.0" not found)
...
 Trac[loader] DEBUG: Skipping "trac.mimeview.rst = trac.mimeview.rst
[rest]": ("DistributionNotFound: docutils>=0.3" not found)
..
Trac[loader] DEBUG: Skipping "trac.mimeview.pygments =
trac.mimeview.pygments [pygments]": ("DistributionNotFound:
Pygments>=0.6" not found)
...
Trac[loader] DEBUG: Skipping "trac.mimeview.silvercity =
trac.mimeview.silvercity [silvercity]": ("DistributionNotFound:
SilverCity>=0.9.4" not found)
...


 Trac[default_workflow] DEBUG: Workflow actions at initialization:
{u'resolve': {u'operations': [u'set_resolution'], 'name': u'resolve',
'default': 0, 'newstate': u'closed', 'oldstates': [u'new',
u'assigned', u'accepted', u'reopened'], u'permissions':
[u'TICKET_MODIFY']}, u'accept': {u'operations':
[u'set_owner_to_self'], 'name': u'accept', 'default': 0, 'newstate':
u'accepted', 'oldstates': [u'new', u'assigned', u'accepted',
u'reopened'], u'permissions': [u'TICKET_MODIFY']}, u'leave':
{u'operations': [u'leave_status'], 'name': u'leave', u'default': 1,
'newstate': u'*', 'oldstates': [u'*'], 'permissions': []}, u'reopen':
{u'operations': [u'del_resolution'], 'name': u'reopen', 'default': 0,
'newstate': u'reopened', 'oldstates': [u'closed'], u'permissions':
[u'TICKET_CREATE']}, u'reassign': {u'operations': [u'set_owner'],
'name': u'reassign', 'default': 0, 'newstate': u'assigned',
'oldstates': [u'new', u'assigned', u'accepted', u'reopened'],
u'permissions': [u'TICKET_MODIFY']}, '_reset': {'operations':
['reset_workflow'], 'name': 'reset', 'default': 0, 'newstate': 'new',
'oldstates': [], 'permissions': []}}

Trac[svn_fs] DEBUG: Subversion bindings imported
Trac[cache] INFO: repos rev [94] != cached rev [93]
Trac[cache] INFO: Trying to sync revision [94]
Trac[cache] DEBUG: Caching node change in [94]: (u'trunk/wwwroot/
Default.aspx', 'file', 'edit', u'trunk/wwwroot/Default.aspx', 93)

Can anyone help me undertsand above code? The work follow action, does
it do anything there? any clue why it does not chnage my ticket
status?
Thank you
Best Regrads
lynda



On Jan 5, 12:04 pm, lynda <[email protected]> wrote:
> Ihave platform windows server 2008, installed trac .11 with mod_wsgi
> to use apache server. my post-commit-hook script does not update trac
> ticket. I am hoping someone can help me check if my parameters are set
> right.
> Thank you for your help
> Lynda
> Here are the insatllations:
> C:\Python26
> C:\trac // this is my trac environment
>
> In my repository/hooks diretcory:
> <b>In script post-commit.bat:</b>
>  %~dp0\trac-post-commit.cmd %1 %2
>
> <b>In Script trac-post-commit.cmd:</b>
>
> for /F %%A in ('svnlook author -r %REV% %1') do set AUTHOR=%%A
> for /F "delims==" %%B in ('svnlook log -r %REV% %1') do set LOG=%%B
>
> :: CALL THE PYTHON SCRIPT
> Python "%~dp0\trac-post-commit" -p "%TRAC_ENV%" -r "%REV%" -u "%AUTHOR
> %" -m "%LOG%"
>
> <b>In Script trac-post-commit :</b>
> import os
> import re
> import sys
>
> if not 'PYTHON_EGG_CACHE' in os.environ:
>     os.environ['PYTHON_EGG_CACHE'] = os.path.join(sys.argv[1], '.egg-
> cache')
>
> from trac.env import open_environment
>
> def main():
>     if len(sys.argv) != 3:
>         print >> sys.stderr, 'Usage: %s <trac_project> <log_message>'
> % sys.argv[0]
>         sys.exit(1)
>
>     env_path = sys.argv[1]
>     log = sys.argv[2]
>
>     tickets = []
>     for tmp in re.findall('(?:close|closed|closes|fix|fixed|fixes|
> addresses|references|refs|re|see)'
>                           '.?(#[0-9]+(?:(?:[, &]+| *and *)#[0-9]+)*)',
> log.lower()):
>         tickets += re.findall('#([0-9]+)', tmp)
>
>     # At least one ticket has to be mentioned in the log message
>     if tickets == []:
>         print >> sys.stderr, 'At least one open ticket must be
> mentioned ' \
>               'in the log message.'
>         sys.exit(1)
>
>     env = open_environment(env_path)
>     db = env.get_db_cnx()
>
>     cursor = db.cursor()
>     cursor.execute("SELECT COUNT(id) FROM ticket WHERE "
>                    "status <> 'closed' AND id IN (%s)" % ','.join
> (tickets))
>     row = cursor.fetchone()
>     # At least one of the tickets mentioned in the log messages has to
>     # be open
>     if not row or row[0] < 1:
>         print >> sys.stderr, 'At least one open ticket must be
> mentioned ' \
>               'in the log message.'
>         sys.exit(1)
>     else:
>         sys.exit(0)
>
> if __name__ == '__main__':
>     main()
-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.


Reply via email to