当前位置: 首页>>代码示例>>Python>>正文


Python utils.sendEmail函数代码示例

本文整理汇总了Python中utils.sendEmail函数的典型用法代码示例。如果您正苦于以下问题:Python sendEmail函数的具体用法?Python sendEmail怎么用?Python sendEmail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sendEmail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: changeStatus

def changeStatus(id_report,status):

    if status not in [1,2,3,4]:
        return make_response(jsonify( { 'error': 'Unknown status' } ), 400)

    rm = ReportModel()
    um = UserModel()

    # get the current report
    report_prev = rm.getReport(id_report)

    #get user of report
    user = um.getUser(idUser=report_prev["id_user"])
    # get the previous report again with the current language
    report_prev = rm.getReport(id_report,user["language"])
    # change the status
    rm.changeStatus(id_report,status)
    report = rm.getReport(id_report,user["language"])
    #send the email
    body = tr("Report status changed email",user["language"])
    body = body % ( report_prev["status_str"].decode("utf-8"), report["status_str"].decode("utf-8"),app.config["cdnUrl"] + "#?c=Report/detail/"+str(id_report))
    utils.sendEmail([report["user_email"]],tr("Report status change subject",user["language"]), body)

    if report_prev["id_report_status"] == 1 and (status==2 or status==4):
        # send email to manager mpa
        mm = MPASModel()
        for lang in app.config["languages"]:
            emails = map(lambda x: x["email"],mm.getMPAManagersEmailLanguage(report["id_mpa"] ,lang))

            if len(emails)>0:
                body = tr("New report added MPA",lang)
                body = body % ( report["mpa"], app.config["cdnUrl"] + "#?c=Report/detail/"+str(id_report))
                utils.sendEmail(emails,tr("New report added in %s [MPA]",lang) % report["mpa"], body)

    return jsonify( {"result" : "done" })
开发者ID:GeographicaGS,项目名称:IUCN-reporting-www,代码行数:35,代码来源:report.py

示例2: _warningEmail

def _warningEmail(subject):
    if libs.ec2_utils.is_ec2():
        try:
            email = {}
            email['from'] = 'Stamped <[email protected]>'
            email['to'] = '[email protected]'
            email['subject'] = subject
            email['body'] = logs.getHtmlFormattedLog()
            utils.sendEmail(email, format='html')
        except Exception as e:
            logs.warning('UNABLE TO SEND EMAIL: %s' % (e,))
开发者ID:Stamped,项目名称:Stamped,代码行数:11,代码来源:Worker.py

示例3: sendFailLogEmail

    def sendFailLogEmail(self):
        if len(self.__fails) == 0:
            return

        stack_info = get_stack()
        stack_name = 'localhost'
        node_name = 'localhost'
        if stack_info is not None:
            stack_name = stack_info.instance.stack
            node_name = stack_info.instance.name

        output = '<html>'
        output += "<h3>RateLimiter Fail Limit reached on %s</h3>" % stack_name
        output += "<p>On stack '%s' instance '%s'.</p>" % (stack_name, node_name)
        output += "<p><i>There were %s failed requests to service '%s' within the last %s seconds</p></i>" %  \
                  (self.fail_limit, self.__service_name, self.fail_period)
        back_online = time.strftime('%m/%d/%Y %H:%M:%S', time.localtime(self.blackout_start + self.blackout_wait)) # Timestamp
        output += "<p>Waiting for %s seconds.  Service will be active again at: %s</p>" % (self.blackout_wait, back_online)

        output += '<h3>Fail Log</h3>'

        output += '<table border=1 cellpadding=5>'
        output += '<tr>'
        labels = ['Timestamp', 'Url', 'Body', 'Headers', 'Code', 'Content']
        for label in labels:
            output += '<td style="font-weight:bold">%s</td>' % label
        output += '</tr>'

        for fail in self.__fails:
            output += '<tr>'
            output += '<td valign=top>%s</td>' % time.strftime('%m/%d/%Y %H:%M:%S', time.localtime(fail.timestamp)) # Timestamp
            output += '<td valign=top>%s</td>' % fail.url
            output += '<td valign=top>%s</td>' % fail.body
            output += '<td valign=top>%s</td>' % fail.headers
            output += '<td valign=top>%s</td>' % fail.status_code
            output += '<td valign=top>%s</td>' % escape(fail.content)
            output += '</tr>'

        output += '</table>'
        output += '</html>'

        try:
            email = {}
            email['from'] = 'Stamped <[email protected]>'
            email['to'] = '[email protected]'
            email['subject'] = "%s RateLimiter '%s' fail limit reached" % (stack_name, self.__service_name)
            email['body'] = output
            utils.sendEmail(email, format='html')
        except Exception as e:
            print('UNABLE TO SEND EMAIL: %s' % e)

        return output
