add loader and versioning

This commit is contained in:
Alex Bezdieniezhnykh
2025-06-10 08:53:57 +03:00
parent 7750025631
commit dcd0fabc1f
31 changed files with 284 additions and 123 deletions
+2 -1
View File
@@ -143,8 +143,9 @@ cdef class ApiClient:
if self.cdn_manager.download(folder, big_part):
with open(path.join(<str> folder, big_part), 'rb') as binary_file:
encrypted_bytes_big = binary_file.read()
# return encrypted_bytes_big
else:
return None
raise Exception(f'Cannot download file {folder}\\{big_part} from CDN!')
cdef load_big_small_resource(self, str resource_name, str folder):
cdef str big_part = f'{resource_name}.big'
+13 -1
View File
@@ -8,6 +8,7 @@ echo remove dist folder:
if exist dist rmdir dist /s /q
if exist build rmdir build /s /q
echo install python and dependencies
if not exist venv (
python -m venv venv
@@ -39,4 +40,15 @@ venv\Scripts\pyinstaller --name=azaion-loader ^
--hidden-import credentials ^
--hidden-import api_client ^
--hidden-import hardware_service ^
start.py
start.py
robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "security.cp312-win_amd64.pyd" "cdn_manager.cp312-win_amd64.pyd"
robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "credentials.cp312-win_amd64.pyd" "api_client.cp312-win_amd64.pyd"
robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "hardware_service.cp312-win_amd64.pyd" "user.cp312-win_amd64.pyd"
robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "main_loader.cp312-win_amd64.pyd"
robocopy "dist\azaion-loader\_internal" "..\dist-dlls\_internal" /E
robocopy "dist\azaion-loader" "..\dist-azaion" "azaion-loader.exe" /E
cd /d %CURRENT_DIR%
+4 -1
View File
@@ -1,4 +1,6 @@
import io
import os
import boto3
@@ -33,8 +35,9 @@ cdef class CDNManager:
cdef download(self, str folder, str filename):
try:
os.makedirs(folder, exist_ok=True)
self.download_client.download_file(folder, filename, f'{folder}\\{filename}')
print(f'downloaded {filename} from the {folder} to current folder')
print(f'downloaded {filename} from the {folder}')
return True
except Exception as e:
print(e)
@@ -55,6 +55,9 @@ cdef class CommandProcessor:
data = UploadFileData.from_msgpack(command.data)
file_bytes = self.api_client.upload_big_small_resource(data.resource, data.filename, data.folder)
self.remote_handler.send(command.client_id, RemoteCommand(CommandType.OK).serialize())
elif command.command_type == CommandType.EXIT:
t = Thread(target=self.stop) # non-block worker:
t.start()
else:
pass
except Exception as e:
+5 -5
View File
@@ -3,16 +3,16 @@ from Cython.Build import cythonize
extensions = [
Extension('constants', ['constants.pyx']),
Extension('credentials', ['credentials.pyx']),
Extension('file_data', ['file_data.pyx']),
Extension('hardware_service', ['hardware_service.pyx'], extra_compile_args=["-g"], extra_link_args=["-g"]),
Extension('security', ['security.pyx']),
Extension('remote_command', ['remote_command.pyx']),
Extension('remote_command_handler', ['remote_command_handler.pyx']),
Extension('credentials', ['credentials.pyx']),
Extension('hardware_service', ['hardware_service.pyx'], extra_compile_args=["-g"], extra_link_args=["-g"]),
Extension('security', ['security.pyx']),
Extension('user', ['user.pyx']),
Extension('cdn_manager', ['cdn_manager.pyx']),
Extension('api_client', ['api_client.pyx']),
Extension('main', ['main.pyx']),
Extension('main_loader', ['main_loader.pyx']),
]
setup(
@@ -21,7 +21,7 @@ setup(
extensions,
compiler_directives={
"language_level": 3,
"emit_code_comments" : False,
"emit_code_comments": False,
"binding": True,
'boundscheck': False,
'wraparound': False
+1 -1
View File
@@ -1,4 +1,4 @@
from main import CommandProcessor
from main_loader import CommandProcessor
import argparse