Skip to content

Commit

Permalink
updating automation #366 from Jurgen
Browse files Browse the repository at this point in the history
  • Loading branch information
mworion committed Aug 18, 2024
1 parent cbcedb5 commit 10981a2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 47 deletions.
1 change: 1 addition & 0 deletions mw4/gui/mainWmixin/tabMinorPlanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def loadMPCDataFromSourceURLs(self):

url = self.mpcPrefix + self.minorPlanetSourceURLs[source]
dest = self.app.mwGlob['dataDir'] + '/' + self.minorPlanetSourceURLs[source]
dest = os.path.normpath(dest)

isOnline = self.ui.isOnline.isChecked()
if isOnline:
Expand Down
7 changes: 4 additions & 3 deletions mw4/gui/mainWmixin/tabTools_IERSTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
###########################################################
# standard libraries
import os

# external packages
from PyQt5.QtWidgets import QListView
Expand Down Expand Up @@ -137,7 +138,7 @@ def startProgEarthRotationDataToMount(self):

source = 'finals.data'
url = urlMain + source
dest = self.app.mwGlob['dataDir'] + '/' + source
dest = os.path.normpath(self.app.mwGlob['dataDir'] + '/' + source)
self.msg.emit(1, 'IERS', 'Download', f'{source}')
DownloadPopup(self, url=url, dest=dest, unzip=False,
callBack=self.progEarthRotationData)
Expand All @@ -156,13 +157,13 @@ def loadTimeDataFromSourceURLs(self):

source = 'finals2000A.all'
url = urlMain + source
dest = self.app.mwGlob['dataDir'] + '/' + source
dest = os.path.normpath(self.app.mwGlob['dataDir'] + '/' + source)
self.msg.emit(1, 'IERS', 'Download', f'{source}')
DownloadPopup(self, url=url, dest=dest, unzip=False)

source = 'finals.data'
url = urlMain + source
dest = self.app.mwGlob['dataDir'] + '/' + source
dest = os.path.normpath(self.app.mwGlob['dataDir'] + '/' + source)
self.msg.emit(1, 'IERS', 'Download', f'{source}')
DownloadPopup(self, url=url, dest=dest, unzip=False)
return True
12 changes: 6 additions & 6 deletions mw4/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ def setupWorkDirs(mwGlob):
"""
mwGlob['modeldata'] = '4.0'
mwGlob['workDir'] = os.getcwd()
mwGlob['configDir'] = mwGlob['workDir'] + '/config'
mwGlob['dataDir'] = mwGlob['workDir'] + '/data'
mwGlob['imageDir'] = mwGlob['workDir'] + '/image'
mwGlob['tempDir'] = mwGlob['workDir'] + '/temp'
mwGlob['modelDir'] = mwGlob['workDir'] + '/model'
mwGlob['measureDir'] = mwGlob['workDir'] + '/measure'
mwGlob['configDir'] = os.path.normpath(mwGlob['workDir'] + '/config')
mwGlob['dataDir'] = os.path.normpath(mwGlob['workDir'] + '/data')
mwGlob['imageDir'] = os.path.normpath(mwGlob['workDir'] + '/image')
mwGlob['tempDir'] = os.path.normpath(mwGlob['workDir'] + '/temp')
mwGlob['modelDir'] = os.path.normpath(mwGlob['workDir'] + '/model')
mwGlob['measureDir'] = os.path.normpath(mwGlob['workDir'] + '/measure')

for dirPath in ['workDir', 'configDir', 'imageDir', 'dataDir',
'tempDir', 'modelDir', 'measureDir']:
Expand Down
34 changes: 12 additions & 22 deletions mw4/logic/automation/automateWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def getAppSettings(self, winKey):
val = self.findAppSetup(winKey)
self.available = val[0]
self.name = val[1]
self.installPath = val[2]
self.updaterApp = val[3]
self.installPath = os.path.normpath(val[2])
self.updaterApp = os.path.normpath(val[2] + '/' + val[3])
except Exception as e:
self.available = False
self.installPath = ''
Expand Down Expand Up @@ -264,16 +264,16 @@ def startUpdater(self):
Timings.slow()

try:
self.updater.start(self.installPath + self.updaterApp)
self.updater.start(self.updaterApp)
except AppStartError as e:
e = f'{e}'.replace('\n', '')
self.log.error(f'Start error: [{e}]')
self.log.error(f'Path: [{self.installPath}{self.updaterApp}]')
self.log.error(f'Path: [{self.updaterApp}]')
return False
except Exception as e:
e = f'{e}'.replace('\n', '')
self.log.error(f'General error: [{e}]')
self.log.error(f'Path: [{self.installPath}{self.updaterApp}]')
self.log.error(f'Path: [{self.updaterApp}]')
return False
else:
suc = self.checkFloatingPointErrorWindow()
Expand Down Expand Up @@ -314,8 +314,7 @@ def prepareUpdater(self):
return False

self.updater = None
os.chdir(os.path.dirname(self.installPath))

os.chdir(self.installPath)
suc = self.startUpdater()
if not suc:
os.chdir(self.actualWorkDir)
Expand Down Expand Up @@ -417,7 +416,6 @@ def uploadMPCDataCommands(self, comets=False):
:return:
"""
win = self.updater['10 micron control box update']
self.log.debug(f'Updater win: [{self.getIdentifiers(win)}]')