开发者ID:Stamped,项目名称:Stamped,代码行数:52,代码来源:RateLimiter2.py

示例4: handleStampedExceptions

def handleStampedExceptions(e, handlers=None):
    if isinstance(e, StampedHTTPError):
        exceptions =  [(StampedHTTPError, e.code, e.kind, e.msg)]
    elif handlers is not None:
        exceptions = handlers + defaultExceptions
    else:
        exceptions = defaultExceptions

    for (exception, code, kind, msg) in exceptions:
        if isinstance(e, exception):
            logs.warning("%s Error (%s): %s" % (code, kind, msg))
            logs.warning(utils.getFormattedException())
            logs.error(code)

            kind = kind
            if kind is None:
                kind = 'stamped_error'

            message = msg
            if message is None and e.msg is not None:
                message = e.msg

            error = {}
            error['error'] = kind
            if message is not None:
                error['message'] = unicode(message)

            return transformOutput(error, status=code)
    else:
        error = {
            'error' :   'stamped_error',
            'message' : "An error occurred. Please try again later.",
        }
        logs.warning("500 Error: %s" % e)
        logs.warning(utils.getFormattedException())
        logs.error(500)

        # Email dev if a 500 occurs
        if libs.ec2_utils.is_ec2():
            try:
                email = {}
                email['from'] = 'Stamped <[email protected]>'
                email['to'] = '[email protected]'
                email['subject'] = '%s - 500 Error - %s' % (stampedAPI.node_name, datetime.utcnow().isoformat())
                email['body'] = logs.getHtmlFormattedLog()
                utils.sendEmail(email, format='html')
            except Exception as e:
                logs.warning('UNABLE TO SEND EMAIL: %s')

        return transformOutput(error, status=500)
开发者ID:Stamped,项目名称:Stamped,代码行数:50,代码来源:helpers.py

示例5: stop_recording

 def stop_recording(e, config):
     """Process the process of recording being stopped"""
     log = logging.getLogger('Conference')
     
     owner = Session.query(ModeratorPin).get(getUnquotedHeader(e, 'Conference-Name'))
     if owner is None:
         log.warning('Error because we could not get owner.')
         Session.remove()
         return
     
     confObj = Session.query(Conference).get(getUnquotedHeader(e, 'Conference-Unique-ID'))
     if confObj is None:
         log.info('Creating a new conference for conference id: %s' % getUnquotedHeader(e, 'Conference-Unique-ID'))
         confObj = Conference(getUnquotedHeader(e, 'Conference-Unique-ID'), parseEventDate(e), unicode(getUnquotedHeader(e, 'Conference-Name')), unicode(getUnquotedHeader(e, 'Conference-Profile-Name')))
         owner.conferences.append(confObj)
         Session.add(confObj)
         Session.flush()
         actionObj = ConferenceAction(unicode(getUnquotedHeader(e, 'Action')), 
                                     unicode(getUnquotedHeader(e, 'Caller-Caller-ID-Name')),
                                     unicode(getUnquotedHeader(e, 'Caller-Caller-ID-Number')),
                                     unicode(getUnquotedHeader(e, 'Conference-Size')),
                                     unicode(getUnquotedHeader(e, 'Member-Type')),
                                     parseEventDate(e),
                                     confObj.id)
         confObj.actions.append(actionObj)
         Session.add(actionObj)
         log.debug('Conference %s has been created. Assigning the pointer.' % getUnquotedHeader(e, 'Conference-Name'))
         
     confObj.recording = os.path.join(config.get('mp3', 'store_to'), getUnquotedHeader(e, 'Path').split('/').pop()[:-3] + 'mp3')
     host = unicode(getUnquotedHeader(e, 'FreeSWITCH-IPv4'))
         
     try:
         try:
             t = Thread(target=postRecordingThread, args=(config, getUnquotedHeader(e, 'Path'), confObj, host, owner))
             t.start()
         except:
             log.exception('Could not run thread and commit to database!')
             Session.remove()
             return
     finally:
         try:
             sendEmail(config, getUnquotedHeader(e, 'Path'), confObj, owner)
             Session.commit()
             Session.remove()
         except Exception, e:
             log.exception('Could not commit to database!')
             Session.rollback()
             Session.remove()
             return
