示例#1
0
 def file_exists_on_remote(remote_file_location):
     file_copied = GCloud.copy_file_from_remote(remote_file_location,
                                                './temp.txt')
     if file_copied:
         System.run_command('rm ./temp.txt')
         return True
     return False
示例#2
0
 def copy_file_from_remote(remote_file_location, local_target):
     try:
         System.run_command('gcloud compute scp {}:~/{} {}'.format(
             INSTANCE_NAME, remote_file_location, local_target))
         return True
     except:
         return False
示例#3
0
 def prompt_for_billing_id(project_id):
     os.system('gcloud alpha billing accounts list')
     billing_account_id = input(
         "Enter billing Account ID from above (if none exist create one here https://cloud.google.com/billing/docs/how-to/manage-billing-account): "
     )
     System.run_command(
         'gcloud beta billing projects link {} --billing-account={}'.format(
             project_id, billing_account_id))
示例#4
0
 def is_authenticated():
     account = System.run_command(
         'gcloud config list account --format value(core.account)')
     if len(account):
         return True
     else:
         return False
示例#5
0
 def upload_directory_to_bucket(directory, bucket_name):
     buckets_list = System.run_command('gsutil ls')
     if bucket_name not in buckets_list:
         System.run_command('gsutil mb gs://{}/'.format(bucket_name))
     System.run_command('gsutil cp -r {} gs://{}/'.format(
         directory, bucket_name))
示例#6
0
 def upload_file_to_bucket(file_location, bucket_name):
     buckets_list = System.run_command('gsutil ls')
     if bucket_name not in buckets_list:
         System.run_command('gsutil mb gs://{}/'.format(bucket_name))
     System.run_command('gsutil cp {} gs://{}/'.format(
         file_location, bucket_name))
示例#7
0
 def create_project(project_id, project_name):
     System.run_command(
         'gcloud projects create {} --name="{}" --set-as-default'.format(
             project_id, project_name))
     System.run_command('gcloud config set project {}'.format(project_id))
示例#8
0
 def login():
     System.run_command('gcloud auth login')
示例#9
0
 def update_sdk():
     System.run_command('gcloud components update')