Changeset 108 for hacks


Ignore:
Timestamp:
Dec 11, 2017, 1:04:59 PM (8 years ago)
Author:
bird
Message:

fritzboxdect.py: better diags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • hacks/munin/fritzboxdect.py

    r107 r108  
    6363
    6464
     65## Wheter to display debug messages.
     66g_fDebug = len(os.environ.get('debug', '')) > 0;
     67
    6568
    6669class FritzBoxConnection(object):
     
    7376
    7477    def __init__(self, sServer, sPassword, iPort = 80):
    75         self.fDebug = len(os.environ.get('debug', '')) > 0;
    76 
    7778        #
    7879        # Connect to the fritz!box.
     
    143144            sName, sValue = sArg.split('=')
    144145            sUrl += '&' + urllib_quote(sName) + '=' + urllib_quote(sValue);
    145         if self.fDebug:
     146        if g_fDebug:
    146147            print('debug: sUrl: %s' % (sUrl,));
    147148
     
    161162        asRet = [];
    162163        asIps       = os.environ.get('fritzboxdect_ip', '10.42.2.1 10.42.1.50').split();
     164        if len(asIps) == 0:
     165            raise Exception('environment variable fritzboxdect_ip is empty')
    163166        asPasswords = os.environ.get('fritzboxdect_password', '').split();
     167        if len(asPasswords) == 0:
     168            raise Exception('environment variable fritzboxdect_password is empty')
     169        if g_fDebug:
     170            print('debug: asIps=%s asPasswords=%s' % (asIps, asPasswords,));
     171
    164172        for i, sIp in enumerate(asIps):
    165173            sPassword = asPasswords[i] if i < len(asPasswords) else asPasswords[-1];
Note: See TracChangeset for help on using the changeset viewer.