开发者ID:mehulsbhatt,项目名称:conference,代码行数:49,代码来源:conference.py

示例6: sendEmailNow

def sendEmailNow (**ka):  
    ok = u.sendEmail(**ka)        
    if ok and u.config('recordEmails'):
        try:
            m.SentEmail.create (**ka)
        except: # (apiproxy_errors.OverQuotaError, BadValueError):
            logging.exception("Error saving SentEmail in datastore")
开发者ID:chdb,项目名称:DhammaMap,代码行数:7,代码来源:basehandler.py

示例7: recognizeAndReport

def recognizeAndReport(recognizer, grayImage, rects, maxDistance,
                       noun='human'):
    for x, y, w, h in rects:
        crop = cv2.equalizeHist(grayImage[y:y+h, x:x+w])
        labelAsInt, distance = recognizer.predict(crop)
        labelAsStr = utils.intToFourChars(labelAsInt)
        #print noun, labelAsStr, distance
        if distance <= maxDistance:
            fromAddr = '[email protected]' # TODO: Replace
            toAddrList = ['[email protected]'] # TODO: Replace
            ccAddrList = []
            subject = 'Angora Blue'
            message = 'We have sighted the %s known as %s.' % \
                    (noun, labelAsStr)
            login = 'username' # TODO: Replace
            password = 'password' # TODO: Replace
            # TODO: Replace if not using Gmail.
            smtpServer='smtp.gmail.com:587'
            try:
                problems = utils.sendEmail(
                        fromAddr, toAddrList, ccAddrList, subject,
                        message, login, password, smtpServer)
                if problems:
                    print >> sys.stderr, 'Email problems:', problems
                else:
                    return True
            except socket.gaierror:
                print >> sys.stderr, 'Unable to reach email server'
    return False
开发者ID:Talamantez,项目名称:angora-blue,代码行数:29,代码来源:AngoraBlue.py

示例8: __addToBlacklistCount

 def __addToBlacklistCount(self, user_id):
     """
     Increments the blacklist counter for a given user, and returns a bool on whether the threshold is hit
     """
     count = self.__blacklist.setdefault(user_id, 0) + 1
     self.__blacklist[user_id] = count
     if (count >= self.__blacklistThreshold):
         text = "Netflix user_id: %s hit the blacklist threshold of %d 403/401 errors." % (user_id, self.__blacklistThreshold)
         logs.info(text)
         msg = {}
         msg['to'] = '[email protected]'
         msg['from'] = 'Stamped <[email protected]>'
         msg['subject'] = 'Netflix blacklist threshold reached'
         msg['body'] = text
         utils.sendEmail(msg)
         return True
     return False
开发者ID:Stamped,项目名称:Stamped,代码行数:17,代码来源:Netflix.py

示例9: sendFailLogEmail

    def sendFailLogEmail(self):
        if len(self.__fails) == 0:
            return

        output = '<html>'
        output += "<h3>RateLimiter RPC Server Failure on %s</h3>" % self.__stack_name
        output += "<p>On stack '%s' instance '%s'.</p>" % (self.__stack_name, self.__node_name)
        output += "<p><i>There were %s failed requests to the rpc server within the last %s seconds</i></p>" %\
                  (self.__fail_limit, self.__fail_period)
        back_online = time.strftime('%m/%d/%Y %H:%M:%S', time.localtime(self.__blackout_start + self.__blackout_wait)) # Timestamp
        output += "<p>Waiting for %s seconds.  Will use local Rate Limiter service until: %s</p>" % (self.__blackout_wait, back_online)

        output += '<h3>Fail Log</h3>'

        output += '<table border=1 cellpadding=5>'
        output += '<tr>'
        labels = ['Timestamp', 'Exception']
        for label in labels:
            output += '<td style="font-weight:bold">%s</td>' % label
        output += '</tr>'

        for fail in self.__fails:
            output += '<tr>'
            output += '<td valign=top>%s</td>' % time.strftime('%m/%d/%Y %H:%M:%S', time.localtime(fail.timestamp)) # Timestamp
            output += '<td valign=top>%s</td>' % fail.exception
            output += '</tr>'

        output += '</table>'

        output += '</html>'


        try:
            email = {}
            email['from'] = 'Stamped <[email protected]>'
            email['to'] = '[email protected]'
            email['subject'] = "%s RateLimiter RPC server failure" % self.__stack_name
            email['body'] = output
            utils.sendEmail(email, format='html')
        except Exception as e:
            print('UNABLE TO SEND EMAIL: %s' % e)

        return output
