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


Python retry.retry函数代码示例

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


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

示例1: make_generic_head_request

def make_generic_head_request(page_url):
    """Make generic HEAD request to check page existence"""
    def _get():
        req = requests.head(page_url, timeout=60)
        req.raise_for_status()

    retry(_get, attempts=5, sleeptime=1)
开发者ID:nthomas-mozilla,项目名称:build-tools,代码行数:7,代码来源:sanity.py

示例2: tagOtherRepo

def tagOtherRepo(config, repo, reponame, revision, pushAttempts):
    remote = make_hg_url(HG, repo)
    mercurial(remote, reponame)

    def tagRepo(repo, attempt, config, revision, tags):
        # set totalChangesets=1 because tag() generates exactly 1 commit
        totalChangesets = 1
        # update to the desired revision first, then to the tip of revision's
        # branch to avoid new head creation
        update(repo, revision=revision)
        update(repo)
        tag(repo, revision, tags, config['hgUsername'])
        outgoingRevs = retry(out, kwargs=dict(src=reponame, remote=remote,
                                              ssh_username=config[
                                                  'hgUsername'],
                                              ssh_key=config['hgSshKey']))
        if len(outgoingRevs) != totalChangesets:
            raise Exception("Wrong number of outgoing revisions")

    pushRepo = make_hg_url(HG, repo, protocol='ssh')

    def tag_wrapper(r, n):
        tagRepo(r, n, config, revision, tags)

    def cleanup_wrapper():
        cleanOutgoingRevs(reponame, pushRepo, config['hgUsername'],
                          config['hgSshKey'])
    retry(apply_and_push, cleanup=cleanup_wrapper,
          args=(reponame, pushRepo, tag_wrapper, pushAttempts),
          kwargs=dict(ssh_username=config['hgUsername'],
                      ssh_key=config['hgSshKey']))
开发者ID:SergiosLen,项目名称:browser-f,代码行数:31,代码来源:tag-release.py

示例3: do_reboot

def do_reboot(slaveapi, slave):
    url = furl(slaveapi)
    url.path.add("slaves").add(slave).add("actions").add("reboot")
    retry(requests.post, args=(str(url),))
    # Because SlaveAPI fully escalates reboots (all the way to IT bug filing),
    # there's no reason for us to watch for it to complete.
    log.info("%s - Reboot queued", slave)
    return
开发者ID:gerva,项目名称:tools,代码行数:8,代码来源:reboot-idle-slaves.py

示例4: action_update

def action_update(master):
    print "sleeping 30 seconds to make sure that hg.m.o syncs NFS... ",
    time.sleep(30)
    print OK
    with show('running'):
        retry(run, args=('source bin/activate && make update',),
                kwargs={'workdir': master['basedir']}, sleeptime=10,
                retry_exceptions=(SystemExit,))
    print OK, "updated %(hostname)s:%(basedir)s" % master
开发者ID:garbas,项目名称:build-tools,代码行数:9,代码来源:actions.py

示例5: repackLocale

