Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@

{"name": "connect to bigquery client", "function": "connect_to_bigquery_client", "screenshot": "none" },
{"name": "execute bigquery query", "function": "execute_bigquery_query", "screenshot": "none" },

{"name": "connect to google service client", "function": "connect_to_google_service_account", "screenshot": "none" },
{"name": "upload to google storage bucket", "function": "upload_to_google_storage_bucket", "screenshot": "none" },

) # yapf: disable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6505,6 +6505,70 @@ def execute_bigquery_query(data_set):
except:
return CommonUtil.Exception_Handler(sys.exc_info())

@logger
def connect_to_google_service_account(data_set):
"""
data_set:
credentials path | input parameter | path to credentails json file
connect to google service client | common action | client variable name
"""

sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
CommonUtil.ExecLog(sModuleInfo, "Actions involving the Google service account may not function correctly without a virtual environment.", 2)
cred_path = None
client_var_name = None
for left, _, right in data_set:
if left.strip().lower() == 'credentials path':
cred_path = right.strip()
if left.strip().lower() == 'connect to google service client':
client_var_name = right.strip()

try:
from google.cloud import storage
client = storage.Client.from_service_account_json(json_credentials_path=cred_path)
sr.Set_Shared_Variables(client_var_name, client)
return "passed"
except:
CommonUtil.ExecLog(sModuleInfo, "Incorrect Credentails", 3)
return "zeuz_failed"

@logger
def upload_to_google_storage_bucket(data_set):
"""
data_set:
filepath | input parameter | filepath
bucket | input parameter | bucket name
upload to google storage bucket | common action | client variable name
"""

sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
CommonUtil.ExecLog(sModuleInfo, "Actions involving the Google service account may not function correctly without a virtual environment.", 2)
filepath = None
client_var_name = None
bucket = None

for left, _, right in data_set:
if left.strip().lower() == 'filepath':
filepath = right.strip()
if left.strip().lower() == 'upload to google storage bucket':
client_var_name = right.strip()
if left.strip().lower() == 'bucket':
bucket = right.strip()

if None in (filepath,client_var_name,bucket):
CommonUtil.ExecLog(sModuleInfo, "Incorrect Dataset", 3)
return "zeuz_failed"

try:
client = sr.Get_Shared_Variables(client_var_name)
bucket = client.get_bucket(bucket)
blob = bucket.blob(os.path.basename(filepath))
blob.upload_from_filename(filepath)
CommonUtil.ExecLog(sModuleInfo, f'File {filepath} uploaded to {bucket}.')
return "passed"
except:
return CommonUtil.Exception_Handler(sys.exc_info())

@logger
def text_to_speech(data_set):
"""
Expand Down
3 changes: 2 additions & 1 deletion requirements-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ jinja2
pandas
pyperclip
thefuzz
backports-datetime-fromisoformat; python_version < '3.11'
backports-datetime-fromisoformat; python_version < '3.11'
google-cloud-storage
3 changes: 2 additions & 1 deletion requirements-mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ jinja2
pandas
pyperclip
backports-datetime-fromisoformat; python_version < '3.11'
thefuzz
thefuzz
google-cloud-storage
1 change: 1 addition & 0 deletions requirements-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ pandas
pyperclip
backports-datetime-fromisoformat; python_version < '3.11'
thefuzz
google-cloud-storage
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ configobj
boto3
pandas
pyperclip
backports-datetime-fromisoformat; python_version < '3.11'
backports-datetime-fromisoformat; python_version < '3.11'
google-cloud-storage