mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[fix] Remove remaining dependencies to helpers
This commit is contained in:
parent
ffcacf28f8
commit
60c6150877
3 changed files with 48 additions and 12 deletions
|
@ -35,7 +35,6 @@ import socket
|
||||||
import urlparse
|
import urlparse
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
from moulinette.helpers import win_msg, random_password, is_true, validate
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
|
||||||
repo_path = '/var/cache/yunohost/repo'
|
repo_path = '/var/cache/yunohost/repo'
|
||||||
|
@ -826,7 +825,6 @@ def app_checkurl(auth, url, app=None):
|
||||||
path = path + '/'
|
path = path + '/'
|
||||||
|
|
||||||
apps_map = app_map(raw=True)
|
apps_map = app_map(raw=True)
|
||||||
validate(r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$', domain)
|
|
||||||
|
|
||||||
if domain not in domain_list(auth)['domains']:
|
if domain not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
||||||
|
@ -1149,3 +1147,35 @@ def _is_installed(app):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def is_true(arg):
|
||||||
|
"""
|
||||||
|
Convert a string into a boolean
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
arg -- The string to convert
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Boolean
|
||||||
|
|
||||||
|
"""
|
||||||
|
true_list = ['yes', 'Yes', 'true', 'True' ]
|
||||||
|
for string in true_list:
|
||||||
|
if arg == string:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def random_password(length=8):
|
||||||
|
"""
|
||||||
|
Generate a random string
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
length -- The string length to generate
|
||||||
|
|
||||||
|
"""
|
||||||
|
import string, random
|
||||||
|
|
||||||
|
char_set = string.ascii_uppercase + string.digits + string.ascii_lowercase
|
||||||
|
return ''.join(random.sample(char_set, length))
|
||||||
|
|
|
@ -29,7 +29,6 @@ import re
|
||||||
import json
|
import json
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
from moulinette.helpers import colorize
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
|
||||||
hook_folder = '/usr/share/yunohost/hooks/'
|
hook_folder = '/usr/share/yunohost/hooks/'
|
||||||
|
@ -147,13 +146,23 @@ def hook_exec(file, args=None):
|
||||||
arg_list.append(args[arg['name']])
|
arg_list.append(args[arg['name']])
|
||||||
else:
|
else:
|
||||||
if os.isatty(1) and 'ask' in arg:
|
if os.isatty(1) and 'ask' in arg:
|
||||||
ask_string = arg['ask']['en'] #TODO: I18n
|
# Retrieve proper ask string
|
||||||
if 'choices' in arg:
|
ask_string = None
|
||||||
ask_string = ask_string +' ('+ '|'.join(arg['choices']) +')'
|
for lang in [m18n.locale, m18n.default_locale]:
|
||||||
if 'default' in arg:
|
if lang in arg['ask']:
|
||||||
ask_string = ask_string +' (default: '+ arg['default'] +')'
|
ask_string = arg['ask'][lang]
|
||||||
|
break
|
||||||
|
if not ask_string:
|
||||||
|
# Fallback to en
|
||||||
|
ask_string = arg['ask']['en']
|
||||||
|
|
||||||
input_string = raw_input(colorize(ask_string + ': ', 'cyan'))
|
# Append extra strings
|
||||||
|
if 'choices' in arg:
|
||||||
|
ask_string += ' (%s)' % '|'.join(arg['choices'])
|
||||||
|
if 'default' in arg:
|
||||||
|
ask_string += ' (default: %s)' % arg['default']
|
||||||
|
|
||||||
|
input_string = msignals.prompt(ask_string)
|
||||||
|
|
||||||
if input_string == '' and 'default' in arg:
|
if input_string == '' and 'default' in arg:
|
||||||
input_string = arg['default']
|
input_string = arg['default']
|
||||||
|
|
|
@ -34,7 +34,6 @@ import errno
|
||||||
import apt
|
import apt
|
||||||
import apt.progress
|
import apt.progress
|
||||||
|
|
||||||
from moulinette.helpers import validate
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
|
||||||
apps_setting_path= '/etc/yunohost/apps/'
|
apps_setting_path= '/etc/yunohost/apps/'
|
||||||
|
@ -118,8 +117,6 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
|
||||||
if not new_domain:
|
if not new_domain:
|
||||||
return { 'current_main_domain': old_domain }
|
return { 'current_main_domain': old_domain }
|
||||||
|
|
||||||
validate(r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$', old_domain)
|
|
||||||
|
|
||||||
config_files = [
|
config_files = [
|
||||||
'/etc/postfix/main.cf',
|
'/etc/postfix/main.cf',
|
||||||
'/etc/metronome/metronome.cfg.lua',
|
'/etc/metronome/metronome.cfg.lua',
|
||||||
|
|
Loading…
Reference in a new issue