third_party/webxr_test_pages/update_bucket.py
def write_index():
  """Updates Cloud Storage index.html based on available test copies"""
  cr_positions = get_bucket_copies()
  cr_positions.sort(key=int, reverse=True)
  logging.debug('Index: %s', cr_positions)

  items = []

  for pos in cr_positions:
    rev = 'r' + pos
    links = []
    links.append({'href': '%s/index.html' % rev,
                  'anchor': 'index.html'})
    links.append({'href': LINK_CRREV % pos,
                  'anchor': '[crrev]'})
    links.append({'href': LINK_OMAHAPROXY % rev,
                  'anchor': '[find in releases]'})
    commit_hash = get_commit_from_cr_position(pos)
    if commit_hash:
      links.append({'href': LINK_CHROMIUMDASH % commit_hash,
                    'anchor' : '[chromium dash]'})
    items.append({'text': rev, 'links': links})

  template = jinja2.Template(open(INDEX_TEMPLATE).read())
  content = template.render({'items': items})
  logging.debug('index.html content:\n%s', content)

  with tempfile.NamedTemporaryFile(suffix='.html', delete=False) as temp:
    try:
      temp.write(content)
      temp.seek(0)
      temp.close()
      run_modify('gsutil.py', 'cp', temp.name, BUCKET + '/index.html')
    finally:
      os.unlink(temp.name)
Updates Cloud Storage index.html based on available test copies
Updates Cloud Storage index.html based on available test copies
Updates Cloud Storage index . html based on available test copies
def write_index():
  cr_positions = get_bucket_copies()
  cr_positions.sort(key=int, reverse=True)
  logging.debug('Index: %s', cr_positions)
  items = []
  for pos in cr_positions:
    rev = 'r' + pos
    links = []
    links.append({'href': '%s/index.html' % rev,
                  'anchor': 'index.html'})
    links.append({'href': LINK_CRREV % pos,
                  'anchor': '[crrev]'})
    links.append({'href': LINK_OMAHAPROXY % rev,
                  'anchor': '[find in releases]'})
    commit_hash = get_commit_from_cr_position(pos)
    if commit_hash:
      links.append({'href': LINK_CHROMIUMDASH % commit_hash,
                    'anchor' : '[chromium dash]'})
    items.append({'text': rev, 'links': links})
  template = jinja2.Template(open(INDEX_TEMPLATE).read())
  content = template.render({'items': items})
  logging.debug('index.html content:\n%s', content)
  with tempfile.NamedTemporaryFile(suffix='.html', delete=False) as temp:
    try:
      temp.write(content)
      temp.seek(0)
      temp.close()
      run_modify('gsutil.py', 'cp', temp.name, BUCKET + '/index.html')
    finally:
      os.unlink(temp.name)
def write_index ( ) : cr_positions = get_bucket_copies ( ) cr_positions . sort ( key = int , reverse = True ) logging . debug ( 'Index: %s' , cr_positions ) items = [ ] for pos in cr_positions : rev = 'r' + pos links = [ ] links . append ( { 'href' : '%s/index.html' % rev , 'anchor' : 'index.html' } ) links . append ( { 'href' : LINK_CRREV % pos , 'anchor' : '[crrev]' } ) links . append ( { 'href' : LINK_OMAHAPROXY % rev , 'anchor' : '[find in releases]' } ) commit_hash = get_commit_from_cr_position ( pos ) if commit_hash : links . append ( { 'href' : LINK_CHROMIUMDASH % commit_hash , 'anchor' : '[chromium dash]' } ) items . append ( { 'text' : rev , 'links' : links } ) template = jinja2 . Template ( open ( INDEX_TEMPLATE ) . read ( ) ) content = template . render ( { 'items' : items } ) logging . debug ( 'index.html content:\n%s' , content ) with tempfile . NamedTemporaryFile ( suffix = '.html' , delete = False ) as temp : try : temp . write ( content ) temp . seek ( 0 ) temp . close ( ) run_modify ( 'gsutil.py' , 'cp' , temp . name , BUCKET + '/index.html' ) finally : os . unlink ( temp . name )
Updates Cloud Storage index.html based on available test copies
Updates Cloud Storage index . html based on available test copies
"""Updates Cloud Storage index.html based on available test copies"""