예제 #1
0
def _WaitForLatestSnapshot(revision):
    util.MarkBuildStepStart('wait_for_snapshot')
    while True:
        snapshot_revision = archive.GetLatestSnapshotVersion()
        if int(snapshot_revision) >= int(revision):
            break
        util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                           (revision, snapshot_revision))
        time.sleep(60)
    util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision)
예제 #2
0
def WaitForLatestSnapshot(revision):
    util.MarkBuildStepStart('wait_for_snapshot')
    while True:
        snapshot_revision = archive.GetLatestRevision(archive.Site.SNAPSHOT)
        if snapshot_revision >= revision:
            break
        util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                           (revision, snapshot_revision))
        time.sleep(60)
    util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision)
예제 #3
0
def _WaitForLatestSnapshot(commit_position):
    util.MarkBuildStepStart('wait_for_snapshot')
    while True:
        snapshot_position = archive.GetLatestSnapshotVersion()
        if commit_position is not None and snapshot_position is not None:
            if int(snapshot_position) >= int(commit_position):
                break
            util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                               (commit_position, snapshot_position))
        time.sleep(60)
    util.PrintAndFlush('Got snapshot commit position %s' % snapshot_position)
예제 #4
0
def _WaitForLatestSnapshot(commit_position):
  util.MarkBuildStepStart('wait_for_snapshot')
  for attempt in range(0, 200):
    snapshot_position = archive.GetLatestSnapshotPosition()
    if commit_position is not None and snapshot_position is not None:
      if int(snapshot_position) >= int(commit_position):
        break
      util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                         (commit_position, snapshot_position))
    time.sleep(60)
  if int(snapshot_position) < int(commit_position):
    raise Exception('Failed to find a snapshot version >= %s' % commit_position)
  util.PrintAndFlush('Got snapshot commit position %s' % snapshot_position)
예제 #5
0
def _GetGitHashFromCommitPosition(commit_position):
    json_url = CR_REV_URL % commit_position
    try:
        response = urllib2.urlopen(json_url)
    except urllib2.HTTPError as error:
        util.PrintAndFlush('HTTP Error %d' % error.getcode())
        return None
    except urllib2.URLError as error:
        util.PrintAndFlush('URL Error %s' % error.message)
        return None
    data = json.loads(response.read())
    if 'git_sha' in data:
        return data['git_sha']
    util.PrintAndFlush('Failed to get git hash for %s' % commit_position)
    return None
def _WaitForLatestSnapshot(revision):
  util.MarkBuildStepStart('wait_for_snapshot')
  def _IsRevisionNumber(revision):
    if isinstance(revision, int):
      return True
    else:
      return revision.isdigit()
  while True:
    snapshot_revision = archive.GetLatestSnapshotVersion()
    if not _IsRevisionNumber(revision):
      revision = _GetSVNRevisionFromGitHash(revision)
    if not _IsRevisionNumber(snapshot_revision):
      snapshot_revision = _GetSVNRevisionFromGitHash(snapshot_revision)
    if revision is not None and snapshot_revision is not None:
      if int(snapshot_revision) >= int(revision):
        break
      util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                         (revision, snapshot_revision))
    time.sleep(60)
  util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision)
def _GetSVNRevisionFromGitHash(snapshot_hashcode):
  json_url = GS_GITHASH_TO_SVN_URL % snapshot_hashcode
  try:
    response = urllib2.urlopen(json_url)
  except urllib2.HTTPError as error:
    util.PrintAndFlush('HTTP Error %d' % error.getcode())
  except urllib2.URLError as error:
    util.PrintAndFlush('URL Error %s' % error.message)
    return None
  data = json.loads(response.read()[4:])
  if 'message' in data:
    message = data['message'].split('\n')
    message = [line for line in message if line.strip()]
    search_pattern = re.compile(GS_SEARCH_PATTERN)
    result = search_pattern.search(message[len(message)-1])
    if result:
      return result.group(1)
  util.PrintAndFlush('Failed to get svn revision number for %s' %
                     snapshot_hashcode)
  return None