Refactor update

This commit is contained in:
VirtuBox
2019-07-19 00:57:32 +02:00
parent e3138432e5
commit dce0618e43

View File

@@ -25,6 +25,9 @@ class WOUpdateController(CementBaseController):
(['--preserve'], (['--preserve'],
dict(help='Preserve current Nginx configuration', dict(help='Preserve current Nginx configuration',
action='store_true')), action='store_true')),
(['--beta'],
dict(help='Update WordOps to latest beta release',
action='store_true')),
(['--travis'], (['--travis'],
dict(help='Argument used only for WordOps development', dict(help='Argument used only for WordOps development',
action='store_true')), action='store_true')),
@@ -36,51 +39,33 @@ class WOUpdateController(CementBaseController):
filename = "woupdate" + time.strftime("%Y%m%d-%H%M%S") filename = "woupdate" + time.strftime("%Y%m%d-%H%M%S")
if self.app.pargs.travis: if self.app.pargs.travis:
WODownload.download(self, [["https://raw.githubusercontent.com/" wo_branch = "updating-configuration"
"WordOps/WordOps/updating-configuration/install", install_args = "--travis --force "
"/tmp/{0}".format(filename), elif self.app.pargs.beta:
"update script"]]) wo_branch = "beta"
try: install_args = ""
Log.info(self, "updating WordOps, please wait...")
os.system("bash /tmp/{0} --travis --force".format(filename))
except OSError as e:
Log.debug(self, str(e))
Log.error(self, "WordOps update failed !")
else: else:
WODownload.download(self, [["https://raw.githubusercontent.com/" wo_branch = "master "
"WordOps/WordOps/master/install", install_args = ""
"/tmp/{0}".format(filename), if self.app.pargs.force:
"update script"]]) install_args = install_args + "--force "
if self.app.pargs.force: if self.app.pargs.preserve:
try: install_args = install_args + "--preserve "
Log.info(self, "updating WordOps, please wait...")
os.system("bash /tmp/{0} --force".format(filename)) WODownload.download(self, [["https://raw.githubusercontent.com/"
except OSError as e: "WordOps/WordOps/{0}/install"
Log.debug(self, str(e)) .format(wo_branch),
Log.error(self, "WordOps update failed !") "/var/lib/wo/tmp/{0}".format(filename),
except Exception as e: "update script"]])
Log.debug(self, str(e))
Log.error(self, "WordOps update failed !") try:
elif self.app.pargs.preserve: Log.info(self, "updating WordOps, please wait...")
try: os.system("/bin/bash /var/lib/wo/tmp/{0} "
Log.info(self, "updating WordOps, please wait...") "-b {1} {2}".format(filename,
os.system("bash /tmp/{0} --preserve".format(filename)) wo_branch, install_args))
except OSError as e: except OSError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, "WordOps update failed !") Log.error(self, "WordOps update failed !")
except Exception as e:
Log.debug(self, str(e))
Log.error(self, "WordOps update failed !")
else:
try:
Log.info(self, "updating WordOps, please wait...")
os.system("bash /tmp/{0}".format(filename))
except OSError as e:
Log.debug(self, str(e))
Log.error(self, "WordOps update failed !")
except Exception as e:
Log.debug(self, str(e))
Log.error(self, "WordOps update failed !")
def load(app): def load(app):