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

Robert Cowham robert at vizim.com
Mon Aug 23 02:22:43 PDT 2010


I would also set p4.port to correct value - the triggers are spawned by the
p4d server, so with very likely a different environment to your interactive
command line.

> -----Original Message-----
> From: perforce-user-bounces at perforce.com 
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of 
> Christopher Evans
> Sent: 22 August 2010 08:45
> To: perforce-user at perforce.com
> Subject: [p4] Triggers: Log into p4 from inside a python trigger
> 
> 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
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com 
> http://maillist.perforce.com/mailman/listinfo/perforce-user




More information about the perforce-user mailing list