mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
* Revert to classes centralization into actionsmap.py * Try to optimize conditions and loops * Revisit Package class and get directories from a file generated at build * Early refactoring of i18n * Move yunohost library into /lib
45 lines
1.2 KiB
Python
Executable file
45 lines
1.2 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
import os.path
|
|
|
|
# Run from source
|
|
basedir = os.path.abspath('%s/../' % os.path.dirname(__file__))
|
|
if os.path.isdir('%s/src' % basedir):
|
|
sys.path.append('%s/src' % basedir)
|
|
|
|
from moulinette import init, cli, MoulinetteError
|
|
from moulinette.helpers import YunoHostError, colorize
|
|
|
|
|
|
## Main action
|
|
|
|
if __name__ == '__main__':
|
|
# Run from source
|
|
init(_from_source=True)
|
|
|
|
# Additional arguments
|
|
use_cache = True
|
|
if '--no-cache' in sys.argv:
|
|
use_cache = False
|
|
sys.argv.remove('--no-cache')
|
|
|
|
try:
|
|
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'):
|
|
raise YunoHostError(17, _("YunoHost is not correctly installed, please execute 'yunohost tools postinstall'"))
|
|
|
|
# Execute the action
|
|
cli(['yunohost'], args, use_cache)
|
|
except MoulinetteError as e:
|
|
print(e.colorize())
|
|
sys.exit(e.code)
|
|
except YunoHostError as e:
|
|
print(colorize(_("Error: "), 'red') + e.message)
|
|
sys.exit(e.code)
|
|
sys.exit(0)
|