add currency command

This commit is contained in:
boyska 2016-12-15 14:20:49 +01:00
parent 660fede91d
commit c002381b9e
2 changed files with 15 additions and 5 deletions

View file

@ -103,3 +103,10 @@ class Messagenet(object):
fw_all = bool(int(b.find_by_id('tutte').value))
fw_to = b.find_by_id('numdev').value
return {'type': fw_type, 'all': fw_all, 'to': fw_to}
def get_currency(self):
b = self.browser
b.visit(self.BASE + '/voip/numeri')
moneystring = b.find_by_css('.currency span').first.value
# FIXME: should do a proper parsing based on LC_CURRENCY
return float(moneystring.replace(',', '.'))

View file

@ -24,16 +24,17 @@ def save_calls(calls, datadir):
def replhelp():
return '''
help - show this message
calllog - show every call, done and received
IN - show every inbound call
OUT - show every outbound call
help - show this message
calllog - show every call, done and received
IN - show every inbound call
OUT - show every outbound call
forward $NUMBER - forward calls to number
forward STOP - disable forwarding
currency - how rich are you ?
'''
if __name__ == '__main__':
def main():
conf = json.load(open(os.path.join(
os.path.dirname(sys.argv[0]),
'defaultconf.json')))
@ -85,6 +86,8 @@ if __name__ == '__main__':
mn.set_forward(False)
else:
mn.set_forward(args[0])
elif cmd == 'currency':
print mn.get_currency()
else:
print " Invalid command '%s'; type 'help' to get help" % cmd