def __init__(self): """Initializing Variable """ self.db = mongodb self.distributionSync = DistributionSync.DistributionSync(self.db) self.toolDB = Tool.Tool(self.db) self.versionsDB = Versions.Versions(self.db) self.mailer = Mailer.Mailer() self.static_folder_path = current_path self.current_import_path = distribution_center_import_full_path self.current_import_small_path = distribution_center_import_path if self.current_import_path in [None, ""]: raise ValueError("Import path was not provided") if not os.path.exists(self.current_import_path): os.makedirs(self.current_import_path) if not os.access(os.path.dirname(self.current_import_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_import_path) self.current_export_path = distribution_center_export_full_path if self.current_export_path in [None, ""]: raise ValueError("Export path was not provided") if not os.path.exists(self.current_export_path): os.makedirs(self.current_export_path) if not os.access(os.path.dirname(self.current_export_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_export_path) self.configdb = Config.Config(self.db) self.logo_path = logo_path self.full_logo_path = logo_full_path self.media_files_path = media_path self.full_media_files_path = media_full_path self.config_id = 13 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService()
def __init__(self, db): """Initializing Variable """ self.configdb = Config.Config(db) self.distributionMachinetDB = DistributionMachine.DistributionMachine( db) self.syncService = SyncServices.SyncServices() self.machineDB = Machine.Machine(db) self.mailer = Mailer.Mailer() self.current_path = distribution_center_export_full_path self.systemDetailsDb = SystemDetails.SystemDetails(db) if not os.path.exists(self.current_path): os.makedirs(self.current_path) if not os.access(os.path.dirname(self.current_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_path) systemDetail = self.systemDetailsDb.get_system_details_single() if not systemDetail: raise Exception("systemDeatils not found") if not systemDetail.get("hostname"): raise Exception("hostname not found in systemDeatils") self.remote_trigger_api_path = "/clonerequest/distribution/pull/" + \ systemDetail.get("hostname") self.config_id = 12 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService() self.remote_authentication_service = RemoteAuthenticationService.RemoteAuthenticationService( )
def __init__(self): self.db = mongodb self.current_import_path = import_full_path if not os.path.exists(self.current_import_path): os.makedirs(self.current_import_path) if not os.access(self.current_import_path, os.W_OK): raise ValueError( "The directory does not have write access :" + self.current_import_path) self.configdb = Config.Config(self.db) self.syncdb = Sync.Sync(self.db) self.syncRequestdb = SyncRequest.SyncRequest(self.db) self.mailer = Mailer.Mailer() self.syncService = SyncServices.SyncServices() self.systemDetailsDb = SystemDetails.SystemDetails(self.db) self.systemDetail = self.systemDetailsDb.get_system_details_single() self.remoteAuthenticationService = RemoteAuthenticationService.RemoteAuthenticationService() if not self.systemDetail: raise Exception("systemDeatils not found") if not self.systemDetail.get("hostname"): raise Exception("hostname not found in systemDeatils") self.host_name = self.systemDetail.get("hostname") self.post_url = "/sync/pull/export" self.config_id = 10 self.count_of_files = 2 # Minimum Threads is 2 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService()
def __init__(self): self.db = mongodb self.current_import_path = import_full_path if self.current_import_path in [None, ""]: raise ValueError("Import path was not provided") if not os.path.exists(self.current_import_path): os.makedirs(self.current_import_path) if not os.access(os.path.dirname(self.current_import_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_import_path) self.current_export_path = export_full_path if self.current_export_path in [None, ""]: raise ValueError("Export path was not provided") if not os.path.exists(self.current_export_path): os.makedirs(self.current_export_path) if not os.access(os.path.dirname(self.current_export_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_export_path) self.configdb = Config.Config(self.db) self.versionsDB = Versions.Versions(self.db) self.toolDB = Tool.Tool(self.db) self.deploymentFieldsDB = DeploymentFields.DeploymentFields(self.db) self.machineDB = Machine.Machine(self.db) self.syncDb = Sync.Sync(self.db) self.mailer = Mailer.Mailer() self.syncRequestDb = SyncRequest.SyncRequest(self.db) self.buildsDB = Build.Build() self.documentsDB = Documents.Documents(self.db) self.toolDB = Tool.Tool(self.db) self.deploymentunitDB = DeploymentUnit.DeploymentUnit() self.deploymentunitsetDB = DeploymentUnitSet.DeploymentUnitSet() self.mediaFilesDB = MediaFiles.MediaFiles(self.db) self.tagsDB = Tags.Tags() self.preRequisitesDB = PreRequisites.PreRequisites(self.db) self.logo_path = logo_path self.full_logo_path = logo_full_path self.media_files_path = media_path self.full_media_files_path = media_full_path self.systemDetailsDb = SystemDetails.SystemDetails(self.db) self.systemDetail = self.systemDetailsDb.get_system_details_single() self.statedb = State.State(self.db) if not self.systemDetail: raise Exception("systemDeatils not found") self.config_id = 9 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService() self.flexAttrDB = FlexibleAttributes.FlexibleAttributes()
def job_function(self): """ # Actual Implementation ###LOGIC### # Search for email's in 'pending' status # Try to send those mails # if successful then mar them as successful else +1 retry count # mark failed if retry count>3""" self.load_configuration() print ' Checking for pending emails..' cursor = self.emaildb.GetPendingEmail() print ' No of Pending Emails :' + str(cursor.count()) for document in cursor: Mailer.Mailer().handle_pending_notification(str(document['_id'])) print ' Waiting for ' + str(self.interinterval) \ + ' secs to send next email.' # Server is not able to send email's continuously time.sleep(self.interinterval) print ' Sleeping....'
def __init__(self, db, key): self.RSAKEY = RSA.generate(1024) self.SECRET_KEY = self.RSAKEY.exportKey('PEM') self.SECRET_PUBLIC_KEY = self.RSAKEY.publickey().exportKey('PEM') self.ENCRYPTION_METHOD = 'RS512' # WE WILL VERIFY EXPIRATION BY OURSELVES self.JWT_OPTIONS = {'verify_exp': False, } self.userdb = Users.Users(db) self.auditdb = Auditing.Auditing() self.roledb = Role.Role(db) self.passHelper = PasswordHelper.PasswordHelper(key) self.permissiondb = Permissions.Permissions(db) self.permissiongroupdb = PermissionGroup.PermissionGroup(db) self.accountDB = Accounts.Accounts() self.configdb = Config.Config(db) self.systemDetailsDB = SystemDetails.SystemDetails(db) self.configdbData = self.configdb.getConfigByName("AuthService") # 6 is for AuthRequestService configuration self.auditing_config = self.configdb.getConfigByName("AuditingServices") # 6 is for AuthRequestService configuration self.mailer = Mailer.Mailer() self.validTokens = {} self.teamService = TeamService.TeamService() self.collection = db.SystemDetails # Set Collection as Permissions self.teamsdb = Teams.Teams(db) if self.configdbData is not None: if self.configdbData.get("expiration") is not None: self.expiration = int(self.configdbData.get("expiration")) else: raise Exception( "Config AuthService does not have expiration set") if self.configdbData.get("email_domain") is not None: self.email_domain = str(self.configdbData.get("email_domain")) else: raise Exception( "Config AuthService does not have email_domain set") self.allow_multi_user_session = self.configdbData.get("allow_multi_user_session","false") else: raise Exception("Config was not found for Authorization services") # ADD DEAMON THREAD TO REMOVE IN VALID TOKENS AUTOMATICALLY pool = ThreadPoolExecutor(2,__name__+".__init__") pool.submit(self.removeInvalidTokens) pool.submit(self.check_if_user_logged_in_from_last_6_months)
from settings import mongodb, proposed_tool_git_full_path,\ proposed_tool_jenkins_full_path,logo_path, logo_full_path, current_path from Services import Mailer, HelperServices from modules import ToolAPI #DB proposedToolsDB = ProposedTools.ProposedTools() toolDB = Tool.Tool(mongodb) configdb = Config.Config(mongodb) sysdetailsDB = SystemDetails.SystemDetails(mongodb) system_details = sysdetailsDB.get_system_details_single() tooldb = Tool.Tool(mongodb) versionsDB = Versions.Versions(mongodb) RepositoryDB = Repository.Repository() #SERVICES mailer = Mailer.Mailer() def email_tool_proposed(pt_details): mailer.send_html_notification( pt_details.get("support_details"), None, None, 17, { "name": pt_details.get("name"), "machine_host": system_details.get("hostname") }) def email_approval_req(pt_details): proposed_tool_support_email = configdb.getConfigByName( "ProposedToolService").get("support_details") mailer.send_html_notification( proposed_tool_support_email, None, pt_details.get("support_details"),