[p4] Triggers: Log into p4 from inside a python trigger

Christopher Evans chris.evans at gmail.com
Sun Aug 22 00:44:49 PDT 2010


So, I am kind of a newb (first post!), but, I have written quite a bit
with p4python, so now I see weird errors inside a trigger that I don't
get in p4python. This is my first trigger that does anything other
than return 'hello world'.

This errors out in the try, however, the 'errors' returned are just
spaces or null chars it seems.

Question: If a submit trigger can only give you the change as an
argument, is this how you log in and get information about the file
being submitted? (describe)

Disclaimer: Because we don't have a test environ at work, I am using
the free 2 user p4 running on my local machine

Here's my trigger:

--------------------------------------------------------------

import sys
from P4 import P4, P4Exception

p4 = P4()
describe = []

try:
	p4.user = "admin"
	p4.password = "admin"
	p4.connect()
	print '1'
	info = p4.run("info")
	print info
	
except P4Exception:
	error = ''
	for e in p4.errors: error += (e+'\n')
	print error
	sys.exit(1)

print 'hello world'
print str(sys.argv)
describe = p4.run('describe',sys.argv[2])
print str(describe)

p4.disconnect()
sys.exit(1)

--------------------------------------------------------------

Thanks,

-- 
CE



More information about the perforce-user mailing list