-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix (master/develop) branch checkout from config-general (#8399)
* Add apiv2 config operation route, for switching branch. * Do not initiate a restart. * Change notification message. * Remove updating from log message. * It's a backup, not necessarily used for updates. * github_updater.py: Add set-remote, to also be able to update other branches then master / develop. * Fix missing import. * Fix checking out branch. * Only check dbUpgrade for master and develop (current) branch. * Disable the actual switch branch. * Move Restart to vue component * Add apiv2 route for system operation calls. * Add restart as first operation * Move shutdown to apiv2. * Remove all the commended code. This should make it end-2-end functional. * Add modal.css * increase timeout. * Remove result, as i'm not using it "yet". * remove restart.mako * Add restart.vue component. * Fix lint errors * Move operation 'CHECKOUT_BRANCH' to system handler. * Fix remote github branches sometime not loading. Race issue. * Fix system handler. * Fix lint errors * Revert trailing comma. * Fix git branches not shown when navigating from other page through router to config-general.vue * bundle runtime * (re)load the default page after a restart. For the theme reload. Reload and force getting data from backend. * fix hard browser reload on chrome
- Loading branch information
Showing
21 changed files
with
708 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# coding=utf-8 | ||
"""Request handler for statistics.""" | ||
from __future__ import unicode_literals | ||
|
||
from medusa import app, ui | ||
from medusa.server.api.v2.base import BaseRequestHandler | ||
from medusa.system.restart import Restart | ||
from medusa.system.shutdown import Shutdown | ||
from medusa.updater.version_checker import CheckVersion | ||
|
||
from tornado.escape import json_decode | ||
|
||
|
||
class SystemHandler(BaseRequestHandler): | ||
"""System operation calls request handler.""" | ||
|
||
#: resource name | ||
name = 'system' | ||
#: identifier | ||
identifier = ('identifier', r'\w+') | ||
#: path param | ||
path_param = None | ||
#: allowed HTTP methods | ||
allowed_methods = ('POST', ) | ||
|
||
def post(self, identifier, *args, **kwargs): | ||
"""Perform an operation on the config.""" | ||
if identifier != 'operation': | ||
return self._bad_request('Invalid operation') | ||
|
||
data = json_decode(self.request.body) | ||
|
||
if data['type'] == 'RESTART' and data['pid']: | ||
if not Restart.restart(data['pid']): | ||
self._not_found('Pid does not match running pid') | ||
return self._created() | ||
|
||
if data['type'] == 'SHUTDOWN' and data['pid']: | ||
if not Shutdown.stop(data['pid']): | ||
self._not_found('Pid does not match running pid') | ||
return self._created() | ||
|
||
if data['type'] == 'CHECKOUT_BRANCH' and data['branch']: | ||
if app.BRANCH != data['branch']: | ||
app.BRANCH = data['branch'] | ||
ui.notifications.message('Checking out branch: ', data['branch']) | ||
|
||
if self._update(data['branch']): | ||
return self._created() | ||
else: | ||
return self._bad_request('Update failed') | ||
else: | ||
ui.notifications.message('Already on branch: ', data['branch']) | ||
return self._bad_request('Already on branch') | ||
|
||
return self._bad_request('Invalid operation') | ||
|
||
def _update(self, branch): | ||
checkversion = CheckVersion() | ||
backup = checkversion.updater and checkversion._runbackup() # pylint: disable=protected-access | ||
|
||
if backup is True: | ||
if branch: | ||
checkversion.updater.branch = branch | ||
|
||
if checkversion.updater.need_update() and checkversion.updater.update(): | ||
return True | ||
else: | ||
ui.notifications.message("Update wasn't successful. Check your log for more information.", branch) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.