def repackLocale(locale, l10nRepoDir, l10nBaseRepo, revision, localeSrcDir,
                 l10nIni, compareLocalesRepo, env, merge=True,
                 prevMar=None, productName=None, platform=None,
                 version=None, oldVersion=None):
    repo = "/".join([l10nBaseRepo, locale])
    localeDir = path.join(l10nRepoDir, locale)
    retry(mercurial, args=(repo, localeDir))
    update(localeDir, revision=revision)
    
    compareLocales(compareLocalesRepo, locale, l10nRepoDir, localeSrcDir,
                   l10nIni, revision=revision, merge=merge)
    env["AB_CD"] = locale
    env["LOCALE_MERGEDIR"] = path.abspath(path.join(localeSrcDir, "merged"))
    if sys.platform.startswith('win'):
        env["LOCALE_MERGEDIR"] = windows2msys(env["LOCALE_MERGEDIR"])
    if sys.platform.startswith('darwin'):
        env["MOZ_PKG_PLATFORM"] = "mac"
    run_cmd(["make", "installers-%s" % locale], cwd=localeSrcDir, env=env)
    UPLOAD_EXTRA_FILES = []
    if prevMar:
        nativeDistDir = path.normpath(path.abspath(path.join(localeSrcDir,
                                                             '../../dist')))
        posixDistDir = windows2msys(nativeDistDir)
        mar = '%s/host/bin/mar' % posixDistDir
        mbsdiff = '%s/host/bin/mbsdiff' % posixDistDir
        current = '%s/current' % posixDistDir
        previous = '%s/previous' % posixDistDir
        updateDir = 'update/%s/%s' % (buildbot2ftp(platform), locale)
        updateAbsDir = '%s/%s' % (posixDistDir, updateDir)
        current_mar = '%s/%s-%s.complete.mar' % (updateAbsDir, productName, version)
        partial_mar_name = '%s-%s-%s.partial.mar' % (productName, oldVersion,
                                                     version)
        partial_mar = '%s/%s' % (updateAbsDir, partial_mar_name)
        UPLOAD_EXTRA_FILES.append('%s/%s' % (updateDir, partial_mar_name))
        env['MAR'] = mar
        env['MBSDIFF'] = mbsdiff
        run_cmd(['rm', '-rf', previous, current])
        run_cmd(['mkdir', previous, current])
        run_cmd(['perl', '../../../tools/update-packaging/unwrap_full_update.pl',
                 '../../../../%s' % prevMar],
                cwd=path.join(nativeDistDir, 'previous'), env=env)
        run_cmd(['perl', '../../../tools/update-packaging/unwrap_full_update.pl',
                 current_mar], cwd=path.join(nativeDistDir, 'current'), env=env)
        run_cmd(
            ['bash', '../../tools/update-packaging/make_incremental_update.sh',
             partial_mar, previous, current], cwd=nativeDistDir, env=env)
        if os.environ.get('MOZ_SIGN_CMD'):
            run_cmd(['bash', '-c',
                     '%s -f gpg -f mar "%s"' %
                     (os.environ['MOZ_SIGN_CMD'], partial_mar)],
                     env=env)
            UPLOAD_EXTRA_FILES.append('%s/%s.asc' % (updateDir, partial_mar_name))

    retry(run_cmd,
          args=(["make", "upload", "AB_CD=%s" % locale,
                 'UPLOAD_EXTRA_FILES=%s' % ' '.join(UPLOAD_EXTRA_FILES)],),
          kwargs={'cwd': localeSrcDir, 'env': env})
开发者ID:EkkiD,项目名称:build-tools,代码行数:57,代码来源:l10n.py

示例6: tagRepo

def tagRepo(config, repo, reponame, revision, tags, bumpFiles, relbranch,
            pushAttempts, defaultBranch='default'):
    remote = make_hg_url(HG, repo)
    retry(mercurial, args=(remote, reponame))

    def bump_and_tag(repo, attempt, config, relbranch, revision, tags,
                     defaultBranch):
        # set relbranchChangesets=1 because tag() generates exactly 1 commit
        relbranchChangesets = 1
        defaultBranchChangesets = 0

        if relbranch in get_branches(reponame):
            update(reponame, revision=relbranch)
        else:
            update(reponame, revision=revision)
            run_cmd(['hg', 'branch', relbranch], cwd=reponame)

        if len(bumpFiles) > 0:
            # Bump files on the relbranch, if necessary
            bump(reponame, bumpFiles, 'version')
            run_cmd(['hg', 'diff'], cwd=repo)
            try:
                get_output(['hg', 'commit', '-u', config['hgUsername'],
                            '-m', getBumpCommitMessage(config['productName'], config['version'])],
                           cwd=reponame)
                relbranchChangesets += 1
            except subprocess.CalledProcessError, e:
                # We only want to ignore exceptions caused by having nothing to
                # commit, which are OK. We still want to raise exceptions caused
                # by any other thing.
                if e.returncode != 1 or "nothing changed" not in e.output:
                    raise

        # We always want our tags pointing at the tip of the relbranch
        # so we need to grab the current revision after we've switched
        # branches and bumped versions.
        revision = get_revision(reponame)
        # Create the desired tags on the relbranch
        tag(repo, revision, tags, config['hgUsername'])

        # This is the bump of the version on the default branch
        # We do it after the other one in order to get the tip of the
        # repository back on default, thus avoiding confusion.
        if len(bumpFiles) > 0:
            update(reponame, revision=defaultBranch)
            bump(reponame, bumpFiles, 'nextVersion')
            run_cmd(['hg', 'diff'], cwd=repo)
            try:
                get_output(['hg', 'commit', '-u', config['hgUsername'],
                            '-m', getBumpCommitMessage(config['productName'], config['version'])],
                           cwd=reponame)
                defaultBranchChangesets += 1
            except subprocess.CalledProcessError, e:
                if e.returncode != 1 or "nothing changed" not in e.output:
                    raise
开发者ID:B-Rich,项目名称:build-tools,代码行数:55,代码来源:tag-release.py

示例7: maybe_delete_repo

