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

Christopher Evans chris.evans at gmail.com
Mon Aug 23 14:40:38 PDT 2010


You were right!

I guess you should never make assumptions about the environment your
trigger will be run in.

Thanks a bunch!

CE

On Mon, Aug 23, 2010 at 11:22 AM, Robert Cowham <robert at vizim.com> wrote:
> 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
>
>



-- 
CE




More information about the perforce-user mailing list