Fix py2app (#69)

* Initial commit of py2app code

* Use environment variable RESOURCE_PATH when running as a bundle

* Move config files to system config location
This commit is contained in:
2023-12-16 22:20:24 -06:00
committed by GitHub
parent 525fd99a58
commit f663430984
28 changed files with 93 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
import logging
import os
import platform
import shutil
import socket
import subprocess
from datetime import datetime
@@ -127,15 +128,24 @@ def current_system_cpu():
def resources_dir():
resources_directory = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
'resources')
return resources_directory
resource_environment_path = os.environ.get('RESOURCEPATH', None)
if resource_environment_path: # running inside resource bundle
return os.path.join(resource_environment_path, 'resources')
else:
return os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'resources')
def config_dir():
config_directory = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
'config')
return config_directory
def copy_directory_contents(src_dir, dst_dir):
"""
Copy the contents of the source directory (src_dir) to the destination directory (dst_dir).
"""
for item in os.listdir(src_dir):
src_path = os.path.join(src_dir, item)
dst_path = os.path.join(dst_dir, item)
if os.path.isdir(src_path):
shutil.copytree(src_path, dst_path, dirs_exist_ok=True)
else:
shutil.copy2(src_path, dst_path)
def is_localhost(comparison_hostname):