parameters: (release, colab_root, dest)
docstring: Installs the Chrome App.
  
    args:
      release: Whether to produce release version.
      colab_root: root directory of colaboratory source
      dest: destination directory for build
docstring_summary: Installs the Chrome App.
docstring_tokens: Installs the Chrome App .
function: def InstallChrome(release, colab_root, dest):
    """Installs the Chrome App.
  
    args:
      release: Whether to produce release version.
      colab_root: root directory of colaboratory source
      dest: destination directory for build
    """
    
    # stage static files
    app_id = DEBUG_APP_ID
    if release:
      app_id = RELEASE_APP_ID
    extra_template_args={
      'app_mode': True,
      'app_origin': 'chrome-extension://' + app_id
    }
    BundleStatic(colab_root, dest, extra_template_args=extra_template_args)
  
    # copy chrome app files, putting pnacl files in root
    # as the folder structure is hard coded into the pnacl kernel code
    # right now
    CopyTreeRecursively(pjoin(colab_root, 'chrome'), dest)
    CopyTreeRecursively(pjoin(colab_root, 'chrome', 'pnacl'), dest)
  
    # Download .pexe and .tar.gz files.  Later these will be pulled
    # from the naclports continuous builder
    pexe_file = pjoin(dest, 'pnacl', 'kernel.pexe')
    tar_file = pjoin(dest, 'pnacl_data.tar.gz')
    url_opener = urllib.URLopener()
    if not os.path.isfile(pexe_file):
      print 'Downloading ' + NACL_PEXE_FILE_URL
      url_opener.retrieve(NACL_PEXE_FILE_URL, pexe_file)
    if not os.path.isfile(tar_file):
      print 'Downloading ' + NACL_TAR_FILE_URL
      url_opener.retrieve(NACL_TAR_FILE_URL, tar_file)
  
    tmp_resources_dir = pjoin(dest, 'tmp_pnacl_resources')
    colabtools_src_dir = pjoin(colab_root, 'colabtools')
    MakeDirectoryIfNotExist(tmp_resources_dir)
    UpdateTarFile(tar_file, colabtools_src_dir, tmp_resources_dir)
    RemoveFileOrDirectoryIfExist(tmp_resources_dir)
  
  
    if release:
      # In release mode, we must change client IDS
      manfiest_file = pjoin(dest, 'manifest.json')
      manifest = {}
      with open(manfiest_file, 'r') as f:
        manifest = json.loads(f.read())
  
      # Delete "key" entry, because published app's don't
      # use private keys to determine to Chrome App ID.
      del manifest['key']
  
      # Change the Client ID to the release client ID
      manifest['oauth2']['client_id'] = RELEASE_CLIENT_ID
  
      # Pretty-print to same manifest file.
      with open(manfiest_file, 'w') as f:
        f.write(json.dumps(manifest, indent=2, separators=(',', ': ')))
function_tokens: def InstallChrome ( release , colab_root , dest ) : # stage static files app_id = DEBUG_APP_ID if release : app_id = RELEASE_APP_ID extra_template_args = { 'app_mode' : True , 'app_origin' : 'chrome-extension://' + app_id } BundleStatic ( colab_root , dest , extra_template_args = extra_template_args ) # copy chrome app files, putting pnacl files in root # as the folder structure is hard coded into the pnacl kernel code # right now CopyTreeRecursively ( pjoin ( colab_root , 'chrome' ) , dest ) CopyTreeRecursively ( pjoin ( colab_root , 'chrome' , 'pnacl' ) , dest ) # Download .pexe and .tar.gz files.  Later these will be pulled # from the naclports continuous builder pexe_file = pjoin ( dest , 'pnacl' , 'kernel.pexe' ) tar_file = pjoin ( dest , 'pnacl_data.tar.gz' ) url_opener = urllib . URLopener ( ) if not os . path . isfile ( pexe_file ) : print 'Downloading ' + NACL_PEXE_FILE_URL url_opener . retrieve ( NACL_PEXE_FILE_URL , pexe_file ) if not os . path . isfile ( tar_file ) : print 'Downloading ' + NACL_TAR_FILE_URL url_opener . retrieve ( NACL_TAR_FILE_URL , tar_file ) tmp_resources_dir = pjoin ( dest , 'tmp_pnacl_resources' ) colabtools_src_dir = pjoin ( colab_root , 'colabtools' ) MakeDirectoryIfNotExist ( tmp_resources_dir ) UpdateTarFile ( tar_file , colabtools_src_dir , tmp_resources_dir ) RemoveFileOrDirectoryIfExist ( tmp_resources_dir ) if release : # In release mode, we must change client IDS manfiest_file = pjoin ( dest , 'manifest.json' ) manifest = { } with open ( manfiest_file , 'r' ) as f : manifest = json . loads ( f . read ( ) ) # Delete "key" entry, because published app's don't # use private keys to determine to Chrome App ID. del manifest [ 'key' ] # Change the Client ID to the release client ID manifest [ 'oauth2' ] [ 'client_id' ] = RELEASE_CLIENT_ID # Pretty-print to same manifest file. with open ( manfiest_file , 'w' ) as f : f . write ( json . dumps ( manifest , indent = 2 , separators = ( ',' , ': ' ) ) )