We switched to the python library to make it better integrated with our snippets, but it has some weird side-fx and only some operations behave other than the CLI version.
We were running the following command:
p4 sync //depot/test/...#head
which would return `file(s) up-to-date, however doing the same thing with tye python API.
from P4 import P4, P4Exception
p4 = P4()
p4.port = "ssl:test:1666"
p4.user = "test-bot"
p4.client = "test-bot_projectX_wing0044"
p4.connect()
print("before run sync")
print p4.run_sync("{}/...#head".format("//depot/projectX"))
print("after run sync")
p4.disconnect()
if p4.errors:
print(p4.errors)
if p4.warnings:
print(p4.warnings)
Output:
python V:\tests\minimal.py
before run sync
Traceback (most recent call last):
File "V:\tests\minimal.py", line 11, in <module>
print p4.run_sync("{}/...#head".format("//depot/projectX"))
File "C:\Python27\lib\site-packages\P4.py", line 497, in <lambda>
return lambda *args, **kargs: self.run(cmd, *args, **kargs)
File "C:\Python27\lib\site-packages\P4.py", line 611, in run
raise e
P4.P4Exception: [P4#run] Warnings during command execution( "p4 sync //depot/projectX/...#head" )
[Warning]: '//depot/projectX/...#head - file(s) up-to-date.'
Doesn't return anything, further, it fails to execute any other p4 command that follows after this statement (between connect and disconnect). Further, any print
statements after this failed operation are omitted. We are running this snippet in a try-catch block, however, run_sync
doesn't seem to throw.
Edit: Based on samwise's comment
I was catching p4.errors
with P4Exception
I've expanded that to p4.warnings
and now I'm seeing Warnings during command execution( "p4 sync //depot/project/...#head")
However, that is exactly the same command that's being executed when I have p4v
opened and I do a right mouse click on //depot/project
and do get latest revision