From 35cdb1fe13d6446919e2279e04a0acfc625207b9 Mon Sep 17 00:00:00 2001 From: Ronny Abraham Date: Wed, 10 Oct 2018 13:06:02 +0300 Subject: [PATCH] added the ability to specify what machine we want to edit files on (probably should be removed) --- modules/maintenance.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/maintenance.py b/modules/maintenance.py index 2d1fc94..18eea22 100644 --- a/modules/maintenance.py +++ b/modules/maintenance.py @@ -4,7 +4,7 @@ import os import sys import utils -from utils import executize, virtualenv +from utils import executize, virtualenv, loggify def command(program=None, cmd=None, extra_param=None): @@ -65,21 +65,31 @@ def command(program=None, cmd=None, extra_param=None): _execute(_command) -def edit(remote_path): +def edit(remote_path, host_string=None): """ calls up mvim or vim on the file remote_path - path to file we want to edit + host_string - what machine the file is located on + + host_string is necessary b/c in the case where I want to edit + configuration files, it is essential to do so only on the localhost + + that is, whether I'm editing staging, development or production project + yml files, the place to do that editing is ALWAYS on localhost, this is + because all fabric commands are executed from localhost and will check for + the necessary configuration files on local (I'm not running fabric from an + ssh command line on the aws server, I'm running it on my laptop) """ - # logger = loggify('maintenance', 'edit') + logger = loggify('maintenance', 'edit') # configuration = env.config if env.debug: - # logger.debug("remote_path : %s" % remote_path) - # logger.debug("env.host_string : %s" % env.host_string) - # logger.debug("sys.platform : %s" % sys.platform) + logger.debug("remote_path : %s" % remote_path) + logger.debug("env.host_string : %s" % env.host_string) + logger.debug("sys.platform : %s" % sys.platform) pass else: @@ -88,10 +98,13 @@ def edit(remote_path): else: editor = "vim" + if not host_string: + host_string = env.host_string + cmd_edit = "{editor} sftp://{user}@{host_string}/{remote_path}".format( editor=editor, user=env.user, - host_string=env.host_string, + host_string=host_string, remote_path=remote_path) local(cmd_edit)