move update api to update.py
This commit is contained in:
parent
2cd77e07a2
commit
5ede07edca
2 changed files with 33 additions and 32 deletions
33
oml/api.py
33
oml/api.py
|
@ -10,10 +10,9 @@ import ox
|
|||
from oxtornado import actions
|
||||
|
||||
|
||||
import settings
|
||||
|
||||
import item.api
|
||||
import user.api
|
||||
import update
|
||||
|
||||
|
||||
def selectFolder(data):
|
||||
|
@ -78,33 +77,3 @@ def autocompleteFolder(data):
|
|||
'items': ox.sorted_strings(folders)
|
||||
}
|
||||
actions.register(autocompleteFolder, cache=False)
|
||||
|
||||
def getVersion(data):
|
||||
'''
|
||||
check if new version is available
|
||||
'''
|
||||
response = {
|
||||
'current': settings.MINOR_VERSION,
|
||||
'upgrade': False,
|
||||
}
|
||||
if not os.path.exists(os.path.join(settings.updates_path, 'release.json')):
|
||||
return response
|
||||
if not os.path.exists(os.path.join(settings.config_path, 'release.json')):
|
||||
return response
|
||||
with open(os.path.join(settings.updates_path, 'release.json')) as fd:
|
||||
release = json.load(fd)
|
||||
current = settings.release['modules']['openmedialibrary']['version']
|
||||
response['current'] = current
|
||||
new = release['modules']['openmedialibrary']['version']
|
||||
response['new'] = new
|
||||
response['update'] = current < new
|
||||
return response
|
||||
actions.register(getVersion, cache=False)
|
||||
|
||||
def restart(data):
|
||||
'''
|
||||
restart (and upgrade if upgrades are available)
|
||||
'''
|
||||
subprocess.Popen(['./ctl', 'restart'], close_fds=True)
|
||||
return {}
|
||||
actions.register(restart, cache=False)
|
||||
|
|
|
@ -12,9 +12,11 @@ import subprocess
|
|||
|
||||
import ed25519
|
||||
import ox
|
||||
from oxtornado import actions
|
||||
|
||||
import settings
|
||||
|
||||
|
||||
ENCODING='base64'
|
||||
RELEASE_URL = 'http://downloads.openmedialibrary.com/release.json'
|
||||
|
||||
|
@ -125,3 +127,33 @@ def install():
|
|||
subprocess.call(cmd)
|
||||
return True
|
||||
return True
|
||||
|
||||
def getVersion(data):
|
||||
'''
|
||||
check if new version is available
|
||||
'''
|
||||
response = {
|
||||
'current': settings.MINOR_VERSION,
|
||||
'upgrade': False,
|
||||
}
|
||||
if not os.path.exists(os.path.join(settings.updates_path, 'release.json')):
|
||||
return response
|
||||
if not os.path.exists(os.path.join(settings.config_path, 'release.json')):
|
||||
return response
|
||||
with open(os.path.join(settings.updates_path, 'release.json')) as fd:
|
||||
release = json.load(fd)
|
||||
current = settings.release['modules']['openmedialibrary']['version']
|
||||
response['current'] = current
|
||||
new = release['modules']['openmedialibrary']['version']
|
||||
response['new'] = new
|
||||
response['update'] = current < new
|
||||
return response
|
||||
actions.register(getVersion, cache=False)
|
||||
|
||||
def restart(data):
|
||||
'''
|
||||
restart (and upgrade if upgrades are available)
|
||||
'''
|
||||
subprocess.Popen(['./ctl', 'restart'], close_fds=True)
|
||||
return {}
|
||||
actions.register(restart, cache=False)
|
||||
|
|
Loading…
Reference in a new issue