if comets:
controls.ButtonWrapper(win['Orbital parameters of comets']).check_by_click()
Expand All @@ -429,17 +427,15 @@ def uploadMPCDataCommands(self, comets=False):
popup = self.updater['Asteroid orbits']

self.moveWindow(popup, 30, 30)
self.log.debug(f'Updater popup: [{self.getIdentifiers(popup)}]')

popup['MPC file'].click()
popup['MPC file'].wait('ready')

fTitle = self.findFileDialogWindow('en')
fDialog = self.updater[fTitle]
self.moveWindow(fDialog, 50, 50)
self.log.debug(f'Updater filedialog: [{self.getIdentifiers(fDialog)}]')

text = self.installPath + 'minorPlanets.mpc'
text = 'minorPlanets.mpc'
self.dialogInput(fDialog, text)
self.dialogInput(fDialog, '~')
popup['Close'].click()
Expand Down Expand Up @@ -467,37 +463,33 @@ def uploadEarthRotationDataCommands(self):
:return:
"""
win = self.updater['10 micron control box update']
self.log.debug(f'Updater win: [{self.getIdentifiers(win)}]')

controls.ButtonWrapper(win['UTC / Earth rotation data']).check_by_click()
win['Edit...1'].click()
popup = self.updater['UTC / Earth rotation data']
self.moveWindow(popup, 30, 30)
self.log.debug(f'Updater popup: [{self.getIdentifiers(popup)}]')

popup['Import files...'].click()
popup['Import files...'].wait('ready')

fTitle = self.findFileDialogWindow('finals')
fDialog = self.updater[fTitle]
self.moveWindow(fDialog, 50, 50)
self.log.debug(f'Finals filedialog: [{self.getIdentifiers(fDialog)}]')

text = self.installPath + self.UTC_1_FILE
text =self.UTC_1_FILE
self.dialogInput(fDialog, text)
self.dialogInput(fDialog, '~')

popup['Import files...'].wait('ready')

if self.updaterApp == 'tenmicron_v2.exe':
text = self.installPath + self.UTC_2a_FILE
if os.path.basename(self.updaterApp) == 'tenmicron_v2.exe':
text = self.UTC_2a_FILE
else:
text = self.installPath + self.UTC_2b_FILE
text = self.UTC_2b_FILE

fTitle = self.findFileDialogWindow('tai-utc')
fDialog = self.updater[fTitle]
self.moveWindow(fDialog, 50, 50)
self.log.debug(f'Leap filedialog: [{self.getIdentifiers(fDialog)}]')

self.dialogInput(fDialog, text)
self.dialogInput(fDialog, '~')
Expand Down Expand Up @@ -534,17 +526,15 @@ def uploadTLEDataCommands(self):
win['Edit...2'].click()
popup = self.updater['Satellites orbits']
self.moveWindow(popup, 30, 30)
self.log.debug(f'Updater popup: [{self.getIdentifiers(popup)}]')

popup['Load from file'].click()
popup['Load from file'].wait('ready')

fTitle = self.findFileDialogWindow('en')
fDialog = self.updater[fTitle]
self.moveWindow(fDialog, 50, 50)
self.log.debug(f'Updater filedialog: [{self.getIdentifiers(fDialog)}]')

text = self.installPath + 'satellites.tle'
text = 'satellites.tle'
self.dialogInput(fDialog, text)
self.dialogInput(fDialog, '~')

Expand Down
29 changes: 14 additions & 15 deletions mw4/logic/databaseProcessing/dataWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,26 @@ def writeEarthRotationData(self, installPath='', updaterApp=''):
:param updaterApp:
:return:
"""
sourceDir = self.app.mwGlob['dataDir'] + '/'
destDir = installPath + '/'
sourceDir = self.app.mwGlob['dataDir']
destDir = installPath

