Skip to content

Commit

Permalink
Modernize python scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed Sep 30, 2020
1 parent ede19ef commit fce3c70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions ci/order-crates-for-publishing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3
#
# This script figures the order in which workspace crates must be published to
# crates.io. Along the way it also ensures there are no circular dependencies
Expand Down Expand Up @@ -42,24 +42,26 @@ def get_packages():
sys.exit(1)

# Order dependencies
deleted_dependencies = []
sorted_dependency_graph = []
max_iterations = pow(len(dependency_graph),2)
while dependency_graph:
while len(deleted_dependencies) < len(dependency_graph):
if max_iterations == 0:
# One day be more helpful and find the actual cycle for the user...
sys.exit('Error: Circular dependency suspected between these packages: \n {}\n'.format('\n '.join(dependency_graph.keys())))

max_iterations -= 1

for package, dependencies in dependency_graph.items():
for dependency in dependencies:
if dependency in dependency_graph:
break
else:
del dependency_graph[package]
deleted_dependencies.append(package)
sorted_dependency_graph.append((package, manifest_path[package]))


return sorted_dependency_graph

for package, manifest in get_packages():
print os.path.relpath(manifest)
print(os.path.relpath(manifest))
8 changes: 4 additions & 4 deletions system-test/testnet-automation-json-parser.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys, json

data=json.load(sys.stdin)

if 'results' in data:
for result in data['results']:
if 'series' in result:
print result['series'][0]['columns'][1].encode() + ': ' + str(result['series'][0]['values'][0][1])
print(result['series'][0]['columns'][1].encode() + ': ' + str(result['series'][0]['values'][0][1]))
else:
print "An expected result from CURL request is missing"
print("An expected result from CURL request is missing")
else:
print "No results returned from CURL request"
print("No results returned from CURL request")

0 comments on commit fce3c70

Please sign in to comment.