Skip to content

Commit

Permalink
tightend code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Nov 28, 2019
1 parent c15467e commit c2ca50d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cli50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ def main():
try:

# Publish container's ports to the host
publish = []
for port in [8080, 8081, 8082]:
publish += ["--publish", f"{port}:{port}"]
container = subprocess.check_output(["docker", "run"] + options + publish +
# https://stackoverflow.com/a/952952/5156190
container = subprocess.check_output(["docker", "run"] + options +
[item for sublist in [['--publish', f'{port}:{port}'] for port in (8080, 8081, 8082)] for item in sublist] +
[f"{IMAGE}:{args['tag']}"] + cmd, stderr=subprocess.STDOUT).decode("utf-8").rstrip()

except subprocess.CalledProcessError:

# Publish all exposed ports to random ports
container = subprocess.check_output(["docker", "run"] + options + ["--publish-all"] +
container = subprocess.check_output(["docker", "run"] + options +
["--publish-all"] +
[f"{IMAGE}:{args['tag']}"] + cmd).decode("utf-8").rstrip()

# List port mappings
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"console_scripts": ["cli50=cli50.__main__:main"]
},
url="https://github.com/cs50/cli50",
version="3.5.0",
version="3.5.1",
include_package_data=True
)

0 comments on commit c2ca50d

Please sign in to comment.