From 7fb7f7dd42f9393bf0659e28ed031dd5a2496945 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 4 Dec 2014 17:44:21 +0530 Subject: [PATCH] pep8 standard organized code --- ee/cli/controllers/base.py | 7 ++++-- ee/cli/controllers/clean.py | 14 ++++++----- ee/cli/controllers/debug.py | 18 ++++++++------ ee/cli/controllers/info.py | 15 ++++++++---- ee/cli/controllers/isl.py | 15 ++++++++---- ee/cli/controllers/secure.py | 17 ++++++++----- ee/cli/controllers/site.py | 47 ++++++++++++++++++------------------ ee/cli/controllers/stack.py | 9 ++++--- ee/cli/main.py | 1 + ee/utils/test.py | 2 +- tests/cli/test_ee.py | 7 ++++++ 11 files changed, 92 insertions(+), 60 deletions(-) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index 0b08fcb5..871b3e38 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -2,14 +2,17 @@ from cement.core.controller import CementBaseController, expose + class EEBaseController(CementBaseController): class Meta: label = 'base' - description = 'easyengine is the commandline tool to manage your websites based on wordpress and nginx with easy to use commands.' + description = 'easyengine is the commandline tool to manage your \ + websites based on wordpress and nginx with easy to \ + use commands.' arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT') ), + metavar='TEXT')), ] @expose(hide=True) diff --git a/ee/cli/controllers/clean.py b/ee/cli/controllers/clean.py index 02fa508c..52b9afdf 100644 --- a/ee/cli/controllers/clean.py +++ b/ee/cli/controllers/clean.py @@ -2,27 +2,29 @@ from cement.core.controller import CementBaseController, expose + class EECleanController(CementBaseController): class Meta: label = 'clean' stacked_on = 'base' stacked_type = 'nested' - description = 'clean command cleans different cache with following options' + description = 'clean command cleans different cache with following \ + options' arguments = [ (['--all'], - dict(help='clean all cache', action='store_true') ), + dict(help='clean all cache', action='store_true')), (['--fastcgi'], - dict(help='clean fastcgi cache', action='store_true')), + dict(help='clean fastcgi cache', action='store_true')), (['--memcache'], - dict(help='clean memcache', action='store_true')), + dict(help='clean memcache', action='store_true')), (['--opcache'], - dict(help='clean opcode cache cache', action='store_true')) + dict(help='clean opcode cache cache', action='store_true')) ] @expose(hide=True) def default(self): # TODO Default action for ee clean command here - print ("Inside EECleanController.default().") + print("Inside EECleanController.default().") # clean command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/controllers/debug.py b/ee/cli/controllers/debug.py index 16022eba..1347c420 100644 --- a/ee/cli/controllers/debug.py +++ b/ee/cli/controllers/debug.py @@ -2,31 +2,33 @@ from cement.core.controller import CementBaseController, expose + class EEDebugController(CementBaseController): class Meta: label = 'debug' stacked_on = 'base' stacked_type = 'nested' - description = 'debug command used for debugging issued with stack or site specific configuration' + description = 'debug command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--fpm'], - dict(help='debug fpm', action='store_true') ), + dict(help='debug fpm', action='store_true')), (['--mysql'], - dict(help='debug mysql', action='store_true') ), + dict(help='debug mysql', action='store_true')), (['--nginx'], - dict(help='debug nginx', action='store_true') ), + dict(help='debug nginx', action='store_true')), (['--php'], - dict(help='debug php', action='store_true') ), + dict(help='debug php', action='store_true')), (['--rewrite'], - dict(help='debug rewrite', action='store_true') ), + dict(help='debug rewrite', action='store_true')), (['--stop'], - dict(help='stop debugging', action='store_true') ), + dict(help='stop debugging', action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEDebugController.default().") + print("Inside EEDebugController.default().") # debug command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/controllers/info.py b/ee/cli/controllers/info.py index e7ad9eb8..70e56ae3 100644 --- a/ee/cli/controllers/info.py +++ b/ee/cli/controllers/info.py @@ -1,21 +1,26 @@ from cement.core.controller import CementBaseController, expose + class EEInfoController(CementBaseController): class Meta: label = 'info' stacked_on = 'base' stacked_type = 'nested' - description = 'info command used for debugging issued with stack or site specific configuration' + description = 'info command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--mysql'], - dict(help='get mysql configuration information', action='store_true') ), + dict(help='get mysql configuration information', + action='store_true')), (['--php'], - dict(help='get php configuration information', action='store_true') ), + dict(help='get php configuration information', + action='store_true')), (['--nginx'], - dict(help='get nginx configuration information', action='store_true') ), + dict(help='get nginx configuration information', + action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEInfoController.default().") + print("Inside EEInfoController.default().") diff --git a/ee/cli/controllers/isl.py b/ee/cli/controllers/isl.py index 3fffbf68..7ac8d40f 100644 --- a/ee/cli/controllers/isl.py +++ b/ee/cli/controllers/isl.py @@ -1,21 +1,26 @@ from cement.core.controller import CementBaseController, expose + class EEImportslowlogController(CementBaseController): class Meta: label = 'import_slow_log' stacked_on = 'base' stacked_type = 'nested' - description = 'info command used for debugging issued with stack or site specific configuration' + description = 'info command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--mysql'], - dict(help='get mysql configuration information', action='store_true') ), + dict(help='get mysql configuration information', + action='store_true')), (['--php'], - dict(help='get php configuration information', action='store_true') ), + dict(help='get php configuration information', + action='store_true')), (['--nginx'], - dict(help='get nginx configuration information', action='store_true') ), + dict(help='get nginx configuration information', + action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEImportslowlogController.default().") + print("Inside EEImportslowlogController.default().") diff --git a/ee/cli/controllers/secure.py b/ee/cli/controllers/secure.py index 122cfab9..17688636 100644 --- a/ee/cli/controllers/secure.py +++ b/ee/cli/controllers/secure.py @@ -1,22 +1,27 @@ from cement.core.controller import CementBaseController, expose + class EESecureController(CementBaseController): class Meta: label = 'secure' stacked_on = 'base' stacked_type = 'nested' - description = 'secure command used for debugging issued with stack or site specific configuration' + description = 'secure command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--ip'], - dict(help='whitelist ip addresses to access admin tools without authentication', - action='store_true') ), + dict(help='whitelist ip addresses to access admin tools without \ + authentication', + action='store_true')), (['--auth'], - dict(help='change http auth credentials', action='store_true') ), + dict(help='change http auth credentials', + action='store_true')), (['--port'], - dict(help='change port for admin tools default is 22222', action='store_true') ), + dict(help='change port for admin tools default is 22222', + action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EESecureController.default().") + print("Inside EESecureController.default().") diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 3d63d125..951e0896 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -3,15 +3,17 @@ 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' + description = 'site command manages website configuration with the help \ + of the following subcommands' arguments = [ (['site_name'], - dict(help='website name') ), + dict(help='website name')), ] @expose(hide=True) @@ -65,29 +67,28 @@ class EESiteController(CementBaseController): 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' + description = 'create command manages website configuration with the \ + help of the following subcommands' arguments = [ (['site_name'], - dict(help='the notorious foo option') ), + dict(help='the notorious foo option')), (['--html'], - dict(help="html site", action='store_true')), + dict(help="html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="wordpress site", action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="wpsubdir site", action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + dict(help="wpsubdomain site", action='store_true')), ] @expose(hide=True) @@ -95,36 +96,36 @@ class EESiteCreateController(CementBaseController): # TODO Default action for ee site command 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' + description = 'update command manages website configuration with the \ + help of the following subcommands' arguments = [ (['site_name'], - dict(help='website name', nargs="1") ), + dict(help='website name', nargs="1")), (['--html'], - dict(help="html site", action='store_true')), + dict(help="html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="wordpress site", action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="wpsubdir site", action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + 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 diff --git a/ee/cli/controllers/stack.py b/ee/cli/controllers/stack.py index 495a3df3..59b86adc 100644 --- a/ee/cli/controllers/stack.py +++ b/ee/cli/controllers/stack.py @@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose + class EEStackController(CementBaseController): class Meta: label = 'stack' @@ -10,17 +11,17 @@ class EEStackController(CementBaseController): description = 'stack command manages stack operations' arguments = [ (['--web'], - dict(help='Install web stack', action='store_true') ), + dict(help='Install web stack', action='store_true')), (['--admin'], - dict(help='Install admin tools stack', action='store_true') ), + dict(help='Install admin tools stack', action='store_true')), (['--mail'], - dict(help='Install mail server stack', action='store_true') ), + dict(help='Install mail server stack', action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee stack command - print ("Inside EEStackController.default().") + print("Inside EEStackController.default().") # stack command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/main.py b/ee/cli/main.py index 15e59dd9..69cec1e9 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -48,6 +48,7 @@ class EETestApp(EEApp): # to import it as a global (rather than passing it into another class/func) app = EEApp() + def main(): try: # Default our exit status to 0 (non-error) diff --git a/ee/utils/test.py b/ee/utils/test.py index d49f4b88..c8925e97 100644 --- a/ee/utils/test.py +++ b/ee/utils/test.py @@ -3,6 +3,7 @@ from ee.cli.main import EETestApp from cement.utils.test import * + class EETestCase(CementTestCase): app_class = EETestApp @@ -13,4 +14,3 @@ class EETestCase(CementTestCase): def tearDown(self): """Override teardown actions (for every test).""" super(EETestCase, self).tearDown() - diff --git a/tests/cli/test_ee.py b/tests/cli/test_ee.py index 0ea3fef3..e79e172e 100644 --- a/tests/cli/test_ee.py +++ b/tests/cli/test_ee.py @@ -2,8 +2,15 @@ from ee.utils import test + class CliTestCase(test.EETestCase): def test_ee_cli(self): self.app.setup() self.app.run() self.app.close() + + def test_ee_cli_site_create(self): + self.app = EETestApp(argv=['site', 'create', 'example.com']) + self.app.setup() + self.app.run() + self.app.close()