mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
import sys
|
||
|
import os.path
|
||
|
import gettext
|
||
|
|
||
|
# Debug option
|
||
|
if '--debug' in sys.argv:
|
||
|
sys.path.append(os.path.abspath(os.path.dirname(__file__) +'/../src'))
|
||
|
from moulinette import cli
|
||
|
from moulinette.core.helpers import YunoHostError, colorize
|
||
|
|
||
|
gettext.install('YunoHost')
|
||
|
|
||
|
|
||
|
## Main action
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
# Additional arguments
|
||
|
use_cache = True
|
||
|
if '--no-cache' in sys.argv:
|
||
|
use_cache = False
|
||
|
sys.argv.remove('--no-cache')
|
||
|
if '--debug' in sys.argv:
|
||
|
sys.argv.remove('--debug')
|
||
|
|
||
|
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(args, use_cache)
|
||
|
except YunoHostError as e:
|
||
|
print(colorize(_("Error: "), 'red') + e.message)
|
||
|
sys.exit(e.code)
|
||
|
sys.exit(0)
|