diff --git a/modules/nginx.py b/modules/nginx.py index a31c590..3e25acb 100644 --- a/modules/nginx.py +++ b/modules/nginx.py @@ -58,25 +58,54 @@ def restart(): @task -def edit(location='conf'): +def edit(param='help'): """ calls up mvim on the Nginx conf file """ configuration = env.config - conf_path = os.path.join( + config_file_path = os.path.join( configuration.nginx.sites_available, configuration.nginx.conf.name) - if location == 'conf': - remote_path = conf_path - elif location == 'log.error' or location == 'log': - remote_path = configuration.logging.nginx.error - elif location == 'log.access': - remote_path = configuration.logging.nginx.access + locations = { + 'conf': { + 'path': config_file_path, + 'desc': "nginx configuration file", + }, - maintenance_edit(remote_path=remote_path) + 'log.error': { + 'path': configuration.logging.nginx.error, + 'desc': "nginx error log file", + }, + + 'log.access': { + 'path': configuration.logging.nxing.access, + 'desc': "nginx access log file", + }, + } + + if param in locations.keys(): + remote_path = locations[param]['path'] + maintenance_edit(remote_path=remote_path) + else: + # if param == 'help': + + print(""" + "fab nginx.edit" automates editing files important to nginx whether + locally or remotely + + to use this you must pass one of the editable locations in as a + parameter + + currently editable locations are: + """) + + for k_loc in locations.keys(): + print("\t{0: <20} - {1}".format(k_loc, locations[k_loc]['desc'])) + + return @task diff --git a/modules/supervisor.py b/modules/supervisor.py index 7453a66..1ad3827 100644 --- a/modules/supervisor.py +++ b/modules/supervisor.py @@ -138,10 +138,6 @@ def edit(param='help'): }, } - print("\n\n\nlocations: %s\n\n\n" % locations) - print("\n\n\nlocations.keys: %s\n\n\n" % locations.keys()) - print("\n\n\nparam: %s\n\n\n" % param) - if param in locations.keys(): remote_path = locations[param]['path'] maintenance_edit(remote_path=remote_path)