update-deployment: Move constants to humbug_tools

(imported from commit d3699d684b74b15a10f0a464f58623a376f7d486)
This commit is contained in:
Zev Benjamin 2013-05-16 12:02:25 -04:00 committed by Tim Abbott
parent 6b3b418010
commit 4cdecdea21
2 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import subprocess import subprocess
import os
# check_output is backported from subprocess.py in Python 2.7 # check_output is backported from subprocess.py in Python 2.7
@ -14,3 +15,7 @@ def check_output(*popenargs, **kwargs):
cmd = popenargs[0] cmd = popenargs[0]
raise subprocess.CalledProcessError(retcode, cmd, output=output) raise subprocess.CalledProcessError(retcode, cmd, output=output)
return output return output
DEPLOYMENTS_DIR = "/home/humbug/humbug-deployments"
LOCK_DIR = os.path.join(DEPLOYMENTS_DIR, "lock")
TIMESTAMP_FORMAT = '%Y-%m-%d-%H-%M-%S'

View File

@ -5,7 +5,7 @@ import subprocess
import pylibmc import pylibmc
import traceback import traceback
import logging import logging
from humbug_tools import check_output from humbug_tools import check_output, DEPLOYMENTS_DIR, LOCK_DIR, TIMESTAMP_FORMAT
import datetime import datetime
import shutil import shutil
@ -19,9 +19,6 @@ WARNING = '\033[93m'
FAIL = '\033[91m' FAIL = '\033[91m'
ENDC = '\033[0m' ENDC = '\033[0m'
DEPLOYMENTS_DIR = "/home/humbug/humbug-deployments"
LOCK_DIR = os.path.join(DEPLOYMENTS_DIR, "lock")
os.chdir("/home/humbug/humbug") os.chdir("/home/humbug/humbug")
if len(sys.argv) > 1: if len(sys.argv) > 1:
oldrev = sys.argv[1] oldrev = sys.argv[1]
@ -50,7 +47,7 @@ subprocess.check_call(["find", ".", "-name", "*.pyc", "-delete"], stdout=open('/
logging.info("Updating static files") logging.info("Updating static files")
subprocess.check_call(["./tools/update-prod-static"]) subprocess.check_call(["./tools/update-prod-static"])
timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S') timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT)
deploy_path = os.path.join(DEPLOYMENTS_DIR, timestamp) deploy_path = os.path.join(DEPLOYMENTS_DIR, timestamp)
subprocess.check_call(["cp", '-a', '/home/humbug/humbug', deploy_path]) subprocess.check_call(["cp", '-a', '/home/humbug/humbug', deploy_path])
subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "current")]) subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "current")])