2013-02-19 02:36:59 +01:00
|
|
|
import subprocess
|
2013-05-16 18:02:25 +02:00
|
|
|
import os
|
2013-02-19 02:36:59 +01:00
|
|
|
|
|
|
|
# check_output is backported from subprocess.py in Python 2.7
|
|
|
|
|
|
|
|
def check_output(*popenargs, **kwargs):
|
|
|
|
if 'stdout' in kwargs:
|
|
|
|
raise ValueError('stdout argument not allowed, it will be overridden.')
|
|
|
|
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
|
|
|
|
output, unused_err = process.communicate()
|
|
|
|
retcode = process.poll()
|
|
|
|
if retcode:
|
|
|
|
cmd = kwargs.get("args")
|
|
|
|
if cmd is None:
|
|
|
|
cmd = popenargs[0]
|
|
|
|
raise subprocess.CalledProcessError(retcode, cmd, output=output)
|
|
|
|
return output
|
2013-05-16 18:02:25 +02:00
|
|
|
|
|
|
|
DEPLOYMENTS_DIR = "/home/humbug/humbug-deployments"
|
|
|
|
LOCK_DIR = os.path.join(DEPLOYMENTS_DIR, "lock")
|
|
|
|
TIMESTAMP_FORMAT = '%Y-%m-%d-%H-%M-%S'
|
2013-06-05 00:21:47 +02:00
|
|
|
|
|
|
|
# Color codes
|
|
|
|
OKBLUE = '\033[94m'
|
|
|
|
OKGREEN = '\033[92m'
|
|
|
|
WARNING = '\033[93m'
|
|
|
|
FAIL = '\033[91m'
|
|
|
|
ENDC = '\033[0m'
|