From 0cf94cddcc7871a11793f9f8e8b832c437bd8abd Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 19 Mar 2015 19:19:22 +0530 Subject: [PATCH] added ee update command --- config/plugins.d/update.conf | 8 ++++++++ ee/cli/plugins/update.py | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 config/plugins.d/update.conf create mode 100644 ee/cli/plugins/update.py diff --git a/config/plugins.d/update.conf b/config/plugins.d/update.conf new file mode 100644 index 00000000..27e9c53a --- /dev/null +++ b/config/plugins.d/update.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[update] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/plugins/update.py b/ee/cli/plugins/update.py new file mode 100644 index 00000000..517abca2 --- /dev/null +++ b/ee/cli/plugins/update.py @@ -0,0 +1,40 @@ +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.download import EEDownload +import time +import os + + +def ee_update_hook(app): + # do something with the ``app`` object here. + pass + + +class EEUpdateController(CementBaseController): + class Meta: + label = 'ee_update' + stacked_on = 'base' + aliases = ['update'] + aliases_only = True + stacked_type = 'nested' + description = ('update EasyEngine') + usage = "ee update" + + @expose(hide=True) + def default(self): + filename = "eeupdate" + time.strftime("%Y%m%d-%H%M%S") + EEDownload.download(self, [["http://rt.cx/ee", + "/tmp/{0}".format(filename), + "EasyEngine update script"]]) + try: + os.system("bash /tmp/{0}".format(filename)) + except Exception as e: + Log.debug(self, e) + Log.error(self, "EasyEngine update failed !") + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EEUpdateController) + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', ee_update_hook)