开发者ID:Stamped,项目名称:Stamped,代码行数:43,代码来源:Request.py

示例10: updatePassword

    def updatePassword(self, authUserId, password):
        
        account = self._accountDB.getAccount(authUserId)

        # Convert and store new password
        password = auth.convertPasswordForStorage(password)
        self._accountDB.updatePassword(authUserId, password)

        # Remove refresh / access tokens
        self._refreshTokenDB.removeRefreshTokensForUser(authUserId)
        self._accessTokenDB.removeAccessTokensForUser(authUserId)

        # If there is no email address associated with the account, we're done
        if account.email is None:
            return True

        # Send confirmation email
        msg = {}
        msg['to'] = account.email
        msg['from'] = 'Stamped <[email protected]>'
        msg['subject'] = 'Stamped: Your Password Has Been Reset'

        try:
            base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
            path = os.path.join(base, 'alerts', 'templates', 'email_password_reset.html.j2')
            template = open(path, 'r')
        except Exception:
            ### TODO: Add error logging?
            raise
        
        params = {
            'screen_name': account.screen_name, 
            'email_address': account.email,
        }
        msg['body'] = utils.parseTemplate(template, params)

        utils.sendEmail(msg, format='html')

        return True
开发者ID:Stamped,项目名称:Stamped,代码行数:39,代码来源:StampedAuth.py

示例11: completor

def completor(url, specific):
    use_mcm = True
    up = componentInfo(mcm=use_mcm, soft=['mcm'])
    if not up.check(): return
    use_mcm = up.status['mcm']
    if use_mcm:
        mcm = McMClient(dev=False)

    CI = campaignInfo()
    SI = siteInfo()
    UC = unifiedConfiguration()

    wfs = []
    wfs.extend( session.query(Workflow).filter(Workflow.status == 'away').all() )
    wfs.extend( session.query(Workflow).filter(Workflow.status.startswith('assistance')).all() )

    ## just take it in random order so that not always the same is seen
    random.shuffle( wfs )

    max_per_round = UC.get('max_per_round').get('completor',None)
    if max_per_round and not specific: wfs = wfs[:max_per_round]

    ## by workflow a list of fraction / timestamps
    completions = json.loads( open('%s/completions.json'%monitor_dir).read())
    
    good_fractions = {}
    timeout = {}
    for c in CI.campaigns:
        if 'force-complete' in CI.campaigns[c]:
            good_fractions[c] = CI.campaigns[c]['force-complete']
        if 'force-timeout' in CI.campaigns[c]:
            timeout[c] = CI.campaigns[c]['force-timeout']

    long_lasting = {}

    overrides = getForceCompletes()
    if use_mcm:    
        ## add all workflow that mcm wants to get force completed
        mcm_force = mcm.get('/restapi/requests/forcecomplete')
        ## assuming this will be a list of actual prepids
        overrides['mcm'] = mcm_force

    print "can force complete on"
    print json.dumps( good_fractions ,indent=2)
    print json.dumps( overrides, indent=2)
    max_force = UC.get("max_force_complete")
    
    #wfs_no_location_in_GQ = set()
    #block_locations = defaultdict(lambda : defaultdict(list))
    #wfs_no_location_in_GQ = defaultdict(list)

    set_force_complete = set()


    for wfo in wfs:
        if specific and not specific in wfo.name: continue

        print "looking at",wfo.name
        ## get all of the same
        wfi = workflowInfo(url, wfo.name)
        pids = wfi.getPrepIDs()
        skip=False
        if not any([c in wfo.name for c in good_fractions]): skip=True
        for user,spec in overrides.items():

            if wfi.request['RequestStatus']!='force-complete':
                if any(s in wfo.name for s in spec) or (wfo.name in spec) or any(pid in spec for pid in pids) or any(s in pids for s in spec):
                    sendEmail('force-complete requested','%s is asking for %s to be force complete'%(user,wfo.name))
                    wfi = workflowInfo(url, wfo.name)
                    forceComplete(url , wfi )
                    skip=True
                    wfi.notifyRequestor("The workflow %s was force completed by request of %s"%(wfo.name,user), do_batch=False)
                    wfi.sendLog('completor','%s is asking for %s to be force complete'%(user,wfo.name))
                    break
    
        if wfo.status.startswith('assistance'): skip = True

        if skip: 
            continue

        priority = wfi.request['RequestPriority']

        if not 'Campaign' in wfi.request: continue

        if not wfi.request['RequestStatus'] in ['acquired','running-open','running-closed']: continue

        c = wfi.request['Campaign']
        if not c in good_fractions: continue
        good_fraction = good_fractions[c]
        ignore_fraction = 2.
        
        lumi_expected = None
        event_expected = None
        if not 'TotalInputEvents' in wfi.request: 
            if 'RequestNumEvents' in wfi.request:
                event_expected = wfi.request['RequestNumEvents']
            else:
                print "truncated, cannot do anything"
                continue
        else:
