Skip to content

Commit 4f5cc1a

Browse files
committed
added ee update command
1 parent 9f50b17 commit 4f5cc1a

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

config/ee.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ password =
6767

6868
### EMail for WordPress sites
6969
email =
70+
71+
[update]
72+
73+
### If enabled, load a plugin named `update` either from the Python module
74+
### `ee.cli.plugins.example` or from the file path
75+
### `/var/lib/ee/plugins/example.py`
76+
enable_plugin = true

ee/cli/plugins/update.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from cement.core.controller import CementBaseController, expose
2+
from cement.core import handler, hook
3+
from ee.core.download import EEDownload
4+
from ee.core.logging import Log
5+
import time
6+
import os
7+
8+
9+
def ee_update_hook(app):
10+
# do something with the ``app`` object here.
11+
pass
12+
13+
14+
class EEUpdateController(CementBaseController):
15+
class Meta:
16+
label = 'ee_update'
17+
stacked_on = 'base'
18+
aliases = ['update']
19+
aliases_only = True
20+
stacked_type = 'nested'
21+
description = ('update EasyEngine to latest version')
22+
usage = "ee update"
23+
24+
@expose(hide=True)
25+
def default(self):
26+
filename = "eeupdate" + time.strftime("%Y%m%d-%H%M%S")
27+
EEDownload.download(self, [["http://rt.cx/ee",
28+
"/tmp/{0}".format(filename),
29+
"update script"]])
30+
try:
31+
Log.info(self, "updating EasyEngine, please wait ...")
32+
os.system("bash /tmp/{0}".format(filename))
33+
except OSError as e:
34+
Log.debug(self, str(e))
35+
Log.error(self, "EasyEngine update failed !")
36+
except Exception as e:
37+
Log.debug(self, str(e))
38+
Log.error(self, "EasyEngine update failed !")
39+
40+
41+
def load(app):
42+
# register the plugin class.. this only happens if the plugin is enabled
43+
handler.register(EEUpdateController)
44+
# register a hook (function) to run after arguments are parsed.
45+
hook.register('post_argument_parsing', ee_update_hook)

0 commit comments

Comments
 (0)