mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
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:
committed by
Tim Abbott
parent
a16bf34c7f
commit
bba01e210b
@@ -5,6 +5,7 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
import argparse
|
||||||
|
|
||||||
config_file = configparser.RawConfigParser()
|
config_file = configparser.RawConfigParser()
|
||||||
config_file.read("/etc/zulip/zulip.conf")
|
config_file.read("/etc/zulip/zulip.conf")
|
||||||
@@ -33,11 +34,11 @@ if os.getuid() != 0:
|
|||||||
logging.error("Must be run as root.")
|
logging.error("Must be run as root.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
parser = argparse.ArgumentParser()
|
||||||
print(FAIL + "Usage: upgrade-zulip-from-git refname" + ENDC)
|
parser.add_argument("refname", help="Git reference, e.g. a branch, tag, or commit ID.")
|
||||||
sys.exit(1)
|
args = parser.parse_args()
|
||||||
|
|
||||||
refname = sys.argv[1]
|
refname = args.refname
|
||||||
|
|
||||||
subprocess.check_call(["mkdir", '-p',
|
subprocess.check_call(["mkdir", '-p',
|
||||||
DEPLOYMENTS_DIR,
|
DEPLOYMENTS_DIR,
|
||||||
|
|||||||
Reference in New Issue
Block a user