#.........这里部分代码省略.........
开发者ID:AndrewLevin,项目名称:WmAgentScripts,代码行数:101,代码来源:completor.py

示例12: getDatasetBlockAndSite

    outs= wl['OutputDatasets']
    for out in outs:
        blocks_at_sites = getDatasetBlockAndSite(url, out, group="")
        deletions = getDatasetOnGoingDeletion(url, out)
        if len(deletions):
            print "\t\tshould not subscribe with on-going deletions",out
            continue
        for site,blocks in blocks_at_sites.items():
            if 'Buffer' in site or 'Export' in site or 'MSS' in site: continue
            all_blocks_at_sites[site].update( blocks )
        print "\t",out
        print "\t\t",len(blocks_at_sites),"sites",sorted(blocks_at_sites.keys()),"with unsubscribed blocks"

if len(all_blocks_at_sites.keys())==0 and len(wfs):
    ## no subscription to be done at this time, let me know
    sendEmail('no unsubscribed blocks','while catching up %s does not need to be there anymore'%( one_status ))

print len(all_blocks_at_sites.keys()),"sites to subscribe things at"
for site,blocks in all_blocks_at_sites.items():
    if 'Buffer' in site or 'Export' in site or 'MSS' in site: continue

    if not site in done: done[site] = []
    blocks = [block for block in blocks if not block in done[site]]
    print "Would subscribe",len(blocks),"blocks to",site
    print "\tSubscribe",len(blocks),"blocks to",site    
    done[site].extend( blocks )
    if blocks:
        print makeReplicaRequest(url, site, list(blocks), "Production blocks", priority="low", approve=True,mail=False)
        time.sleep(1)

open('myblock_done.json','w').write( json.dumps( done, indent=2 ))
开发者ID:bbockelm,项目名称:WmAgentScripts,代码行数:31,代码来源:subscribor.py

示例13: stagor