def maybe_delete_repo(server, username, sshKey, repo, repoPath):
    reponame = get_repo_name(repo)
    repo_url = make_hg_url(server, '%s/%s' % (repoPath, reponame))
    try:
        log.info("Trying to open %s" % repo_url)
        urlopen(repo_url)
    except URLError:
        log.info("%s doesn't exist, not deleting" % reponame)
    else:
        log.info('Deleting %s' % reponame)
        retry(run_remote_cmd, args=('edit %s delete YES' % reponame, server,
                                    username, sshKey))
开发者ID:EkkiD,项目名称:build-tools,代码行数:12,代码来源:repo_setup.py

示例8: createRepacks

def createRepacks(sourceRepo, revision, l10nRepoDir, l10nBaseRepo,
                  mozconfigPath, objdir, makeDirs, locales, ftpProduct,
                  appName, version, appVersion, buildNumber, stageServer,
                  stageUsername, stageSshKey, compareLocalesRepo, merge,
                  platform, stage_platform, brand, mobileDirName):
    sourceRepoName = path.split(sourceRepo)[-1]
    nightlyDir = "candidates"
    localeSrcDir = path.join(sourceRepoName, objdir, mobileDirName, "locales")
    # Even on Windows we need to use "/" as a separator for this because
    # compare-locales doesn"t work any other way
    l10nIni = "/".join([sourceRepoName, mobileDirName, "locales", "l10n.ini"])

    env = {
        "MOZ_OBJDIR": objdir,
        "MOZ_PKG_VERSION": version,
        "UPLOAD_HOST": stageServer,
        "UPLOAD_USER": stageUsername,
        "UPLOAD_SSH_KEY": stageSshKey,
        "UPLOAD_TO_TEMP": "1",
        # Android signing
        "JARSIGNER": os.path.join(os.getcwd(), "scripts", "release",
                                  "signing", "mozpass.py")
    }
    build.misc.cleanupObjdir(sourceRepoName, objdir, mobileDirName)
    retry(mercurial, args=(sourceRepo, sourceRepoName))
    update(sourceRepoName, revision=revision)
    l10nRepackPrep(sourceRepoName, objdir, mozconfigPath,
                   l10nRepoDir, makeDirs, localeSrcDir, env)
    fullCandidatesDir = makeCandidatesDir(appName, version, buildNumber,
                                      protocol='http', server=stageServer,
                                      nightlyDir=nightlyDir)
    input_env = retry(downloadReleaseBuilds,
                      args=(stageServer, ftpProduct, brand, version,
                            buildNumber, stage_platform, fullCandidatesDir))
    env.update(input_env)
    print "env pre-locale: %s" % str(env)

    failed = []
    for l in locales:
        try:
            # adding locale into builddir
            env["POST_UPLOAD_CMD"] = postUploadCmdPrefix(
                to_mobile_candidates=True,
                product=appName,
                version=version,
                builddir='%s/%s' % (stage_platform, l),
                buildNumber=buildNumber,
                nightly_dir=nightlyDir,)
            print "env post-locale: %s" % str(env)
            repackLocale(str(l), l10nRepoDir, l10nBaseRepo, revision,
                         localeSrcDir, l10nIni, compareLocalesRepo, env, merge)
        except Exception, e:
            failed.append((l, format_exc()))
开发者ID:EkkiD,项目名称:build-tools,代码行数:53,代码来源:release-mobile-repacks.py

示例9: commitSVN

def commitSVN(targetSVNDirectory, product, version, fakeCommit=False):
    """
    Commit the change in the svn
    """
    retval = os.getcwd()
    os.chdir(targetSVNDirectory)
    try:
        if not os.path.isdir(".svn"):
            raise Exception("Could not find the svn directory")
        commitMSG = "'" + product + " version " + version + "'"
        if not fakeCommit:
            retry(doCommitSVN, args=(commitMSG), attempts=3, sleeptime=0)
    finally:
        os.chdir(retval)
开发者ID:pocmo,项目名称:build-tools,代码行数:14,代码来源:svn.py

示例10: compareLocales

def compareLocales(repo, locale, l10nRepoDir, localeSrcDir, l10nIni,
                   revision="default", merge=True):
    retry(mercurial, args=(repo, "compare-locales"))
    update("compare-locales", revision=revision)
    mergeDir = path.join(localeSrcDir, "merged")
    if path.exists(mergeDir):
        log.info("Deleting %s" % mergeDir)
        shutil.rmtree(mergeDir)
    run_cmd(["python", path.join("compare-locales", "scripts",
                                 "compare-locales"),
             "-m", mergeDir,
             l10nIni,
             l10nRepoDir, locale],
            env={"PYTHONPATH": path.join("compare-locales", "lib")})
开发者ID:bdacode,项目名称:build-tools,代码行数:14,代码来源:l10n.py

