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


Python ResQ.enqueue方法代码示例

本文整理汇总了Python中pyres.ResQ.enqueue方法的典型用法代码示例。如果您正苦于以下问题:Python ResQ.enqueue方法的具体用法?Python ResQ.enqueue怎么用?Python ResQ.enqueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyres.ResQ的用法示例。


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

示例1: publish

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
def publish(text, url=None):
    '''
    Publish status to social networks.
    '''
    r = ResQ()
    r.enqueue(TwitterStatus, text, url)
    r.enqueue(VkontakteStatus, text, url)
开发者ID:nott,项目名称:kkb,代码行数:9,代码来源:__init__.py

示例2: publish

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
def publish(subject, text):
    '''
    Publish cumulative post to Livejournal.
    '''
    r = ResQ()
    for target in settings.PUBLISHING_LJ_TARGETS.iterkeys():
        r.enqueue(LivejournalPost, target, subject, text)
开发者ID:nott,项目名称:kkb,代码行数:9,代码来源:livejournal.py

示例3: perform

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
 def perform(eventid):
     print (eventid)
     db = sqlitedb()
     eventrec = db.getactiveevent()
     for event in eventrec:
         print event['eventid']
         r = ResQ(server="%s:%s" % (resqserver, resqport))
         r.enqueue(callQ, event['eventid'])
开发者ID:eiroh,项目名称:barista,代码行数:10,代码来源:eventq.py

示例4: submit_feedback

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
def submit_feedback(request):
    if request.method != 'POST':
        raise Http404
    if 'lang' in request.GET and request.GET['lang'] in ALLOWED_LANGS:
        translation.activate(request.GET['lang'])

    try:
        form = FeedbackForm(request.POST or None)
        if form.is_valid():
            r = ResQ()
            r.enqueue(FeedbackTask, form.cleaned_data['name'],
                      form.cleaned_data['email'], form.cleaned_data['text'])
            return HttpResponse(status=200)
    
        # form is invalid
        return HttpResponse(
            loader.render_to_string('feedback/feedback_form_partial.html',
                                    {'feedback_form': form}),
            status=409)
    except Exception:
        logger.exception('')
        raise
开发者ID:nott,项目名称:django-pyres-feedback,代码行数:24,代码来源:views.py

示例5: add_repository_to_queue

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
def add_repository_to_queue(user, repo_owner, repository_name, repo_object=None):
    res = ResQ()
    repo = None
    token = user.get_profile().extra_data['access_token']

    if not repo_object:

        gh = Github(login=user.email, token=token)

        repo = gh.repos.get(repo_owner, repository_name)
    else:
        repo = repo_object

    queue_data = {'email': user.email, 'token': token}
    queue_data['repo'] = {
        'name': repo.name,
        'url': repo.url,
        'git_url': repo.git_url,
        'html_url': repo.html_url,
        'language': repo.language
    }

    db_repo, created = Repository.objects.get_or_create(
            git_url=repo.git_url, defaults=queue_data['repo'])

    query_filter = {'user': user, 'repository': db_repo}
    query_filter.update({'defaults': {
            'user': user,
            "repository": db_repo
        }
    })

    as_contributor, created = Contributor.objects.get_or_create(**query_filter)

    # put a timestamp field in repository model to verify if there is need to 
    # process again. so only put in queue if is not created and timestamp > x time

    res.enqueue(RepositoryWorker, queue_data)
开发者ID:timehome,项目名称:djangodash2012,代码行数:40,代码来源:models.py

示例6: perform

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
    def perform(text, url):
        '''
        Delayed task.
        '''
        if not settings.PUBLISHING_VKONTAKTE_USER:
            return
        if not url is None:
            text = '%s %s' % (text, url)

        method = 'wall.post'
        owner_id, token, extra_params = settings.PUBLISHING_VKONTAKTE_USER
        params = {'owner_id': owner_id,
                  'access_token': token,
                  'message': text}
        params.update(extra_params)
        resp = vk(method, params)
        post_id = resp.get("response", {}).get("post_id")
        if not post_id:
            raise ValueError('Post ID not provided.\nMethod %s\nParams %r'\
                                 '\n Response %r' % (method, params, resp))

        r = ResQ()
        for user, data in settings.PUBLISHING_VKONTAKTE_REPOST_USERS.iteritems():
            r.enqueue(VkontakteLike, user, owner_id, post_id)
开发者ID:nott,项目名称:kkb,代码行数:26,代码来源:vkontakte.py

