def app_restore(storage, bucket_name=None):
 if (not makedirs(APP_BACKUP_DIR_LOCATION)):
  logging.warning("Dir '{0}' already exists. Skipping dir creation...".format(APP_BACKUP_DIR_LOCATION))
 if (storage == StorageTypes.GCS):
  objects = gcs_helper.list_bucket(bucket_name)
  for app_path in objects:
   if (not app_path.startswith(gcs_helper.APPS_GCS_PREFIX)):
    continue
   app_file = app_path[len(gcs_helper.APPS_GCS_PREFIX):]
   source = 'gs://{0}/{1}'.format(bucket_name, app_path)
   destination = '{0}/{1}'.format(APP_BACKUP_DIR_LOCATION, app_file)
   if (not gcs_helper.download_from_bucket(source, destination)):
    logging.error("Error while downloading '{0}' from GCS.".format(source))
    delete_app_tars(APP_BACKUP_DIR_LOCATION)
    return False
 apps_to_deploy = [os.path.join(APP_BACKUP_DIR_LOCATION, app) for app in os.listdir(APP_BACKUP_DIR_LOCATION)]
 if (not deploy_apps(apps_to_deploy)):
  logging.error('Failed to successfully deploy one or more of the following apps: {0}'.format(apps_to_deploy))
  return False
 return True

def app_restore ( storage , bucket_name = None ) : if ( not makedirs ( APP_BACKUP_DIR_LOCATION ) ) : logging . warning ( "Dir '{0}' already exists. Skipping dir creation..." . format ( APP_BACKUP_DIR_LOCATION ) ) if ( storage == StorageTypes . GCS ) : objects = gcs_helper . list_bucket ( bucket_name ) for app_path in objects : if ( not app_path . startswith ( gcs_helper . APPS_GCS_PREFIX ) ) : continue app_file = app_path [ len ( gcs_helper . APPS_GCS_PREFIX ) : ] source = 'gs://{0}/{1}' . format ( bucket_name , app_path ) destination = '{0}/{1}' . format ( APP_BACKUP_DIR_LOCATION , app_file ) if ( not gcs_helper . download_from_bucket ( source , destination ) ) : logging . error ( "Error while downloading '{0}' from GCS." . format ( source ) ) delete_app_tars ( APP_BACKUP_DIR_LOCATION ) return False apps_to_deploy = [ os . path . join ( APP_BACKUP_DIR_LOCATION , app ) for app in os . listdir ( APP_BACKUP_DIR_LOCATION ) ] if ( not deploy_apps ( apps_to_deploy ) ) : logging . error ( 'Failed to successfully deploy one or more of the following apps: {0}' . format ( apps_to_deploy ) ) return False return True
restores the app source code from the backups location on the filesystem .