Esempio n. 1
0
  def _Check(cls, username, logs_query):
    """Checks that a user has the specified logs access.

    Args:
      username: The user whose logs access we're checking.
      logs_query: a string; see the comments for TextQuery in
        //logs/accesstools:report.py for the syntax.

    Returns:
      True or False, depending whether the user's permissions match the query.
    """

    logging.debug('Checking for logs access "%s".', logs_query)

    command = "%s --query '%s' '%s'" % (cls.LOGS_REPORT, username, logs_query)
    (status, report_result) = _GET_STATUS_OUTPUT(command)
    report_result = report_result.strip()

    # The output should be 'True' or 'False'.  Convert it to bool.
    if status == 0 and report_result == 'True':
      return True
    if status == 0 and report_result == 'False':
      return False

    logging.warning('Error running %s, got: %s', command, report_result)
    return False
 def PostButtonAction(self):
     xpath_action_done_ok_button = (
         "//div[contains(.,'This action is done successfully.')]/../div" "/button[contains(.,'OK')]"
     )
     WebDriverWait(self.driver, 120).until(EC.presence_of_element_located((By.XPATH, xpath_action_done_ok_button)))
     try:
         ok_button = self.driver.find_element_by_xpath(xpath_action_done_ok_button)
         (ActionChains(self.driver).move_to_element(ok_button).click(ok_button).perform())
     except WebDriverException as e:
         logging.warning("Button function is failing to start")
         logging.warning(e)
 def PostUpdateButtonAction(self, *args):
     action_name = args[0]
     if action_name is "DELETE":
         xpath_delete_button = "//div[contains(.,'Service:')]/../div/button[contains(.," "'Delete/Reset')]"
         delete_button = self.driver.find_element_by_xpath(xpath_delete_button)
         (ActionChains(self.driver).move_to_element(delete_button).click(delete_button).perform())
         self.PostButtonAction()
     elif action_name is "UPDATE":
         service_plan = args[1]
         self.ServicePlanOptionChoose(service_plan)
         xpath_update_button = "//div[contains(.,'Service:')]/../div/button[contains(.,'Update')]"
         try:
             update_button = self.driver.find_element_by_xpath(xpath_update_button)
         except WebDriverException as e:
             logging.warning(
                 "Update function can't start due to no provision on " "port, please check the configuration."
             )
             logging.warning(e)
         (ActionChains(self.driver).move_to_element(update_button).click(update_button).perform())
         self.PostButtonAction()
     else:
         xpath_cancel_button = "//div[contains(.,'Service:')]/../div/button[contains(.,'Cancel')]"
         cancel_button = self.driver.find_element_by_xpath(xpath_cancel_button)
         ActionChains(self.driver).move_to_element(cancel_button)