示例11: process

 def process(self):
     """
     Process this patchset, doing the following:
         1. Check permissions on patchset
         2. Clone the repository
         3. Apply patches, with 3 attempts
     """
     # 1. Check permissions on each patch
     outgoing = self.branch if not self.try_run else 'try'
     if not has_sufficient_permissions(self.user, outgoing):
         log.error('Insufficient permissions to push to %s.'
                 % (outgoing))
         self.add_comment('Insufficient permissions to push to %s.'
                 % (outgoing))
         return (False, '\n'.join(self.comments))
     # 2. Clone the repository
     cloned_rev = None
     try:
         cloned_rev = clone_branch(self.branch, self.branch_url)
     except RetryException:
         log.error('[Branch %s] Could not clone from %s.'
                 % (self.branch, self.branch_url))
         self.add_comment('An error occurred while cloning %s.'
                 % (self.branch_url))
         return (False, '\n'.join(self.comments))
     # 3. Apply patches, with 3 attempts
     try:
         # make 3 attempts so that
         # 1st is on current clone,
         # 2nd attempt is after an update -C,
         # 3rd attempt is a fresh clone
         retry(apply_and_push, attempts=3,
                 retry_exceptions=(RetryException,),
                 cleanup=RepoCleanup(self.branch, self.branch_url),
                 args=(self.active_repo, self.push_url,
                       self.apply_patches, 1),
                 kwargs=dict(ssh_username=config['hg_username'],
                             ssh_key=config['hg_ssh_key'],
                             force=self.try_run))    # force only on try
         revision = get_revision(self.active_repo)
         shutil.rmtree(self.active_repo)
         for patch in self.patches:
             patch.delete()
     except (HgUtilError, RetryException, FailException), err:
         # Failed
         log.error('[PatchSet] Could not be applied and pushed.\n%s'
                 % (err))
         self.add_comment('Patchset could not be applied and pushed.'
                          '\n%s' % (err))
         return (False, '\n'.join(self.comments))
开发者ID:gerva,项目名称:build-autoland,代码行数:50,代码来源:hgpusher.py

示例12: get_production_slaves

def get_production_slaves(slaveapi):
    url = furl(slaveapi)
    url.path.add("slaves")
    url.args["environment"] = "prod"
    url.args["enabled"] = 1
    r = retry(requests.get, args=(str(url),))
    return r.json()["slaves"]
开发者ID:B-Rich,项目名称:build-tools,代码行数:7,代码来源:reboot-idle-slaves.py

示例13: cleanOutgoingRevs

def cleanOutgoingRevs(reponame, remote, username, sshKey):
    outgoingRevs = retry(out, kwargs=dict(src=reponame, remote=remote,
                                          ssh_username=username,
                                          ssh_key=sshKey))
    for r in reversed(outgoingRevs):
        run_cmd(['hg', '--config', 'extensions.mq=', 'strip', '-n',
                 r[REVISION]], cwd=reponame)
开发者ID:70599,项目名称:Waterfox,代码行数:7,代码来源:hg.py

示例14: request

 def request(self, params=None, data=None, method='GET', url_template_vars={}):
     url = self.api_root + self.url_template % url_template_vars
     if method != 'GET' and method != 'HEAD':
         if not self.csrf_token or is_csrf_token_expired(self.csrf_token):
             res = self.session.request(
                 method='HEAD', url=self.api_root + '/csrf_token',
                 config=self.config, timeout=self.timeout,
                 auth=self.auth)
             self.csrf_token = res.headers['X-CSRF-Token']
         data['csrf_token'] = self.csrf_token
     log.debug('Request to %s' % url)
     log.debug('Data sent: %s' % data)
     try:
         return retry(self.session.request, sleeptime=5, max_sleeptime=15,
                      retry_exceptions=(requests.HTTPError, 
                                        requests.ConnectionError),
                      attempts=self.retries,
                      kwargs=dict(method=method, url=url, data=data,
                                  config=self.config, timeout=self.timeout,
                                  auth=self.auth, params=params)
                     )
     except requests.HTTPError, e:
         log.error('Caught HTTPError: %d %s' % 
                  (e.response.status_code, e.response.content), 
                  exc_info=True)
         raise
开发者ID:ffledgling,项目名称:build-tools,代码行数:26,代码来源:api.py

示例15: ssh

def ssh(user, identity, host, remote_cmd, port=22):
    cmd = ['ssh', '-l', user]
    if identity:
        cmd.extend(['-i', identity])
    cmd.extend(['-p', str(port), host, remote_cmd])

    return retry(do_cmd, attempts=retries + 1, sleeptime=retry_sleep, args=(cmd,))
开发者ID:djmitche,项目名称:build-buildbotcustom,代码行数:7,代码来源:log_uploader.py


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