fix base dir

This commit is contained in:
copper 2022-05-31 13:04:34 +08:00
parent 28253c05b5
commit 4a6533e1c9
4 changed files with 21 additions and 9 deletions

7
ECD.py
View File

@ -1,7 +1,12 @@
import os
os.environ['PROJ_LIB'] = os.path.join(os.path.dirname(__file__), 'share/proj')
os.environ['GDAL_DATA'] = os.path.join(os.path.dirname(__file__), 'share')
os.environ['ECD_BASEDIR'] = os.path.dirname(__file__)
BASE_DIR = os.path.dirname(__file__)
from rscder import MulStart
import logging
logging.basicConfig(level=logging.INFO, filename='log.txt', filemode='w', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.basicConfig(level=logging.INFO, filename=os.path.join(BASE_DIR, 'log.txt'), filemode='a', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
if __name__ == '__main__':

View File

@ -1,4 +1,5 @@
nuitka ECD.py --standalone --plugin-enable=qt-plugins --plugin-enable=numpy --show-progress --include-package=qgis --plugin-enable=pylint-warnings --output-dir=package --windows-icon-from-ico=logo.ico --no-pyi-file --follow-import-to=rscder --include-package=osgeo --include-package=PyQtAds
nuitka ECD.py --standalone --plugin-enable=pyqt5 --include-qt-plugins=sensible,styles --plugin-enable=numpy --show-progress --include-package=qgis --output-dir=package --windows-icon-from-ico=logo.ico
xcopy /Y icons/* package/ECD.dist/
@REM nuitka keygen.py --standalone --plugin-enable=qt-plugins --plugin-enable=numpy --show-progress --plugin-enable=pylint-warnings --output-dir=package --windows-disable-console --windows-icon-from-ico=logo.ico --no-pyi-file

View File

@ -2,3 +2,7 @@
2022-05-28 21:40:04,316 - root - INFO - remain_days: 186
2022-05-28 21:40:05,077 - root - INFO - lic data:2022-12-01 00:00:00
2022-05-28 21:40:05,077 - root - INFO - remain_days: 186
2022-05-31 13:03:21,977 - root - INFO - lic data:2022-12-01 00:00:00
2022-05-31 13:03:21,997 - root - INFO - remain_days: 183
2022-05-31 13:03:23,512 - root - INFO - lic data:2022-12-01 00:00:00
2022-05-31 13:03:23,512 - root - INFO - remain_days: 183

View File

@ -4,7 +4,7 @@ from typing import Tuple
from PyQt5.QtCore import QSettings
from rscder.utils.license import LicenseHelper
import yaml
BASE_DIR = os.environ['ECD_BASEDIR']
class Settings(QSettings):
def __init__(self, key):
@ -23,7 +23,7 @@ class Settings(QSettings):
@property
def root(self):
_r = './plugins'
_r = os.path.join(BASE_DIR, '/plugins')
if not os.path.exists(_r):
os.makedirs(_r)
return _r
@ -105,10 +105,11 @@ class Settings(QSettings):
@property
def end_date(self):
if not os.path.exists('lic/license.lic'):
lic_path = os.path.join(BASE_DIR, 'lic', 'license.lic')
if not os.path.exists(lic_path):
return datetime.now()
with open('lic/license.lic', 'r') as f:
with open(lic_path, 'r') as f:
lic = f.read()[::-1]
lic_helper = LicenseHelper()
@ -124,10 +125,11 @@ class Settings(QSettings):
@property
def license(self):
if not os.path.exists('lic/license.lic'):
lic_path =os.path.join(BASE_DIR, 'lic', 'license.lic')
if not os.path.join(lic_path):
return False
with open('lic/license.lic', 'r') as f:
with open(lic_path, 'r') as f:
lic = f.read()[::-1]
lic_helper = LicenseHelper()
@ -144,7 +146,7 @@ class Settings(QSettings):
@property
def root(self):
with Settings(Settings.General.PRE) as s:
return s.value('root', './')
return s.value('root', BASE_DIR)
@property
def auto_save(self):