示例7: queue_job

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
def queue_job(input_coordinate=None, \
              hg18_option='off', \
              transcript_type='NA', \
              refseq_correspondence='no', \
              sample_id='yes', \
              analysis_type=None, \
              analysis_programs=None):
    if analysis_type == None:
        print 'Choose an analysis type.'
        return
    input_basename = input_coordinate + '_' + hg18_option + '_' + transcript_type + '_' + refseq_correspondence + '_' + sample_id + '.txt'
    job_name = input_basename[:-4] + '_' + analysis_type + '_' + analysis_programs + '_20121231_010101'
    job_dir = os.path.join(diagnostic_tests_dir, job_name)
    if os.path.exists(job_dir) == False:
        os.mkdir(job_dir)
    input_filename = os.path.join(job_dir, input_basename)
    shutil.copy(os.path.join(diagnostic_tests_dir, input_basename), input_filename)
    job_id = job_name
    mutation_filename = input_filename
    mutation_filename_fix = mutation_filename + '.fix'
    mutation_filename_error = mutation_filename +'.error'
    email = '[email protected]'
    classifier = '_Other'
    upload_filename = input_basename
    user_upload_dir = job_dir
    chosen_db_str = analysis_programs.strip('_')
    chosen_dbs = chosen_db_str.split('_')
    tsv_report = 'on'
    gene_annot = 'on'
    hg18 = hg18_option
    functional_annot = 'on'
    f = open(input_filename)
    no_input_line = 0
    for line in f:
        if len(line) > 0:
            if not line[0] in ['#', '>', '!']:
                no_input_line += 1
    f.close()
    if no_input_line >= 5000:
        queue_name = queue_name_prefix + '_LARGE'
    else:
        queue_name = queue_name_prefix + '_SMALL'
    mupit_input = 'on'
    resubmit = 'no'
    wf = open(os.path.join(job_dir, 'job_info.txt'), 'w')
    wf.write(str(no_input_line)+'\n')
    wf.write(job_id+'\n')
    wf.write(chosen_db_str+'\n')
    wf.write('call_queuer_path\n')
    wf.write('python_path\n')
    wf.write('queuer_path\n')
    wf.write(email+'\n')
    wf.write(job_id+'\n')
    wf.write(classifier+'\n')
    wf.write(mutation_filename+'\n')
    wf.write(upload_filename+'\n')
    wf.write(user_upload_dir+'\n')
    wf.write(chosen_db_str+'\n')
    wf.write(tsv_report+'\n')
    wf.write(functional_annot+'\n')
    wf.write(hg18+'\n')
    wf.write(analysis_type+'\n')
    wf.write(str(no_input_line)+'\n')
    wf.write('error_output_path\n')
    wf.write(mupit_input+'\n')
    wf.close()
    r=ResQ()
    argstr  =       'dummy'
    argstr += ' ' + 'yes'
    argstr += ' ' + user_upload_dir
    argstr += ' ' + resubmit
    argstr += ' ' + job_id
    argstr += ' -e ' + email
    argstr += ' -i ' + job_id
    argstr += ' -c ' + classifier
    argstr += ' -m ' + mutation_filename
    argstr += ' -u ' + upload_filename
    argstr += ' -D ' + user_upload_dir
    argstr += ' -d ' + chosen_db_str
    argstr += ' -t ' + tsv_report
    argstr += ' -f ' + functional_annot
    argstr += ' -r ' + hg18
    argstr += ' -y ' + analysis_type
    argstr += ' -n ' + str(no_input_line)
    argstr += ' -M ' + mupit_input
    argstr += ' -R ' + resubmit
    argstr += ' -Q ' + queue_name
    argstr += ' -T ' + 'yes' # -T option for 'test'
    r.enqueue(queue_name, masteranalyzer.MasterAnalyzer, argstr)
    global job_ids
    job_ids.append(job_id)
开发者ID:kmoad,项目名称:CRAVAT-testing,代码行数:93,代码来源:inside_server_submit_test.py

示例8: Task

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
class Task(object):
    queue ="test-queue"
    
    def __init__(self,payload):
        self.payload = payload
    
    @staticmethod
    def perform(json_dir):
        print "do something %s\n" % (json_dir)
        
        
    



if __name__ == '__main__':
    
    
    r = ResQ()
    print("Enqueue message\n")
    r.enqueue(Task,"{key:id-1, file:'/tmp/toto.jpg'}")
    #print("get message from basic\n")
    #job = Job.reserve('test-queue', r)
    job = None
    
    if job:
        print("job payload %s\n" % (job._payload) )
    else:
        print( "No jobs \n")
    
    
开发者ID:gaubert,项目名称:imgr-on-dotcloud,代码行数:31,代码来源:resqueue_test.py

示例9: publish

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import enqueue [as 别名]
def publish(text, link, image):
    r = ResQ()
    r.enqueue(FacebookLink, text, link, image, True)
    r.enqueue(FacebookLink, text, link, image, False)
开发者ID:nott,项目名称:kkb,代码行数:6,代码来源:facebooklink.py


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