#.........这里部分代码省略.........


        if done:
            ## transfer.status = 'done'
            print transfer.phedexid,"is done"
        else:
            print transfer.phedexid,"not finished"
            pprint.pprint( checks )

    #print done_by_input
    print "\n----\n"
    for dsname in done_by_input:
        fractions = None
        if dsname in completion_by_input:
            fractions = itertools.chain.from_iterable([check.values() for check in completion_by_input.values()])
        
        ## the workflows in the waiting room for the dataset
        using_its = getWorkflowByInput(url, dsname)
        #print using_its
        using_wfos = []
        for using_it in using_its:
            wf = session.query(Workflow).filter(Workflow.name == using_it).first()
            if wf:
                using_wfos.append( wf )
        
        if not len(done_by_input[dsname]):
            print "For dataset",dsname,"there are no transfer report. That's an issue."
            for wf in using_wfos:
                if wf.status == 'staging':
                    if UC.get("stagor_sends_back"):
                        print "sending",wf.name,"back to considered"
                        wf.status = 'considered'
                        session.commit()
                        sendEmail( "send back to considered","%s was send back and might be trouble"% wf.name)
                    else:
                        print "would send",wf.name,"back to considered"
                        sendEmail( "subscription lagging behind","susbscriptions to get %s running are not appearing in phedex. I would have send it back to considered but that's not good."% wf.name)
            continue

        #need_sites = int(len(done_by_input[dsname].values())*0.7)+1
        need_sites = len(done_by_input[dsname].values())
        #if need_sites > 10:            need_sites = int(need_sites/2.)
        got = done_by_input[dsname].values().count(True)
        if all([wf.status != 'staging' for wf in using_wfos]):
            ## not a single ds-using wf is in staging => moved on already
            ## just forget about it
            print "presence of",dsname,"does not matter anymore"
            print "\t",done_by_input[dsname]
            print "\t",[wf.status for wf in using_wfos]
            print "\tneeds",need_sites
            continue #??
            
        ## should the need_sites reduces with time ?
        # with dataset choping, reducing that number might work as a block black-list.

        if len(done_by_input[dsname].values()) and all(done_by_input[dsname].values()):
            print dsname,"is everywhere we wanted"
            ## the input dataset is fully transfered, should consider setting the corresponding wf to staged
            for wf in using_wfos:
                if wf.status == 'staging':
                    print wf.name,"is with us. setting staged and move on"
                    wf.status = 'staged'
                    session.commit()
        elif fractions and len(list(fractions))>1 and set(fractions)==1:
            print dsname,"is everywhere at the same fraction"
            print "We do not want this in the end. we want the data we asked for"
开发者ID:julianbadillo,项目名称:WmAgentScripts,代码行数:67,代码来源:stagor.py

示例14: main

def main():
    options, args = parseCommandLine()

    warnings = {}

    # Verify that existing documents are valid
    for collection in collections:
        logs.info("Running checks for %s" % collection.__name__)
        db = collection()
        begin = time.time()

        stats = {
            'passed': 0,
            'errors': [],
        }

        # Build handler
        greenlets = [ gevent.spawn(handler, db, options) ]

        # Build workers
        for i in range(WORKER_COUNT):
            greenlets.append(gevent.spawn(worker, db, collection, api, stats, options))

        # Run!
        gevent.joinall(greenlets)

        passed = stats.pop('passed', 0)
        errors = stats.pop('errors', [])
        total = passed

        print ('='*80)
        print '%40s: %s' % ('PASSED', passed)
        for k, v in stats.items():
            print '%40s: %s' % (k, v)
            total += int(v)
        print ('-'*80)
        print '%40s: %s%s Accuracy (%.2f seconds)' % (collection.__name__, int(100.0*passed/total*1.0), '%', (time.time()-begin))
        print 

        if len(errors) > 0:
            warnings[collection.__name__] = errors

            for error in errors:
                print error 
            print 

    # TODO: Repopulate missing documents

    # Email dev if any errors come up
    if libs.ec2_utils.is_ec2() and options.email:
        if len(warnings) > 0:
            try:
                stack = libs.ec2_utils.get_stack().instance.stack
                email = {}
                email['from'] = 'Stamped <[email protected]>'
                email['to'] = '[email protected]'
                email['subject'] = '%s: Integrity Checker Failure' % stack

                html = '<html><body><p>Integrity checker caught the following errors:</p>'
                for k, v in warnings.iteritems():
                    html += '<hr><h3>%s</h3>' % k 
                    for e in v:
                        html += ('<p><code>%s</code></p>' % e).replace('\n','<br>')
                html += '</body></html>'

                email['body'] = html
                utils.sendEmail(email, format='html')
            except Exception as e:
                logs.warning('UNABLE TO SEND EMAIL: %s' % e)
开发者ID:Stamped,项目名称:Stamped,代码行数:69,代码来源:MongoIntegrityChecker.py

示例15: injector

