Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: client/cipd.py

Issue 2667673002: [client] Add support to run_isolated/cipd for cipd 1.5. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/run_isolated.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cipd.py
diff --git a/client/cipd.py b/client/cipd.py
index 2539ef74b3c29b593f14c8a4e624a7c5a2c99d66..17b4a63c491fec6a3a0ed34b33cb1943dddad64e 100644
--- a/client/cipd.py
+++ b/client/cipd.py
@@ -202,7 +202,23 @@ class CipdClient(object):
exit_code, '\n'.join(output)))
with open(json_file_path) as jfile:
result_json = json.load(jfile)
- return [(x['package'], x['instance_id']) for x in result_json['result']]
+ # TEMPORARY(iannucci): this code handles cipd <1.4 and cipd >=1.5
+ # formatted ensure result formats. Cipd 1.5 added support for subdirs, and
+ # as part of the transition, the result of the ensure command needed to
+ # change. To ease the transition, we always return data as-if we're using
+ # the new format. Once cipd 1.5+ is deployed everywhere, this type switch
+ # can be removed.
+ if isinstance(result_json['result'], dict):
+ # cipd 1.5
+ return {
+ subdir: [(x['package'], x['instance_id']) for x in pins]
+ for subdir, pins in result_json['result'].iteritems()
+ }
+ else:
+ # cipd 1.4
+ return {
+ "": [(x['package'], x['instance_id']) for x in result_json['result']],
+ }
finally:
fs.remove(list_file_path)
fs.remove(json_file_path)
« no previous file with comments | « no previous file | client/run_isolated.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698