Assets folder is part of startup
This commit is contained in:
parent
9358106d74
commit
64d15ddd86
6 changed files with 109 additions and 2 deletions
|
|
@ -8,6 +8,12 @@ class Constants:
|
|||
|
||||
DB_VERSION_THIS_APP_WANTS = 1
|
||||
|
||||
# Fallback for development (running outside AppImage)
|
||||
fallback_non_appimage = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# appimage home
|
||||
APPDIR_HOME: Final[str] = os.environ.get('APPDIR', fallback_non_appimage)
|
||||
|
||||
# ticketing group:
|
||||
TICKET_API_BASE_URL: Final[str] = os.environ.get(
|
||||
"TICKET_API_BASE_URL", "https://ticket.hydraveil.net"
|
||||
|
|
|
|||
54
core/assets/yaml_mappings/locations.yaml
Normal file
54
core/assets/yaml_mappings/locations.yaml
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
fields:
|
||||
- name: country_code
|
||||
path: ['country', 'code']
|
||||
required: true
|
||||
|
||||
- name: code # this is city code
|
||||
path: ['code']
|
||||
required: true
|
||||
|
||||
- name: id
|
||||
path: ['id']
|
||||
|
||||
- name: country_name
|
||||
path: ['country', 'name']
|
||||
|
||||
- name: name # this is CITY name
|
||||
path: ['name']
|
||||
|
||||
- name: time_zone
|
||||
path: ['time_zone', 'code']
|
||||
|
||||
- name: operator_id
|
||||
path: ['operator_id']
|
||||
required: true
|
||||
|
||||
- name: provider_name
|
||||
path: ['provider', 'name']
|
||||
|
||||
- name: is_proxy_capable
|
||||
path: ['is_proxy_capable']
|
||||
|
||||
- name: is_wireguard_capable
|
||||
path: ['is_wireguard_capable']
|
||||
required: true
|
||||
|
||||
- name: is_hysteria2_capable
|
||||
path: ['is_hysteria2_capable']
|
||||
|
||||
- name: is_vless_capable
|
||||
path: ['is_vless_capable']
|
||||
|
||||
|
||||
# original version:
|
||||
# locations.append((
|
||||
# location['country']['code'],
|
||||
# location['code'],
|
||||
# location['id'],
|
||||
# location['country']['name'],
|
||||
# location['name'],
|
||||
# location['time_zone']['code'],
|
||||
# location['operator_id'],
|
||||
# location['provider']['name'],
|
||||
# location['is_proxy_capable'],
|
||||
# location['is_wireguard_capable']))
|
||||
8
core/assets/yaml_mappings/mapping_one.yaml
Normal file
8
core/assets/yaml_mappings/mapping_one.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fields:
|
||||
- name: group_a_code
|
||||
path: ['group_a', 'code']
|
||||
- name: code
|
||||
path: ['code']
|
||||
- name: id
|
||||
path: ['id']
|
||||
required: true
|
||||
19
core/assets/yaml_mappings/operators.yaml
Normal file
19
core/assets/yaml_mappings/operators.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
fields:
|
||||
- name: id
|
||||
path: ['id']
|
||||
required: true
|
||||
|
||||
- name: name
|
||||
path: ['name']
|
||||
|
||||
- name: public_key # this is ed25519
|
||||
path: ['public_key']
|
||||
|
||||
- name: nostr_public_key
|
||||
path: ['nostr_public_key']
|
||||
|
||||
- name: nostr_profile_reference
|
||||
path: ['nostr_profile_reference']
|
||||
|
||||
- name: nostr_attestation_event_reference
|
||||
path: ['nostr_attestation', 'event_reference']
|
||||
20
core/services/helpers/manage_assets.py
Normal file
20
core/services/helpers/manage_assets.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import shutil
|
||||
import os
|
||||
from core.Constants import Constants
|
||||
|
||||
def assets_folder_setup():
|
||||
initial_appimage_assets = f"{Constants.APPDIR_HOME}/assets"
|
||||
current_assets_folder = f"{Constants.HV_DATA_HOME}/assets"
|
||||
|
||||
print(f"initial_appimage_assets is {initial_appimage_assets}")
|
||||
|
||||
# Step 1: Check if folder exists
|
||||
if os.path.exists(current_assets_folder):
|
||||
return True
|
||||
else:
|
||||
try:
|
||||
# Step 2: Copy over from initial AppImage if not:
|
||||
shutil.copytree(initial_appimage_assets, current_assets_folder)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
|
@ -35,9 +35,9 @@ def sync_one_orm_model(
|
|||
new_data = api_result.data
|
||||
|
||||
# prep data (denormalize)
|
||||
# parent_directory = get_parent_directory()
|
||||
current_assets_folder = f"{Constants.HV_DATA_HOME}/assets"
|
||||
yaml_filename = f"{which_endpoint}.yaml"
|
||||
full_yaml_path = f"assets/yaml_mappings/{yaml_filename}"
|
||||
full_yaml_path = f"{current_assets_folder}/yaml_mappings/{yaml_filename}"
|
||||
|
||||
denormalized_data = denormalize(new_data, str(full_yaml_path))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue