Browse Source

default argument needed handled

bugfixes
harshadyeola 10 years ago
parent
commit
14ec8c9314
  1. 65
      ee/cli/plugins/site.py

65
ee/cli/plugins/site.py

@ -29,7 +29,7 @@ class EESiteController(CementBaseController):
description = ('Performs website specific operations') description = ('Performs website specific operations')
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='Website name')), dict(help='Website name', nargs='?')),
] ]
@expose(hide=True) @expose(hide=True)
@ -38,6 +38,11 @@ class EESiteController(CementBaseController):
@expose(help="Enable site example.com") @expose(help="Enable site example.com")
def enable(self): def enable(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
Log.info(self, "Enable domain {0:10} \t".format(ee_domain), end='') Log.info(self, "Enable domain {0:10} \t".format(ee_domain), end='')
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -58,6 +63,11 @@ class EESiteController(CementBaseController):
@expose(help="Disable site example.com") @expose(help="Disable site example.com")
def disable(self): def disable(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
Log.info(self, "Disable domain {0:10} \t".format(ee_domain), end='') Log.info(self, "Disable domain {0:10} \t".format(ee_domain), end='')
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -81,6 +91,11 @@ class EESiteController(CementBaseController):
@expose(help="Get example.com information") @expose(help="Get example.com information")
def info(self): def info(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = '' ee_db_name = ''
ee_db_user = '' ee_db_user = ''
@ -135,6 +150,11 @@ class EESiteController(CementBaseController):
@expose(help="Edit Nginx configuration of example.com") @expose(help="Edit Nginx configuration of example.com")
def edit(self): def edit(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(ee_domain)): .format(ee_domain)):
@ -151,6 +171,11 @@ class EESiteController(CementBaseController):
@expose(help="Display Nginx configuration of example.com") @expose(help="Display Nginx configuration of example.com")
def show(self): def show(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
# TODO Write code for ee site edit command here # TODO Write code for ee site edit command here
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -167,7 +192,11 @@ class EESiteController(CementBaseController):
@expose(help="Change directory to site webroot") @expose(help="Change directory to site webroot")
def cd(self): def cd(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
if os.path.isfile('/etc/nginx/sites-available/{0}' if os.path.isfile('/etc/nginx/sites-available/{0}'
.format(ee_domain)): .format(ee_domain)):
@ -189,7 +218,8 @@ class EESiteCreateController(CementBaseController):
'required files as options are provided') 'required files as options are provided')
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='domain name for the site to be created.')), dict(help='domain name for the site to be created.',
nargs='?')),
(['--html'], (['--html'],
dict(help="create html site", action='store_true')), dict(help="create html site", action='store_true')),
(['--php'], (['--php'],
@ -220,6 +250,18 @@ class EESiteCreateController(CementBaseController):
def default(self): def default(self):
# self.app.render((data), 'default.mustache') # self.app.render((data), 'default.mustache')
# Check domain name validation # Check domain name validation
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
if not (self.app.pargs.html or self.app.pargs.php or
self.app.pargs.mysql or self.app.pargs.wp or
self.app.pargs.w3tc or self.app.pargs.wpfc or
self.app.pargs.wpsc or self.app.pargs.wpsubdir or
self.app.pargs.wpsubdomain):
self.app.pargs.html = True
data = '' data = ''
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_site_webroot = EEVariables.ee_webroot + ee_domain ee_site_webroot = EEVariables.ee_webroot + ee_domain
@ -494,7 +536,8 @@ class EESiteUpdateController(CementBaseController):
'another as per the options are provided') 'another as per the options are provided')
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='domain name for the site to be updated')), dict(help='domain name for the site to be updated',
nargs='?')),
(['--password'], (['--password'],
dict(help="update to password for wordpress site user", dict(help="update to password for wordpress site user",
action='store_true')), action='store_true')),
@ -521,6 +564,11 @@ class EESiteUpdateController(CementBaseController):
@expose(help="Update site type or cache") @expose(help="Update site type or cache")
def default(self): def default(self):
if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
data = '' data = ''
(ee_domain, (ee_domain,
ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name)
@ -947,7 +995,7 @@ class EESiteDeleteController(CementBaseController):
description = 'delete an existing website' description = 'delete an existing website'
arguments = [ arguments = [
(['site_name'], (['site_name'],
dict(help='domain name to be deleted')), dict(help='domain name to be deleted', nargs='?')),
(['--no-prompt'], (['--no-prompt'],
dict(help="doesnt ask permission for delete", dict(help="doesnt ask permission for delete",
action='store_true')), action='store_true')),
@ -962,12 +1010,15 @@ class EESiteDeleteController(CementBaseController):
@expose(help="Delete website configuration and files") @expose(help="Delete website configuration and files")
@expose(hide=True) @expose(hide=True)
def default(self): def default(self):
# TODO Write code for ee site update here if not self.app.pargs.site_name:
try:
self.app.pargs.site_name = input('Enter site name : ')
except IOError as e:
Log.error(self, 'could not input site name')
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
ee_db_name = '' ee_db_name = ''
ee_prompt = '' ee_prompt = ''
ee_nginx_prompt = '' ee_nginx_prompt = ''
if ((not self.app.pargs.db) and (not self.app.pargs.files) and if ((not self.app.pargs.db) and (not self.app.pargs.files) and
(not self.app.pargs.all)): (not self.app.pargs.all)):
self.app.pargs.all = True self.app.pargs.all = True

Loading…
Cancel
Save