From d8c51210101553e111a162e176c493776fe9f17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Fri, 30 May 2014 11:24:18 +0200 Subject: [PATCH] [fix] Always return value instead of printing it --- app.py | 9 +++++---- dyndns.py | 7 +++++-- hook.py | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index 0318ad9f7..026ce227b 100644 --- a/app.py +++ b/app.py @@ -726,7 +726,7 @@ def app_setting(app, key, value=None, delete=False): if value is None and not delete: # Get the value if app_settings is not None and key in app_settings: - print(app_settings[key]) + return app_settings[key] else: # Set the value if app_settings is None: @@ -821,7 +821,6 @@ def app_initdb(user, password=None, db=None, sql=None): if password is None: password = random_password(12) return_pwd = True - print(password) mysql_root_pwd = open('/etc/yunohost/mysql').read().rstrip() mysql_command = 'mysql -u root -p%s -e "CREATE DATABASE %s ; GRANT ALL PRIVILEGES ON %s.* TO \'%s\'@localhost IDENTIFIED BY \'%s\';"' % (mysql_root_pwd, db, db, user, password) @@ -831,8 +830,10 @@ def app_initdb(user, password=None, db=None, sql=None): if os.system('mysql -u %s -p%s %s < %s' % (user, password, db, sql)) != 0: raise MoulinetteError(errno.EIO, m18n.n('mysql_db_init_failed')) - if not return_pwd: - msignals.display(m18n.n('mysql_db_initialized'), 'success') + if return_pwd: + return password + + msignals.display(m18n.n('mysql_db_initialized'), 'success') def app_ssowatconf(auth): diff --git a/dyndns.py b/dyndns.py index 6a5dc9f06..ee794afb0 100644 --- a/dyndns.py +++ b/dyndns.py @@ -58,8 +58,11 @@ def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None if key is None: if len(glob.glob('/etc/yunohost/dyndns/*.key')) == 0: os.makedirs('/etc/yunohost/dyndns') - print(m18n.n('dyndns_key_generating')) - os.system('cd /etc/yunohost/dyndns && dnssec-keygen -a hmac-md5 -b 128 -n USER %s' % domain) + + msignals.display(m18n.n('dyndns_key_generating')) + + os.system('cd /etc/yunohost/dyndns && ' \ + 'dnssec-keygen -a hmac-md5 -b 128 -n USER %s' % domain) os.system('chmod 600 /etc/yunohost/dyndns/*.key /etc/yunohost/dyndns/*.private') key_file = glob.glob('/etc/yunohost/dyndns/*.key')[0] diff --git a/hook.py b/hook.py index 762d996c2..be1be258e 100644 --- a/hook.py +++ b/hook.py @@ -54,7 +54,6 @@ def hook_add(app, file): except OSError: os.makedirs(hook_folder + action) finalpath = hook_folder + action +'/'+ priority +'-'+ app - print app os.system('cp %s %s' % (file, finalpath)) os.system('chown -hR admin: %s' % hook_folder)