def injector(url, options, specific):
    mlock = moduleLock()
    if mlock(): return

    use_mcm = True
    up = componentInfo(soft=['mcm','wtc','jira'] )
    if not up.check(): return
    use_mcm = up.status['mcm']

    UC = unifiedConfiguration()

    transform_keywords = UC.get('convert_to_stepchain')

    workflows = getWorkflows(url, status=options.wmstatus, user=options.user)
    for user in UC.get("user_rereco"):
        workflows.extend( getWorkflows(url, status=options.wmstatus, user=user, rtype="ReReco")) 
    for user in (options.user_relval.split(',') if options.user_relval else UC.get("user_relval")) :
        workflows.extend( getWorkflows(url, status=options.wmstatus, user=user, rtype="TaskChain")) 
    for user in (options.user_storeresults.split(',') if options.user_storeresults else UC.get("user_storeresults")) :
        workflows.extend( getWorkflows(url, status=options.wmstatus, user=user, rtype="StoreResults"))

    print len(workflows),"in line"
    cannot_inject = set()
    to_convert = set()
    status_cache = defaultdict(str)

    ## browse for assignment-approved requests, browsed for ours, insert the diff
    for wf in workflows:
        if specific and not specific in wf: continue

        exists = session.query(Workflow).filter(Workflow.name == wf ).first()
        if not exists:
            wfi = workflowInfo(url, wf)
            ## check first that there isn't related here with something valid
            can_add = True
            ## first try at finding a match
            familly = session.query(Workflow).filter(Workflow.name.contains(wfi.request['PrepID'])).all()
            if not familly:
                pids = wfi.getPrepIDs()
                req_familly = []
                for pid in pids:
                    req_familly.extend( getWorkflowById( url, pid, details=True) )
                    
                familly = []
                print len(req_familly),"members"
                for req_member in req_familly:
                    #print "member",req_member['RequestName']
                    owfi = workflowInfo(url, req_member['RequestName'], request=req_member)
                    other_pids = owfi.getPrepIDs()
                    if set(pids) == set(other_pids):
                        ## this is a real match
                        familly.extend( session.query(Workflow).filter(Workflow.name == req_member['RequestName']).all() )

            for lwfo in familly:
                if lwfo:
                    ## we have it already
                    if not lwfo.status in ['forget','trouble','forget-unlock','forget-out-unlock']:
                        wfi.sendLog('injector',"Should not put %s because of %s %s"%( wf, lwfo.name,lwfo.status ))
                        sendLog('injector',"Should not put %s because of %s %s"%( wf, lwfo.name,lwfo.status ), level='critical')
                        print "Should not put",wf,"because of",lwfo.name,lwfo.status
                        cannot_inject.add( wf )
                        can_add = False
            ## add a check on validity of input datasets
            _,prim,par,sec = wfi.getIO()
            for d in list(prim)+list(par)+list(sec):
                if not d in status_cache:
                    status_cache[d] = getDatasetStatus(d)
                if status_cache[d] != 'VALID':
                    wfi.sendLog('injector',"One of the input is not VALID. %s : %s"%( d, status_cache[d]))
                    sendLog('injector',"One of the input of %s is not VALID. %s : %s"%( wf, d, status_cache[d]), level='critical')
                    can_add = False
                #else:
                #    ##make sure that all blocks get closed
                #    closeAllBlocks(url, d)

                ## check for any file in phedex, to verify existence
                _,ph_files,_,_ = getDatasetFiles(url, d)
                if not ph_files and not ( 'StoreResults' == wfi.request.setdefault('RequestType',None) ):
                    wfi.sendLog('injector',"One of the input has no file in phedex: %s" % d )
                    sendLog('injector',"One of the input has no file in phedex: %s"% d, level='critical')
                    can_add = False

            ### ban some workflow that you don't like anymore
            #outputs = wfi.request['OutputDatasets']



            if not can_add: continue

            ## temporary hack to transform specific taskchain into stepchains
            good_for_stepchain = wfi.isGoodToConvertToStepChain( keywords = transform_keywords)
            #good_for_stepchain = wfi.isGoodToConvertToStepChain( keywords = None) 


            ## match keywords and technical constraints
            if (not options.no_convert) and good_for_stepchain and not wfi.isRelval():
                to_convert.add( wf )
                wfi.sendLog('injector','Transforming %s TaskChain into StepChain'%wf)
                sendEmail('convertion to stepchain','Transforming %s TaskChain into StepChain'%wf)

#.........这里部分代码省略.........
开发者ID:CMSCompOps,项目名称:WmAgentScripts,代码行数:101,代码来源:injector.py


注:本文中的utils.sendEmail函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。