mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add beans
This commit is contained in:
parent
8029c0b142
commit
7c75cefede
2 changed files with 102 additions and 0 deletions
50
bin/yunohost
Executable file
50
bin/yunohost
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
from_source = False
|
||||
|
||||
# Run from source
|
||||
basedir = os.path.abspath('%s/../' % os.path.dirname(__file__))
|
||||
if os.path.isdir('%s/moulinette' % basedir):
|
||||
sys.path.insert(0, basedir)
|
||||
from_source = True
|
||||
|
||||
from moulinette import init, cli, MoulinetteError
|
||||
from moulinette.helpers import YunoHostError, colorize
|
||||
|
||||
|
||||
## Main action
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Run from source
|
||||
init(_from_source=from_source)
|
||||
|
||||
# Additional arguments
|
||||
use_cache = True
|
||||
if '--no-cache' in sys.argv:
|
||||
use_cache = False
|
||||
sys.argv.remove('--no-cache')
|
||||
|
||||
args = list(sys.argv)
|
||||
args.pop(0)
|
||||
|
||||
# Check that YunoHost is installed
|
||||
if not os.path.isfile('/etc/yunohost/installed') and \
|
||||
(len(args) < 2 or args[1] != 'tools' or args[2] != 'postinstall'):
|
||||
from moulinette.interfaces.cli import colorize, get_locale
|
||||
|
||||
# Init i18n
|
||||
m18n.load_namespace('yunohost')
|
||||
m18n.set_locale(get_locale())
|
||||
|
||||
# Print error and exit
|
||||
print('%s %s' % (colorize(m18n.g('error'), 'red'),
|
||||
m18n.n('yunohost_not_installed')))
|
||||
sys.exit(1)
|
||||
|
||||
# Execute the action
|
||||
ret = cli(['yunohost'], args, use_cache)
|
||||
sys.exit(ret)
|
52
bin/yunohost-api
Executable file
52
bin/yunohost-api
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
from_source = False
|
||||
|
||||
# Run from source
|
||||
basedir = os.path.abspath('%s/../' % os.path.dirname(__file__))
|
||||
if os.path.isdir('%s/moulinette' % basedir):
|
||||
sys.path.insert(0, basedir)
|
||||
from_source = True
|
||||
|
||||
from moulinette import init, api, MoulinetteError
|
||||
|
||||
|
||||
## Callbacks for additional routes
|
||||
|
||||
def is_installed():
|
||||
"""
|
||||
Check whether YunoHost is installed or not
|
||||
|
||||
"""
|
||||
installed = False
|
||||
if os.path.isfile('/etc/yunohost/installed'):
|
||||
installed = True
|
||||
return { 'installed': installed }
|
||||
|
||||
|
||||
## Main action
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Run from source
|
||||
init(_from_source=from_source)
|
||||
|
||||
# Additional arguments
|
||||
use_cache = True
|
||||
if '--no-cache' in sys.argv:
|
||||
use_cache = False
|
||||
sys.argv.remove('--no-cache')
|
||||
# TODO: Add log argument
|
||||
|
||||
try:
|
||||
# Run the server
|
||||
api(['yunohost'], 6787,
|
||||
{('GET', '/installed'): is_installed}, use_cache)
|
||||
except MoulinetteError as e:
|
||||
from moulinette.interfaces.cli import colorize
|
||||
print('%s %s' % (colorize(m18n.g('error'), 'red'), e.strerror))
|
||||
sys.exit(e.errno)
|
||||
sys.exit(0)
|
Loading…
Add table
Reference in a new issue