if destDir == sourceDir:
return False
if not os.path.isfile(sourceDir + 'CDFLeapSeconds.txt'):
if not os.path.isfile(sourceDir + '/CDFLeapSeconds.txt'):
return False
if not os.path.isfile(sourceDir + 'finals.data'):
if not os.path.isfile(sourceDir + '/finals.data'):
return False
if not os.path.isfile(sourceDir + 'tai-utc.dat'):
if not os.path.isfile(sourceDir + '/tai-utc.dat'):
return False

if updaterApp == 'tenmicron_v2.exe':
shutil.copy(os.path.normpath(sourceDir + 'CDFLeapSeconds.txt'),
os.path.normpath(destDir + 'CDFLeapSeconds.txt'))
if os.path.basename(updaterApp) == 'tenmicron_v2.exe':
shutil.copy(os.path.normpath(sourceDir + '/CDFLeapSeconds.txt'),
os.path.normpath(destDir + '/CDFLeapSeconds.txt'))
else:
shutil.copy(os.path.normpath(sourceDir + 'tai-utc.dat'),
os.path.normpath(destDir + 'tai-utc.dat'))
shutil.copy(os.path.normpath(sourceDir + '/tai-utc.dat'))

shutil.copy(os.path.normpath(sourceDir + 'finals.data'),
os.path.normpath(destDir + 'finals.data'))
shutil.copy(os.path.normpath(sourceDir + '/finals.data'),
os.path.normpath(destDir + '/finals.data'))
return True

@staticmethod
Expand All @@ -83,7 +82,7 @@ def writeCometMPC(datas=None, installPath=''):
if not isinstance(datas, list):
return False

dest = installPath + '/minorPlanets.mpc'
dest = os.path.normpath(installPath + '/minorPlanets.mpc')

with open(dest, 'w') as f:
for data in datas:
Expand Down Expand Up @@ -279,7 +278,7 @@ def writeAsteroidMPC(self, datas=None, installPath=''):
if not isinstance(datas, list):
return False

dest = installPath + '/minorPlanets.mpc'
dest = os.path.normpath(installPath + '/minorPlanets.mpc')

with open(dest, 'w') as f:
for data in datas:
Expand Down Expand Up @@ -380,7 +379,7 @@ def writeSatelliteTLE(datas=None, installPath=''):
if not isinstance(datas, dict):
return False

dest = installPath + '/satellites.tle'
dest = os.path.normpath(installPath + '/satellites.tle')

with open(dest, 'w') as f:
for name in datas:
Expand Down
3 changes: 2 additions & 1 deletion mw4/logic/environment/seeingWeather.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def workerGetSeeingData(self, url):
data = data.json()
self.log.trace(data)

with open(self.app.mwGlob['dataDir'] + '/meteoblue.data', 'w+') as f:
dataDir = os.path.normpath(self.app.mwGlob['dataDir'] + '/meteoblue.data')
with open(dataDir, 'w+') as f:
json.dump(data, f, indent=4)
return True

Expand Down

0 comments on commit 10981a2

Please sign in to comment.