| 56 | |
| 57 | |
| 58 | class DiffgramInstallTool: |
| 59 | static_storage_provider = None |
| 60 | bucket_name = None |
| 61 | bucket_region = None |
| 62 | gcp_credentials_path = None |
| 63 | use_docker_minio:bool = True |
| 64 | s3_endpoint_url = None |
| 65 | s3_access_id = None |
| 66 | s3_access_secret = None |
| 67 | is_aws_signature_v4 = None |
| 68 | azure_connection_string = None |
| 69 | diffgram_version = None |
| 70 | database_url = None |
| 71 | local_database = None |
| 72 | mailgun = None |
| 73 | mailgun_key = None |
| 74 | email_domain = None |
| 75 | z_flag = None |
| 76 | rabbit_port: int = 5672 |
| 77 | rabbit_host: str = 'localhost' |
| 78 | rabbit_user_name: str = 'admin' |
| 79 | rabbit_pass: str = 'admin' |
| 80 | |
| 81 | def set_static_storage_option(self, option_number): |
| 82 | if option_number == 4: |
| 83 | self.static_storage_provider = 'gcp' |
| 84 | elif option_number == 2: |
| 85 | self.static_storage_provider = 'aws' |
| 86 | elif option_number == 3: |
| 87 | self.static_storage_provider = 'azure' |
| 88 | elif option_number == 1: |
| 89 | self.static_storage_provider = 'minio' |
| 90 | |
| 91 | def set_gcp_credentials(self): |
| 92 | is_valid = False |
| 93 | self.use_docker_minio = False |
| 94 | # Ask For Service Account |
| 95 | while not is_valid: |
| 96 | f = None |
| 97 | service_account_path = bcolors.inputcolor( |
| 98 | 'Please provide the Full Path of your GCP service account JSON file: ') |
| 99 | try: |
| 100 | if not service_account_path.endswith('.json'): |
| 101 | bcolors.printcolor('ERROR: Path must be a JSON file', bcolors.WARNING) |
| 102 | is_valid = False |
| 103 | continue |
| 104 | f = open(service_account_path) |
| 105 | # Do something with the file |
| 106 | self.gcp_credentials_path = service_account_path |
| 107 | is_valid = True |
| 108 | except IOError: |
| 109 | bcolors.printcolor( |
| 110 | "Invalid path, make sure your are writing the full path to your GCP credentials JSON file", |
| 111 | bcolors.FAIL) |
| 112 | finally: |
| 113 | if f: |
| 114 | f.close() |
| 115 | # Ask for bucket name |