original_docstring:  Ensures the information from the Tomato router is up to date.
              Returns boolean if scanning successful. 
docstring: Ensures the information from the Tomato router is up to date.
  Returns boolean if scanning successful.
docstring_tokens: Ensures the information from the Tomato router is up to date . Returns boolean if scanning successful .
code: def _update_tomato_info(self):
          """ Ensures the information from the Tomato router is up to date.
              Returns boolean if scanning successful. """
  
          self.lock.acquire()
  
          # if date_updated is None or the date is too old we scan for new data
          if not self.date_updated or \
             datetime.now() - self.date_updated > MIN_TIME_BETWEEN_SCANS:
  
              self.logger.info("Tomato:Scanning")
  
              try:
                  response = requests.Session().send(self.req, timeout=3)
  
                  # Calling and parsing the Tomato api here. We only need the
                  # wldev and dhcpd_lease values. For API description see:
                  # http://paulusschoutsen.nl/
                  #   blog/2013/10/tomato-api-documentation/
                  if response.status_code == 200:
  
                      for param, value in \
                              self.parse_api_pattern.findall(response.text):
  
                          if param == 'wldev' or param == 'dhcpd_lease':
                              self.last_results[param] = \
                                  json.loads(value.replace("'", '"'))
  
                      self.date_updated = datetime.now()
  
                      return True
  
                  elif response.status_code == 401:
                      # Authentication error
                      self.logger.exception((
                          "Tomato:Failed to authenticate, "
                          "please check your username and password"))
  
                      return False
  
              except requests.exceptions.ConnectionError:
                  # We get this if we could not connect to the router or
                  # an invalid http_id was supplied
                  self.logger.exception((
                      "Tomato:Failed to connect to the router"
                      " or invalid http_id supplied"))
  
                  return False
  
              except requests.exceptions.Timeout:
                  # We get this if we could not connect to the router or
                  # an invalid http_id was supplied
                  self.logger.exception(
                      "Tomato:Connection to the router timed out")
  
                  return False
  
              except ValueError:
                  # If json decoder could not parse the response
                  self.logger.exception(
                      "Tomato:Failed to parse response from router")
  
                  return False
  
              finally:
                  self.lock.release()
  
          else:
              # We acquired the lock before the IF check,
              # release it before we return True
              self.lock.release()
  
              return True
code_tokens: def _update_tomato_info ( self ) : self . lock . acquire ( ) if not self . date_updated or datetime . now ( ) - self . date_updated > MIN_TIME_BETWEEN_SCANS : self . logger . info ( "Tomato:Scanning" ) try : response = requests . Session ( ) . send ( self . req , timeout = 3 ) if response . status_code == 200 : for param , value in self . parse_api_pattern . findall ( response . text ) : if param == 'wldev' or param == 'dhcpd_lease' : self . last_results [ param ] = json . loads ( value . replace ( "'" , '"' ) ) self . date_updated = datetime . now ( ) return True elif response . status_code == 401 : self . logger . exception ( ( "Tomato:Failed to authenticate, " "please check your username and password" ) ) return False except requests . exceptions . ConnectionError : self . logger . exception ( ( "Tomato:Failed to connect to the router" " or invalid http_id supplied" ) ) return False except requests . exceptions . Timeout : self . logger . exception ( "Tomato:Connection to the router timed out" ) return False except ValueError : self . logger . exception ( "Tomato:Failed to parse response from router" ) return False finally : self . lock . release ( ) else : self . lock . release ( ) return True
short_docstring: Ensures the information from the Tomato router is up to date.
short_docstring_tokens: Ensures the information from the Tomato router is up to date .
comment: """ Ensures the information from the Tomato router is up to date.
              Returns boolean if scanning successful. """$SEP$# if date_updated is None or the date is too old we scan for new data$SEP$# Calling and parsing the Tomato api here. We only need the$SEP$# wldev and dhcpd_lease values. For API description see:$SEP$# http://paulusschoutsen.nl/$SEP$#   blog/2013/10/tomato-api-documentation/$SEP$# Authentication error$SEP$# We get this if we could not connect to the router or$SEP$# an invalid http_id was supplied$SEP$# We get this if we could not connect to the router or$SEP$# an invalid http_id was supplied$SEP$# If json decoder could not parse the response$SEP$# We acquired the lock before the IF check,$SEP$# release it before we return True