upgrade-zulip-from-git: Refactor to use argparse instead of sys.argv.

This is a preparatory commit to add an optional argument to mention
the git remote url. This does not make any change to the current
behaviour.
This commit is contained in:
Shubham Padia
2018-10-20 05:04:30 +05:30
committed by Tim Abbott
parent a16bf34c7f
commit bba01e210b

View File

@@ -5,6 +5,7 @@ import sys
import subprocess
import logging
import time
import argparse
config_file = configparser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf")
@@ -33,11 +34,11 @@ if os.getuid() != 0:
logging.error("Must be run as root.")
sys.exit(1)
if len(sys.argv) != 2:
print(FAIL + "Usage: upgrade-zulip-from-git refname" + ENDC)
sys.exit(1)
parser = argparse.ArgumentParser()
parser.add_argument("refname", help="Git reference, e.g. a branch, tag, or commit ID.")
args = parser.parse_args()
refname = sys.argv[1]
refname = args.refname
subprocess.check_call(["mkdir", '-p',
DEPLOYMENTS_DIR,