#!/usr/bin/env python
cmd = 'p4 -G changelists -m 3'
mo = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
result = marshal.loads(mo)
pprint(result)
Nope. This won't work correctly.
You will only get the last data in the list of 3 items.
This is the correct way to do it:-
#!/usr/bin/env python
cmd = 'p4 -G changelists -m 3'
mo = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
result = []
try:
while 1:
output = marshal.load(mo.stdout)
result.append(output)
except EOFError:
pass
finally:
mo.stdout.close()
pprint(result)
No comments:
Post a Comment