p4.connect() # Connect to the Perforce Server
info = p4.run("info") # Run "p4 info" (returns a dict)
changes_results = p4.run('changes','-s','submitted', '//components/rel/...@2017/11/01,@2017/12/31')
changes_lists = []
for change_result in changes_results:
change_list = change_result['change']
changes_lists.append(change_list)
print('Total Change list found ', len(changes_lists))
for idx_main, change_id in enumerate(changes_lists):
print('\n\n\n', change_id, idx_main)
result = p4.run('describe', change_id)
print(result)
depotfiles = result[0]["depotFile"]
filesrevision = result[0]["rev"]
For some change list, this is working perfectly fine p4.run is returning list and I am able to extract change list file and their revision number.
But sometimes p4.run is not returning proper list and instead returning string and I am unable to extract changelist files and their revision number and giving below error
depotfiles = result[0]["depotFile"] TypeError: string indices must be integers
Is there issue with P4 or my code.
The most straightforward way to get the list of files in a changelist (or anywhere else) is the p4 files
command.
I.e. replace:
result = p4.run('describe', change_id)
print(result)
depotfiles = result[0]["depotFile"]
filesrevision = result[0]["rev"]
with:
for result in p4.run('files', '@='+change_id):
print(result)
depotfiles = result["depotFile"]
filesrevision = result["rev"]