Bug fixes

This commit is contained in:
Kloadut 2012-10-15 22:48:05 +02:00
parent 6fec72d127
commit 1f4b115b6f
4 changed files with 25 additions and 26 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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()

View file

@ -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)