-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from lexara-prime-ai/dev
Dev
- Loading branch information
Showing
5 changed files
with
182 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
.terraform | ||
*.tfstate | ||
.env | ||
service_account.json | ||
# Added by cargo | ||
|
||
/target | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
class CONSTANTS: | ||
FILE_PATH = './tableau/data' | ||
FILE_NAME = 'wspr_spots.csv' | ||
FILE_PATH = "./tableau/data" | ||
FILE_NAME = "wspr_spot_data.csv" | ||
FULL_PATH = FILE_PATH + "/" + FILE_NAME | ||
SCOPES = ["https://www.googleapis.com/auth/drive"] | ||
SERVICE_ACCOUNT_FILE = "service_account.json" | ||
PARENT_FOLDER_ID = "1uVnscmoxu91XT1LMnZoOOn3iCTirlEII" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import constants | ||
from google.oauth2 import service_account | ||
from googleapiclient.discovery import build | ||
|
||
|
||
def authenticate(): | ||
try: | ||
print("\n[Authenticating] <wspr_cdk> service user...") | ||
|
||
credentials = service_account.Credentials.from_service_account_file( | ||
constants.SERVICE_ACCOUNT_FILE, scopes=constants.SCOPES | ||
) | ||
|
||
return credentials | ||
except Exception as e: | ||
print("\n[ERROR] -> Failed to [Authenticate] <wspr_cdk> service user: \n", e) | ||
|
||
|
||
def upload_to_drive(file_path): | ||
try: | ||
credentials = authenticate() | ||
service = build("drive", "v3", credentials=credentials) | ||
|
||
file_metadata = { | ||
"name": "wspr_spot_data", | ||
"parents": [constants.PARENT_FOLDER_ID], | ||
} | ||
|
||
print("[Uploading] file to Google Drive...\n") | ||
|
||
service.files().create(body=file_metadata, media_body=file_path).execute() | ||
except Exception as e: | ||
print("\n[ERROR] -> Failed to upload to Google Drive: \n", e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Update the package list | ||
echo "Updating package list..." | ||
sudo apt-get update | ||
|
||
# Install pip if it is not already installed | ||
echo "Checking for pip..." | ||
if ! command -v pip &> /dev/null; then | ||
echo "pip not found. Installing pip..." | ||
sudo apt-get install -y python3-pip | ||
# Check if pip is installed. | ||
if ! command -v pip &>/dev/null; then | ||
echo "pip not found. Installing pip..." | ||
sudo apt-get install -y python3-pip | ||
else | ||
echo "pip is already installed." | ||
echo "pip is already installed." | ||
fi | ||
|
||
# Install mkdocs | ||
echo "Installing dependencies [mkdocs], [tableauhyperapi]..." | ||
pip install mkdocs | ||
pip install tableauhyperapi | ||
# Modules that will be installed/upgraded. | ||
modules=("mkdocs" "tableauhyperapi" "google-api-python-client" "google-auth-httplib2" "google-auth-oauthlib") | ||
|
||
# Verify installation | ||
echo "Verifying mkdocs installation..." | ||
if python3 -c "import mkdocs" &> /dev/null; then | ||
echo "mkdocs successfully installed." | ||
else | ||
echo "Failed to install mkdocs." | ||
fi | ||
echo "Installing dependencies: ${modules[*]}..." | ||
pip install "${modules[@]}" --upgrade | ||
|
||
echo "Verifying tableauhyperapi installation..." | ||
if python3 -c "import tableauhyperapi" &> /dev/null; then | ||
echo "tableauhyperapi successfully installed." | ||
else | ||
echo "Failed to install tableauhyperapi." | ||
fi | ||
# Verify module installation. | ||
verify_installation() { | ||
local module=$1 | ||
local import_name=$2 | ||
echo "Verifying ${module} installation..." | ||
if python3 -c "import ${import_name}" &>/dev/null; then | ||
echo "${module} successfully installed." | ||
else | ||
echo "Failed to install ${module}." | ||
fi | ||
} | ||
|
||
# The following dictionary contains module to import name mappings. | ||
declare -A module_import_map=( | ||
["mkdocs"]="mkdocs" | ||
["tableauhyperapi"]="tableauhyperapi" | ||
["google-api-python-client"]="googleapiclient" | ||
["google-auth-httplib2"]="google_auth_httplib2" | ||
["google-auth-oauthlib"]="google_auth_oauthlib" | ||
) | ||
|
||
# Verify installation of each module. | ||
for module in "${!module_import_map[@]}"; do | ||
verify_installation "${module}" "${module_import_map[${module}]}" | ||
done | ||
|
||
|
||
# An array modules contains the names of all the modules to be installed. | ||
# The pip install command installs or upgrades all the modules listed in the array. | ||
# A dictionary module_import_map maps module names to their respective import names. | ||
# The verify_installation function takes a module name and its import name as arguments, checks if the module can be imported, and prints the appropriate message. | ||
# The script iterates over the module_import_map dictionary to verify the installation of each module using the verify_installation function. |