From c002381b9e8ae032d3da45958aa2e31cb7667ecd Mon Sep 17 00:00:00 2001 From: boyska Date: Thu, 15 Dec 2016 14:20:49 +0100 Subject: [PATCH] add currency command --- messagenet.py | 7 +++++++ leggi.py => mncli.py | 13 ++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) rename leggi.py => mncli.py (89%) diff --git a/messagenet.py b/messagenet.py index e5c1297..5cf661d 100644 --- a/messagenet.py +++ b/messagenet.py @@ -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(',', '.')) diff --git a/leggi.py b/mncli.py similarity index 89% rename from leggi.py rename to mncli.py index 81e2245..5a45c7a 100644 --- a/leggi.py +++ b/mncli.py @@ -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