recursively adding files in perforce with python -


i'm building python script supposed recursively add files 3 subdirs in perforce , submit them. here's how looks:

wksp = "myworkspace"   subprocess.popen("dir /b /s /a-d | p4 -c " + wksp + " -x - add") 

here error trace:

traceback (most recent call last):   file "v2_pep8.py", line 286, in <module>     p4()   file "v2_pep8.py", line 226, in p4     subprocess.popen("dir /b /s /a-d | p4 -c " + wksp + " -x - add")   file "c:\programs\python\app\lib\subprocess.py", line 711, in __init__     errread, errwrite)   file "c:\programs\python\app\lib\subprocess.py", line 948, in _execute_child     startupinfo) windowserror: [error 2] system cannot find file specified 

if print out entire command , paste command line works, reason when script executes via subprocess.popen doesn't.

the problem subprocess.popen expects invoke process. there no dir executable; it's command that's internally recognized cmd.exe shell.

subprocess.popen("cmd.exe /c dir /s /a-d") instead should work, you'd need capture output , redirect yourself.

you try os.system("dir /b /s /a-d | p4 -c " + wksp + " -x - add"), should invoke entire command in system shell.

(of course, since you're using python, don't need use dir list of files; instead use os.listdir or os.walk.)


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -