ret = os.popen(cmd + file).readline().strip()
if not ret.endswith('opened for edit'):
    print("Couldn't open", file, 'for edit:')
print(ret)
raise ValueError
How do I check out a file from perforce in python?