I want to search a Perforce depot for files.
I do this from a python script and use the p4python
library command:
list = p4.run("files", "//mypath/myfolder/*")
This works fine as long as myfolder
contains some files. I get a python list
as a return value. But when there is no file in myfolder
the program stops running and no error message is displayed. My goal is to get an empty python list
, so that I can see that this folder doesn't contain any files.
Does anybody has some ideas? I could not find information in the p4
files documentation and on StackOverflow.
I'm going to guess you've got an exception handler around that command execution that's eating the exception and exiting. I wrote a very simple test script and got this:
C:\Perforce\test>C:\users\samwise\AppData\local\programs\python\Python36-32\python files.py
Traceback (most recent call last):
File "files.py", line 6, in <module>
print(p4.run("files", "//depot/no such path/*"))
File "C:\users\samwise\AppData\local\programs\python\Python36-32\lib\site-packages\P4.py", line 611, in run
raise e
File "C:\users\samwise\AppData\local\programs\python\Python36-32\lib\site-packages\P4.py", line 605, in run
result = P4API.P4Adapter.run(self, *flatArgs)
P4.P4Exception: [P4#run] Errors during command execution( "p4 files //depot/no such path/*" )
[Error]: "//depot/no such path/* - must refer to client 'Samwise-dvcs-1509687817'."