fritzcollectd/__init__.py
def init(self):
        """ Initialize the connection to the FRITZ!Box """
        self._fc = fritzconnection.FritzConnection(
            address=self._fritz_address, port=self._fritz_port,
            user=self._fritz_user, password=self._fritz_password)
        if self._fc.modelname is None:
            self._fc = None
            raise IOError("fritzcollectd: Failed to connect to %s" %
                          self._fritz_address)

        if not self._fc.call_action('WANIPConn:1', 'GetStatusInfo'):
            self._fc = None
            raise IOError("fritzcollectd: Statusinformation via UPnP is "
                          "not enabled")

        if self._fritz_password != '':
            # If the 'Allow access for applications' option is disabled,
            # the connection behaves as if it was created without password.
            if 'WANIPConnection:1' not in self._fc.services.keys():
                self._fc = None
                raise IOError("fritzcollectd: Allow access for applications "
                              "is not enabled")

            try:
                self._fc.call_action('WANIPConnection:1', 'GetStatusInfo')
            except fritzconnection.AuthorizationError:
                self._fc = None
                raise IOError("fritzcollectd: Incorrect password or "
                              "'FRITZ!Box Settings' rights for user disabled")
        else:
            collectd.info("fritzcollectd: No password configured, "
                          "some values cannot be queried")

        self._filter_service_actions(self.SERVICE_ACTIONS,
                                     self._fc.actionnames)
 Initialize the connection to the FRITZ!Box 
Initialize the connection to the FRITZ!Box
Initialize the connection to the FRITZ!Box
def init(self):
        self._fc = fritzconnection.FritzConnection(
            address=self._fritz_address, port=self._fritz_port,
            user=self._fritz_user, password=self._fritz_password)
        if self._fc.modelname is None:
            self._fc = None
            raise IOError("fritzcollectd: Failed to connect to %s" %
                          self._fritz_address)
        if not self._fc.call_action('WANIPConn:1', 'GetStatusInfo'):
            self._fc = None
            raise IOError("fritzcollectd: Statusinformation via UPnP is "
                          "not enabled")
        if self._fritz_password != '':
            if 'WANIPConnection:1' not in self._fc.services.keys():
                self._fc = None
                raise IOError("fritzcollectd: Allow access for applications "
                              "is not enabled")
            try:
                self._fc.call_action('WANIPConnection:1', 'GetStatusInfo')
            except fritzconnection.AuthorizationError:
                self._fc = None
                raise IOError("fritzcollectd: Incorrect password or "
                              "'FRITZ!Box Settings' rights for user disabled")
        else:
            collectd.info("fritzcollectd: No password configured, "
                          "some values cannot be queried")
        self._filter_service_actions(self.SERVICE_ACTIONS,
                                     self._fc.actionnames)
def init ( self ) : self . _fc = fritzconnection . FritzConnection ( address = self . _fritz_address , port = self . _fritz_port , user = self . _fritz_user , password = self . _fritz_password ) if self . _fc . modelname is None : self . _fc = None raise IOError ( "fritzcollectd: Failed to connect to %s" % self . _fritz_address ) if not self . _fc . call_action ( 'WANIPConn:1' , 'GetStatusInfo' ) : self . _fc = None raise IOError ( "fritzcollectd: Statusinformation via UPnP is " "not enabled" ) if self . _fritz_password != '' : if 'WANIPConnection:1' not in self . _fc . services . keys ( ) : self . _fc = None raise IOError ( "fritzcollectd: Allow access for applications " "is not enabled" ) try : self . _fc . call_action ( 'WANIPConnection:1' , 'GetStatusInfo' ) except fritzconnection . AuthorizationError : self . _fc = None raise IOError ( "fritzcollectd: Incorrect password or " "'FRITZ!Box Settings' rights for user disabled" ) else : collectd . info ( "fritzcollectd: No password configured, " "some values cannot be queried" ) self . _filter_service_actions ( self . SERVICE_ACTIONS , self . _fc . actionnames )
Initialize the connection to the FRITZ!Box
Initialize the connection to the FRITZ!Box
""" Initialize the connection to the FRITZ!Box """ # If the 'Allow access for applications' option is disabled, # the connection behaves as if it was created without password.
self