agent: only read stdin if - is passed as filename

This makes it easier to use pdb to interactively debug the deployment code.
This commit is contained in:
Frédéric Péters 2015-02-11 12:46:35 +01:00
parent ed2b9a88f0
commit 7f07faee2a
2 changed files with 6 additions and 3 deletions

View File

@ -22,8 +22,11 @@ def replace_file(path, content):
class Command(BaseCommand):
def handle(self, base_url, *args, **kwargs):
hobo_environment = json.load(sys.stdin)
def handle(self, base_url, json_filename, *args, **kwargs):
if json_filename == '-':
hobo_environment = json.load(sys.stdin)
else:
hobo_environment = json.load(file(json_filename))
me = [x for x in hobo_environment.get('services') if x.get('base_url') == base_url][0]
domain = urlparse.urlparse(me.get('base_url')).netloc.split(':')[0]

View File

@ -51,7 +51,7 @@ class BaseService(object):
return False
def execute(self, environment):
cmd_process = subprocess.Popen(self.service_manage_cmd + ' hobo_deploy ' + self.base_url,
cmd_process = subprocess.Popen(self.service_manage_cmd + ' hobo_deploy ' + self.base_url + ' -',
shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout = cmd_process.communicate(input=json.dumps(environment))