Exemplo n.º 1
0
 def get_token_from_database(cls, team_id, user_id=None):
     database = Database()
     database.initialize()
     if user_id is not None:
         credentials = database.find_one("slack_tokens",
                                         query=({
                                             "team_id": team_id,
                                             "user_id": user_id
                                         }))
     else:
         credentials = database.find_one("slack_tokens",
                                         query=({
                                             "team_id": team_id
                                         }))
     return cls(**credentials)
Exemplo n.º 2
0
 def remove_fact(fact_text):
     database = Database()
     database.initialize()
     if database.find_one("facts", {"fact_text": fact_text}) is None:
         raise LookupError('Fact was not found in the database')
     else:
         database.remove("facts", {"fact_text": fact_text})
         print("Fact was successfully removed")
Exemplo n.º 3
0
 def find_entry(cls, text):
     database = Database()
     database.initialize()
     entry = database.find_one("samples", {"text": text})
     if entry is not None:
         return cls(**entry)
     else:
         return None
Exemplo n.º 4
0
 def remove_distributor(email_address=None, slack_ids=None):
     database = Database()
     database.initialize()
     if database.find_one("distributors", {"email_address": email_address,
                                           "slack_ids": slack_ids}):
         database.remove("distributors", {"email_address": email_address,
                                          "slack_ids": slack_ids})
         return True
Exemplo n.º 5
0
 def get_release_notes(version):
     database = Database()
     database.initialize()
     jira_settings = database.find_one("jira_settings", query={})
     auth_jira = JIRA(basic_auth=(jira_settings['email'], jira_settings['password']),
                      server=jira_settings['server'])
     release_notes = "{} has been deployed to production! Release notes:\n".format(version)
     issues = auth_jira.search_issues("""fixVersion in ("{}")""".format(version))
     for issue in issues:
         release_notes = release_notes + str(issue) + " - " + auth_jira.issue(issue).fields.summary + "\n"
     return release_notes
Exemplo n.º 6
0
 def get_email_credentials(cls, returnless=False):
     database = Database()
     database.initialize()
     emailer_credential_object = database.find_one("emailer_credentials",
                                                   ({}))
     if emailer_credential_object is None:
         email_address = input(
             "Please enter the gmail account address you would like to use to send emails:"
         )
         email_password = input("Please enter your gmail password:"******"Login failed. Please enter your GMAIL address:")
             email_password = input("Please enter your GMAIL password:"******"emailer_credentials",
                         ({
                             "email_address": email_address,
                             "email_password": email_password
                         }))
     else:
         email_address = emailer_credential_object['email_address']
         email_password = emailer_credential_object['email_password']
     if returnless is False:
         return email_address, email_password
Exemplo n.º 7
0
 def get_app_credentials():
     database = Database()
     database.initialize()
     result = database.find_one("slack_credentials", query=({}))
     return result
Exemplo n.º 8
0
 def get_entry_by_ts(cls, ts):
     database = Database()
     database.initialize()
     result = database.find_one("message_log", {"trigger_ts": ts})
     if result is not None:
         return cls(**result)
Exemplo n.º 9
0
 def get_one_user(cls, query=({})):
     database = Database()
     database.initialize()
     user = database.find_one("users", query)
     return cls(**user)
Exemplo n.º 10
0
 def get_token_from_database():
     database = Database()
     database.initialize()
     result = database.find_one("giphy_tokens", query=({}))
     return result['giphy_token']
Exemplo n.º 11
0
 def get_keyword_from_database():
     database = Database()
     database.initialize()
     result = database.find_one("giphy_keyword", query=({}))
     return result['giphy_keyword']