From bbdc8cf05c3d9ddb4b029d5d8b82ccb7ebb0be58 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 18:35:10 +0530 Subject: [PATCH 1/2] moved site controller to plugins --- ee/cli/bootstrap.py | 6 -- ee/cli/controllers/site.py | 144 ------------------------------------- 2 files changed, 150 deletions(-) delete mode 100644 ee/cli/controllers/site.py diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index de3c5108..b22b6ca3 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,9 +5,6 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController -from ee.cli.controllers.site import EESiteController -from ee.cli.controllers.site import EESiteCreateController -from ee.cli.controllers.site import EESiteUpdateController from ee.cli.controllers.debug import EEDebugController from ee.cli.controllers.clean import EECleanController from ee.cli.controllers.secure import EESecureController @@ -17,9 +14,6 @@ from ee.cli.controllers.info import EEInfoController def load(app): handler.register(EEBaseController) - handler.register(EESiteController) - handler.register(EESiteCreateController) - handler.register(EESiteUpdateController) handler.register(EEDebugController) handler.register(EECleanController) handler.register(EEInfoController) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py deleted file mode 100644 index bee9cb9e..00000000 --- a/ee/cli/controllers/site.py +++ /dev/null @@ -1,144 +0,0 @@ -"""EasyEngine site controller.""" - -from cement.core.controller import CementBaseController, expose -from ee.core.dummy import EEDummy - - -class EESiteController(CementBaseController): - class Meta: - label = 'site' - stacked_on = 'base' - stacked_type = 'nested' - description = 'site command manages website configuration with the help \ - of the following subcommands' - arguments = [ - (['site_name'], - dict(help='website name')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee site command - print("Inside EESiteController.default().") - - @expose(help="delete site example.com") - def delete(self): - # TODO Write code for ee site delete command here - print("Inside EESiteController.delete().") - - @expose(help="enable site example.com") - def enable(self): - # TODO Write code for ee site enable command here - print("Inside EESiteController.enable().") - - @expose(help="disable site example.com") - def disable(self): - # TODO Write code for ee site disable command here - print("Inside EESiteController.disable().") - - @expose(help="get example.com information") - def info(self): - # TODO Write code for ee site info command here - print("Inside EESiteController.info().") - - @expose(help="Monitor example.com logs") - def log(self): - # TODO Write code for ee site log command here - print("Inside EESiteController.log().") - - @expose(help="Edit example.com's nginx configuration") - def edit(self): - # TODO Write code for ee site edit command here - print("Inside EESiteController.edit().") - - @expose(help="Display example.com's nginx configuration") - def show(self): - # TODO Write code for ee site edit command here - print("Inside EESiteController.show().") - - @expose(help="list sites currently available") - def list(self): - # TODO Write code for ee site list command here - print("Inside EESiteController.list().") - - @expose(help="change to example.com's webroot") - def cd(self): - # TODO Write code for ee site cd here - print("Inside EESiteController.cd().") - - -class EESiteCreateController(CementBaseController): - class Meta: - label = 'create' - stacked_on = 'site' - stacked_type = 'nested' - description = 'create command manages website configuration with the \ - help of the following subcommands' - arguments = [ - (['site_name'], - dict(help='the notorious foo option')), - (['--html'], - dict(help="html site", action='store_true')), - (['--php'], - dict(help="php site", action='store_true')), - (['--mysql'], - dict(help="mysql site", action='store_true')), - (['--wp'], - dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee site command - data = dict(foo='EESiteCreateController.default().') - self.app.render((data), 'default.mustache') - - # print("Inside EESiteCreateController.default().") - - -class EESiteUpdateController(CementBaseController): - class Meta: - label = 'update' - stacked_on = 'site' - stacked_type = 'nested' - description = 'update command manages website configuration with the \ - help of the following subcommands' - arguments = [ - (['site_name'], - dict(help='website name')), - (['--html'], - dict(help="html site", action='store_true')), - (['--php'], - dict(help="php site", action='store_true')), - (['--mysql'], - dict(help="mysql site", action='store_true')), - (['--wp'], - dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), - ] - - @expose(help="update example.com") - def default(self): - # TODO Write code for ee site update here - print("Inside EESiteUpdateController.default().") - - # site command Options and subcommand calls and definations to - # mention here - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # From 5e5c4560bd2c79d5821febf7034549b78604120e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 19:11:13 +0530 Subject: [PATCH 2/2] minor update --- ee/cli/plugins/site.py | 158 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 ee/cli/plugins/site.py diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py new file mode 100644 index 00000000..7848c305 --- /dev/null +++ b/ee/cli/plugins/site.py @@ -0,0 +1,158 @@ +"""EasyEngine site controller.""" +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook + + +def ee_site_hook(app): + # do something with the ``app`` object here. + pass + + +class EESiteController(CementBaseController): + class Meta: + label = 'site' + stacked_on = 'base' + stacked_type = 'nested' + description = ('site command manages website configuration' + 'with the help of the following subcommands') + arguments = [ + (['site_name'], + dict(help='website name')), + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee site command + print("Inside EESiteController.default().") + + @expose(help="delete site example.com") + def delete(self): + # TODO Write code for ee site delete command here + print("Inside EESiteController.delete().") + + @expose(help="enable site example.com") + def enable(self): + # TODO Write code for ee site enable command here + print("Inside EESiteController.enable().") + + @expose(help="disable site example.com") + def disable(self): + # TODO Write code for ee site disable command here + print("Inside EESiteController.disable().") + + @expose(help="get example.com information") + def info(self): + # TODO Write code for ee site info command here + print("Inside EESiteController.info().") + + @expose(help="Monitor example.com logs") + def log(self): + # TODO Write code for ee site log command here + print("Inside EESiteController.log().") + + @expose(help="Edit example.com's nginx configuration") + def edit(self): + # TODO Write code for ee site edit command here + print("Inside EESiteController.edit().") + + @expose(help="Display example.com's nginx configuration") + def show(self): + # TODO Write code for ee site edit command here + print("Inside EESiteController.show().") + + @expose(help="list sites currently available") + def list(self): + # TODO Write code for ee site list command here + print("Inside EESiteController.list().") + + @expose(help="change to example.com's webroot") + def cd(self): + # TODO Write code for ee site cd here + print("Inside EESiteController.cd().") + + +class EESiteCreateController(CementBaseController): + class Meta: + label = 'create' + stacked_on = 'site' + stacked_type = 'nested' + description = 'create command manages website configuration with the \ + help of the following subcommands' + arguments = [ + (['site_name'], + dict(help='the notorious foo option')), + (['--html'], + dict(help="html site", action='store_true')), + (['--php'], + dict(help="php site", action='store_true')), + (['--mysql'], + dict(help="mysql site", action='store_true')), + (['--wp'], + dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], + dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], + dict(help="wpsubdomain site", action='store_true')), + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee site command + data = dict(foo='EESiteCreateController.default().') + self.app.render((data), 'default.mustache') + + # print("Inside EESiteCreateController.default().") + + +class EESiteUpdateController(CementBaseController): + class Meta: + label = 'update' + stacked_on = 'site' + stacked_type = 'nested' + description = 'update command manages website configuration with the \ + help of the following subcommands' + arguments = [ + (['site_name'], + dict(help='website name')), + (['--html'], + dict(help="html site", action='store_true')), + (['--php'], + dict(help="php site", action='store_true')), + (['--mysql'], + dict(help="mysql site", action='store_true')), + (['--wp'], + dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], + dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], + dict(help="wpsubdomain site", action='store_true')), + ] + + @expose(help="update example.com") + def default(self): + # TODO Write code for ee site update here + print("Inside EESiteUpdateController.default().") + + # site command Options and subcommand calls and definations to + # mention here + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EESiteController) + handler.register(EESiteCreateController) + handler.register(EESiteUpdateController) + + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', ee_site_hook)