def get_project_id_(self, tracker, bug): return SelectorMapping(tracker).match( bug.id, bug.project_name, bug.component_name, bug.version, )
def __call__(self, *args, **kwargs): config = ApplicationConfig.get_current_config(allow_empty=True) if config is None: WARN(u'Application config not found, emails cannot be checked') return trackers = dict( (tracker.mailer, tracker) for tracker in Tracker.query.filter( Tracker.mailer != None).filter(Tracker.mailer != '')) if not len(trackers): WARN( u'No trackers have mailers configured, email will not be checked' ) return username = config.google_user_email.encode('utf-8') password = config.google_user_password.encode('utf-8') # TODO logins_mappings = dict( (tracker.id, TrackerCredentials.get_logins_mapping(tracker)) for tracker in trackers.itervalues()) selector_mappings = dict((tracker.id, SelectorMapping(tracker)) for tracker in trackers.itervalues()) # find all projects connected to the tracker projects = dict( (project.id, project) for project in Project.query.all()) # all pre-conditions should be checked by now # start fetching fetcher = MailFetcher( username, password, ) # ok, we have all mails, lets create timeentries from them extractor = TimeEntryMailExtractor( trackers, logins_mappings, projects, selector_mappings, ) for msg in fetcher: timeentry = extractor.get(msg) if timeentry: DBSession.add(timeentry) transaction.commit()
def _run(self): config = ApplicationConfig.get_current_config(allow_empty=True) if config is None: WARN(u'Application config not found, emails cannot be checked') return self.mark_not_busy() trackers = dict( (tracker.mailer, tracker) for tracker in Tracker.query.filter(Tracker.mailer != None).filter(Tracker.mailer != '') ) if not len(trackers): WARN(u'No trackers have mailers configured, email will not be checked') return self.mark_not_busy() username = config.google_user_email.encode('utf-8') password = config.google_user_password.encode('utf-8') # TODO logins_mappings = dict( (tracker.id, TrackerCredentials.get_logins_mapping(tracker)) for tracker in trackers.itervalues() ) selector_mappings = dict( (tracker.id, SelectorMapping(tracker)) for tracker in trackers.itervalues() ) # find all projects connected to the tracker projects = dict( (project.id, project) for project in Project.query.all() ) # all pre-conditions should be checked by now # start fetching f = CustomClientFactory(username, password, self.mark_not_busy, trackers, logins_mappings, projects, selector_mappings) f.protocol = MailerPOP3Client reactor.connectSSL(self.POP3_SERVER, self.POP3_PORT, f, self.context_factory)
def resolve(self, bug): bug.owner = self.resolve_user(bug.owner) bug.reporter = self.resolve_user(bug.reporter) bug.project_id = SelectorMapping(self.tracker).match( bug.id, bug.project_name, bug.component_name, bug.version, )