# coding=utf-8 import path from utils.custom_logging import make_logger from src.meta.meta_property import MetaProperty logger = make_logger(__name__) class ConfigValues: @MetaProperty(None, str) def saved_games_path(self, value: str): p = path.Path(value) if not p.exists(): raise FileNotFoundError('path does not exist: {}'.format( p.abspath())) elif not p.isdir(): raise TypeError('path is not a directory: {}'.format(p.abspath())) return str(p.abspath()) @MetaProperty(None, str) def single_miz_output_folder(self, value: str): p = path.Path(value) if not p.exists(): return None elif not p.isdir(): return None return str(p.abspath()) @MetaProperty(None, str)
elif os.environ.get('APPVEYOR'): __version__ = loads( subprocess.check_output([ r'C:\ProgramData\chocolatey\bin\gitversion.exe' ]).decode().rstrip()).get('FullSemVer') else: # This is a potential security breach, but I'm leaving it as is as it should only be running scripted __version__ = loads( subprocess.check_output(['gitversion' ]).decode().rstrip()).get('FullSemVer') __guid__ = '4ae6dbb7-5b26-28c6-b797-2272f5a074f3' __appname__ = 'TEMP' logger = make_logger(__name__, ch_level=INFO) def find_latest_trmt(folder: Path or str): return natsorted( [Path(f).abspath() for f in Path(folder).listdir('TRMT_*.miz')]).pop() def check_cert(): logger.info('certificate: checking') import certifi import os from utils.custom_path import Path cacert = Path(certifi.where()) # noinspection SpellCheckingInspection
# coding=utf-8 """ Nope """ from src.miz.mission import Group from utils.custom_logging import make_logger, Logged LOGGER = make_logger('flights') class Flights(Logged): def __init__(self): super().__init__() self.d = {} def add_flight(self, flight): if not isinstance(flight, Flight): raise Exception('TODO') if flight.id in self.d.keys(): raise Exception('TODO') self.d[flight.id] = flight def remove_flight(self, flight): if not isinstance(flight, Flight): raise Exception('TODO') if flight.id not in self.d.keys(): raise Exception('TODO') del self.d[flight.id] def populate_from_miz(self, miz): print(miz.mission)
# coding=utf-8 if __name__ == '__main__': """Setup logging""" from utils.custom_logging import make_logger # noinspection PyProtectedMember from src.global_ import PATH_LOG_FILE logger = make_logger(__name__, log_file_path=PATH_LOG_FILE) """Say hello !""" from src.__version__ import __version__ logger.info(__version__) """Init config""" # noinspection PyUnresolvedReferences from src.cfg.cfg import Config """Init Sentry""" # noinspection PyUnresolvedReferences from src.sentry import SENTRY from utils.threadpool import register_sentry register_sentry(SENTRY) SENTRY.register_context('config', Config()) """Intercept SIGINT""" import signal as core_sig from utils import nice_exit # Intercept OS signals to trigger a nice exit core_sig.signal(core_sig.SIGINT, nice_exit) import src.emft try: src.emft.main() except SystemExit as e: logger.info('caught SystemExit, bye bye !')
# coding=utf-8 """ Easy to use validator for different values """ from os.path import exists from re import fullmatch as re_full_match from utils.custom_logging import make_logger LOGGER = make_logger(__name__) class ValidatorError(Exception): """ Base Error for the Validator class """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) class Validator: """ Validates many kind of values against pre-defined conditions, raises Exception and logs errors """ def __init__(self, *, _type=None, _instance=None, _min=None, _max=None, _regex=None,
# coding=utf-8 from os import walk, listdir from os.path import abspath, isdir, join, basename from utils.custom_logging import make_logger from src.global_ import ENCODING LOGGER = make_logger('skins') available_skins = { 'A-10A': set(), 'A-10C': set(), 'F-15C': set(), 'FW-190D9': set(), 'ka-50': set(), 'L-39ZA': set(), 'mi-8mt': set(), 'mig-29a': set(), 'mig-29s': set(), 'P-51D': set(), 'su-25': set(), 'su-25t': set(), 'su-27': set(), 'su-33': set(), 'TF-51D': set(), } def gather_in_folders(list_of_folders):