def Populate(self, dr): if dr is not None: self.ID = dr["account_id"] self.Name = dr["account_name"] self.AccountNumber = ("" if not dr["account_number"] else dr["account_number"]) self.LoginID = ("" if not dr["login_id"] else dr["login_id"]) self.LoginPassword = ("" if not dr["login_password"] else catocommon.cato_decrypt(dr["login_password"])) self.IsDefault = (True if dr["is_default"] == 1 else False) c = Cloud() c.FromID(dr["default_cloud_id"]) if not c: raise Exception("Error building Cloud Account object: Unable to get Default Cloud.") return self.DefaultCloud = c # find a provider object cp = CloudProviders() if not cp: raise Exception("Error building Cloud Account object: Unable to get CloudProviders.") return # check the CloudProvider class first ... it *should be there unless something is wrong. if dr["provider"] in cp: self.Provider = cp[dr["provider"]] else: raise Exception("Provider [%s] does not exist in the cloud_providers session xml." % dr["provider"]) else: raise Exception("Unable to build Cloud Account object. Either no Cloud Accounts are defined, or no Account could be found.")
def FromID(self, sAccountID): try: if not sAccountID: raise Exception( "Error building Cloud Account object: Cloud Account ID is required." ) sSQL = "select account_name, account_number, provider, login_id, login_password, is_default" \ " from cloud_account" \ " where account_id = '" + sAccountID + "'" db = catocommon.new_conn() dr = db.select_row_dict(sSQL) if dr is not None: self.ID = sAccountID self.Name = dr["account_name"] self.AccountNumber = ("" if not dr["account_number"] else dr["account_number"]) self.LoginID = ("" if not dr["login_id"] else dr["login_id"]) self.LoginPassword = ("" if not dr["login_password"] else catocommon.cato_decrypt( dr["login_password"])) self.IsDefault = (True if dr["is_default"] == 1 else False) # find a provider object cp = providers.CloudProviders() if not cp: raise Exception( "Error building Cloud Account object: Unable to get CloudProviders." ) return #check the CloudProvider class first ... it *should be there unless something is wrong. if cp.has_key(dr["provider"]): self.Provider = cp[dr["provider"]] else: raise Exception( "Provider [" + dr["provider"] + "] does not exist in the cloud_providers session xml.") else: raise Exception( "Unable to build Cloud Account object. Either no Cloud Accounts are defined, or no Account with ID [" + sAccountID + "] could be found.") except Exception, ex: raise Exception(ex)
def __init__(self): s = settings.get_application_section("messenger") self.Enabled = s.get("Enabled", self.Enabled) self.PollLoop = s.get("PollLoop", self.PollLoop) self.RetryDelay = s.get("RetryDelay", self.RetryDelay) self.RetryMaxAttempts = s.get("RetryMaxAttempts", self.RetryMaxAttempts) self.SMTPServerAddress = s.get("SMTPServerAddress", self.SMTPServerAddress) self.SMTPUserAccount = s.get("SMTPUserAccount", self.SMTPUserAccount) self.SMTPServerPort = s.get("SMTPServerPort", self.SMTPServerPort) self.SMTPConnectionTimeout = s.get("SMTPConnectionTimeout", self.SMTPConnectionTimeout) self.SMTPLegacySSL = s.get("SMTPLegacySSL", self.SMTPLegacySSL) self.FromEmail = s.get("FromEmail", self.FromEmail) self.FromName = s.get("FromName", self.FromName) self.AdminEmail = s.get("AdminEmail", self.AdminEmail) if s.get("SMTPUserPassword"): self.SMTPUserPassword = catocommon.cato_decrypt(s["SMTPUserPassword"])
def __init__(self): try: sSQL = "select mode_off_on, loop_delay_sec, retry_delay_min, retry_max_attempts," \ " smtp_server_addr, smtp_server_user, smtp_server_password, smtp_server_port, from_email, from_name, admin_email" \ " from messenger_settings" \ " where id = 1" db = catocommon.new_conn() row = db.select_row_dict(sSQL) if row: self.Enabled = catocommon.is_true(row["mode_off_on"]) self.PollLoop = row["loop_delay_sec"] self.RetryDelay = row["retry_delay_min"] self.RetryMaxAttempts = row["retry_max_attempts"] self.SMTPServerAddress = row["smtp_server_addr"] self.SMTPUserAccount = row["smtp_server_user"] self.SMTPUserPassword = catocommon.cato_decrypt(row["smtp_server_password"]) self.SMTPServerPort = row["smtp_server_port"] self.FromEmail = row["from_email"] self.FromName = row["from_name"] self.AdminEmail = row["admin_email"] except Exception, ex: raise Exception(ex)
def FromID(self, sAccountID): try: if not sAccountID: raise Exception("Error building Cloud Account object: Cloud Account ID is required."); sSQL = "select account_name, account_number, provider, login_id, login_password, is_default" \ " from cloud_account" \ " where account_id = '" + sAccountID + "'" db = catocommon.new_conn() dr = db.select_row_dict(sSQL) if dr is not None: self.ID = sAccountID self.Name = dr["account_name"] self.AccountNumber = ("" if not dr["account_number"] else dr["account_number"]) self.LoginID = ("" if not dr["login_id"] else dr["login_id"]) self.LoginPassword = ("" if not dr["login_password"] else catocommon.cato_decrypt(dr["login_password"])) self.IsDefault = (True if dr["is_default"] == 1 else False) # find a provider object cp = providers.CloudProviders() if not cp: raise Exception("Error building Cloud Account object: Unable to get CloudProviders.") return #check the CloudProvider class first ... it *should be there unless something is wrong. if cp.has_key(dr["provider"]): self.Provider = cp[dr["provider"]] else: raise Exception("Provider [" + dr["provider"] + "] does not exist in the cloud_providers session xml.") else: raise Exception("Unable to build Cloud Account object. Either no Cloud Accounts are defined, or no Account with ID [" + sAccountID + "] could be found.") except Exception, ex: raise Exception(ex)
def CatoDecrypt(s): return catocommon.cato_decrypt(s)