diff --git a/parse_args b/parse_args index c6df3df1..f46d02d4 100755 --- a/parse_args +++ b/parse_args @@ -444,37 +444,35 @@ action_map = { 'actions' : { 'info': { 'action_help' : _("Check System"), - 'connections' : ['ldap'], - 'arguments' : { + 'arguments' : { '-m' : { 'full' : '--memory', 'help' : _("Check Memory"), 'action' : 'store_true', - }, + }, '-c' : { 'full' : '--cpu', 'help' : _("Check CPU"), 'action' : 'store_true', - }, + }, '-d' : { 'full' : '--disk', 'help' : _("Check Disk"), 'action' : 'store_true', - }, + }, '-i' : { 'full' : '--ifconfig', 'help' : _("Ifconfig"), 'action' : 'store_true', - }, + }, '-u' : { 'full' : '--uptime', 'help' : _("Show Uptime"), 'action' : 'store_true', - }, - } - }, - } - }, + }, + } + }, + } }, ############################# # Firewall # @@ -632,13 +630,14 @@ def main(action_map): """ args = parse_dict(action_map) connections = connect_services(action_map) - + try: if connections: result = args.func(vars(args), connections) else: result = args.func(vars(args)) - except TypeError: + except TypeError, error: + print error print(_("Not (yet) implemented function")) return 1 except YunoHostError, error: diff --git a/yunohost.py b/yunohost.py index 62a18c3d..227ee3f4 100644 --- a/yunohost.py +++ b/yunohost.py @@ -4,6 +4,7 @@ import os import sys import ldap import ldap.modlist as modlist +import json import re import getpass @@ -72,8 +73,8 @@ def str_to_func(astr): func = getattr(mod, function) except (AttributeError, ImportError): - #raise YunoHostError(168, _('Function is not defined')) - return None + #raise YunoHostError(168, _('Function is not defined')) + return None else: return func @@ -208,7 +209,7 @@ class YunoHostLDAP: """ self.conn = ldap.initialize('ldap://localhost:389') - self.base = 'dc=yunohost,dc=org' + self.base = 'dc=gavoty,dc=org' self.pwd = getpass.getpass(colorize(_('LDAP Admin Password: '), 'yellow')) try: self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd) diff --git a/yunohost_monitor.py b/yunohost_monitor.py index c15a0abb..65712062 100644 --- a/yunohost_monitor.py +++ b/yunohost_monitor.py @@ -5,7 +5,7 @@ import sys import subprocess import psutil from datetime import datetime, timedelta -from psutil._compat import print_ +#from psutil._compat import print_ def bytes2human(n): symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y') @@ -22,7 +22,7 @@ def check_disk(): templ = "%s,%s/%s,%s,%s" for part in psutil.disk_partitions(all=False): usage = psutil.disk_usage(part.mountpoint) - print_(templ % (part.mountpoint, + print(templ % (part.mountpoint, bytes2human(usage.used), bytes2human(usage.total), bytes2human(usage.free), @@ -49,14 +49,14 @@ def uptime(): uptime = datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME) print "Uptime: %s" % (str(uptime).split('.')[0]) -def monitor_info(args, connections): - if args['memory'] == True: +def monitor_info(args): + if args['memory']: check_memory() - elif args['cpu'] == True: - check_cpu() - elif args['disk'] == True: + elif args['cpu']: + check_cpu() + elif args['disk']: check_disk() - elif args['ifconfig'] == True: + elif args['ifconfig']: ifconfig() - elif args['uptime'] == True: + elif args['uptime']: uptime() diff --git a/yunohost_user.py b/yunohost_user.py index 3f539933..14730678 100644 --- a/yunohost_user.py +++ b/yunohost_user.py @@ -9,7 +9,6 @@ import string import getpass from yunohost import YunoHostError, win_msg, colorize, validate - def user_list(args, connections): # TODO : fix print(args)