Skip to content

Commit 87ea406

Browse files
committed
Fix for ParallelGamit and changes in Cnn.insert
1 parent 94b3e4e commit 87ea406

File tree

4 files changed

+53
-17
lines changed

4 files changed

+53
-17
lines changed

com/ParallelGamit.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def purge_solutions(JobServer, args, dates, GamitConfig):
187187

188188
pbar = tqdm(total=len(dates), ncols=80, desc=' -- Purge progress', disable=None)
189189

190-
modules = ('pgamit.pyDate', 'pgamit.dbConnection', 'os', 'glob')
190+
modules = ('pgamit.pyDate', 'pgamit.dbConnection', 'os', 'glob', 'shutil')
191191

192192
JobServer.create_cluster(purge_solution, progress_bar=pbar, modules=modules)
193193

@@ -462,14 +462,21 @@ def generate_kml(dates, sessions, GamitConfig):
462462
if not os.path.exists('production'):
463463
os.makedirs('production')
464464

465+
# to fix the issue from simple kml
466+
# AttributeError: module 'cgi' has no attribute 'escape'
467+
# see: https://github.com/tjlang/simplekml/issues/38
468+
import cgi
469+
import html
470+
cgi.escape = html.escape
471+
465472
kml.savekmz('production/' + GamitConfig.NetworkConfig.network_id.lower() + '.kmz')
466473

467474

468475
def ParseZTD(project, dates, Sessions, GamitConfig, JobServer):
469476

470477
tqdm.write(' >> %s Parsing the tropospheric zenith delays...' % print_datetime())
471478

472-
modules = ('numpy', 'os', 're', 'datetime', 'traceback', 'pgamit.dbConnection')
479+
modules = ('numpy', 'os', 're', 'datetime', 'traceback', 'pgamit.dbConnection', 'pgamit.pyZTD')
473480

474481
pbar = tqdm(total=len(dates), disable=None, desc=' >> Zenith total delay parsing', ncols=100)
475482

@@ -496,7 +503,7 @@ def ExecuteGlobk(cnn, JobServer, GamitConfig, sessions, dates):
496503
% print_datetime())
497504

498505
modules = ('os', 'shutil', 'pgamit.snxParse', 'subprocess', 'platform', 'traceback', 'glob',
499-
'pgamit.dbConnection', 'math', 'datetime', 'pgamit.pyDate')
506+
'pgamit.dbConnection', 'math', 'datetime', 'pgamit.pyDate', 'pgamit.pyGlobkTask')
500507

501508
pbar = tqdm(total=len(dates), disable=None, desc=' >> GLOBK combinations completion', ncols=100)
502509

@@ -681,7 +688,7 @@ def ExecuteGamit(cnn, JobServer, GamitConfig, stations, check_stations, ignore_m
681688
dry_run=False, create_kml=False):
682689

683690
modules = ('pgamit.pyRinex', 'datetime', 'os', 'shutil', 'pgamit.pyProducts', 'subprocess', 're', 'pgamit.pyETM',
684-
'glob', 'platform', 'traceback')
691+
'glob', 'platform', 'traceback', 'pgamit.pyGamitTask')
685692

686693
tqdm.write(' >> %s Creating GAMIT session instances and executing GAMIT, please wait...' % print_datetime())
687694

@@ -727,7 +734,7 @@ def ExecuteGamit(cnn, JobServer, GamitConfig, stations, check_stations, ignore_m
727734
msg = 'Session already processed'
728735
pbar.update()
729736

730-
tqdm.write(' -- %s %s %s %s%02i -> %s' % (print_datetime(),
737+
tqdm.write(' -- %s %s %s %s%03i -> %s' % (print_datetime(),
731738
GamitSession.NetName,
732739
GamitSession.date.yyyyddd(),
733740
GamitSession.org,

pgamit/dbConnection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,12 @@ def rollback_transac(self):
249249
def insert(self, table, **kw):
250250
debug("INSERT: table=%r kw=%r" % (table, kw))
251251

252+
# figure out any extra columns and remove them from the incoming **kw
253+
cols = list(self.get_columns(table).keys())
254+
252255
# assuming fields are passed through kw which are keyword arguments
253-
fields = list(kw.keys())
254-
values = list(kw.values())
256+
fields = [k for k in kw.keys() if k in cols]
257+
values = [v for v, k in zip(kw.values(), kw.keys()) if k in cols]
255258

256259
# form the insert query dynamically
257260
placeholders = ', '.join(['%s'] * len(fields))

pgamit/pyGamitSession.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,4 +442,11 @@ def generate_kml(self):
442442
else:
443443
pt.stylemap = styles_stn
444444

445+
# to fix the issue from simple kml
446+
# AttributeError: module 'cgi' has no attribute 'escape'
447+
# see: https://github.com/tjlang/simplekml/issues/38
448+
import cgi
449+
import html
450+
cgi.escape = html.escape
451+
445452
kml.savekmz(os.path.join(self.solution_pwd, self.DirName) + '.kmz')

pgamit/pyJobServer.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def check_tab_file(tabfile, date):
5353

5454
# start importing the modules needed
5555
try:
56+
print(' >> Testing python imports')
5657
import shutil
5758
import datetime
5859
import time
@@ -62,24 +63,20 @@ def check_tab_file(tabfile, date):
6263
import numpy
6364
import dirsync
6465
# app
65-
from pgamit import pyRinex
6666
from pgamit import dbConnection
67-
from pgamit import pyStationInfo
68-
from pgamit import pyArchiveStruct
69-
from pgamit import pyPPP
7067
from pgamit import pyProducts
7168
from pgamit import pyOptions
72-
from pgamit import Utils
73-
from pgamit import pyOTL
74-
from pgamit import pyETM
7569
from pgamit import pyRunWithRetry
7670
from pgamit import pyDate
7771

72+
print(' -- Done')
73+
7874
except:
7975
return ' -- %s: Problem found while importing modules:\n%s' % (platform.node(), traceback.format_exc())
8076

8177
try:
8278
if len(software_sync) > 0:
79+
print(' >> Syncing directories')
8380
# synchronize directories listed in the src and dst arguments
8481
from dirsync import sync
8582

@@ -95,54 +92,68 @@ def check_tab_file(tabfile, date):
9592
for f in updated:
9693
print(' -- Updated %s' % f)
9794

95+
print(' -- Done')
96+
9897
except:
9998
return ' -- %s: Problem found while synchronizing software:\n%s ' % (platform.node(), traceback.format_exc())
10099

101100
# continue with a test SQL connection
102101
# make sure that the gnss_data.cfg is present
103102
try:
103+
print(' >> Testing database connection')
104104
cnn = dbConnection.Cnn('gnss_data.cfg')
105105

106106
q = cnn.query('SELECT count(*) FROM networks')
107-
107+
print(' -- Done')
108108
except:
109109
return ' -- %s: Problem found while connecting to postgres:\n%s ' % (platform.node(), traceback.format_exc())
110110

111111
# make sure we can create the production folder
112112
try:
113+
print(' >> Testing access to production dir')
113114
test_dir = os.path.join('production/node_test')
114115
if not os.path.exists(test_dir):
115116
os.makedirs(test_dir)
117+
118+
print(' -- Done')
116119
except:
117120
return ' -- %s: Could not create production folder:\n%s ' % (platform.node(), traceback.format_exc())
118121

119122
# test
120123
try:
124+
print(' >> Testing gnss_data.cfg file access')
121125
Config = pyOptions.ReadOptions('gnss_data.cfg')
122-
126+
print(' -- Done')
123127
except:
124128
return ' -- %s: Problem while reading config file and/or testing archive access:\n%s' \
125129
% (platform.node(), traceback.format_exc())
126130

127131
if check_archive:
128-
132+
print(' >> Testing access to archive %s' % Config.archive_path)
129133
# check that all paths exist and can be reached
130134
if not os.path.exists(Config.archive_path):
131135
return ' -- %s: Could not reach archive path %s' % (platform.node(), Config.archive_path)
136+
print(' -- Done')
132137

138+
print(' >> Testing access to repository %s' % Config.repository)
133139
if not os.path.exists(Config.repository):
134140
return ' -- %s: Could not reach repository path %s' % (platform.node(), Config.repository)
141+
print(' -- Done')
135142

136143
# pick a test date to replace any possible parameters in the config file
137144
date = pyDate.Date(year=2010, doy=1)
138145
try:
146+
print(' >> Testing access to broadcast orbits %s' % Config.brdc_path)
139147
brdc = pyProducts.GetBrdcOrbits(Config.brdc_path, date, test_dir)
148+
print(' -- Done')
140149
except:
141150
return ' -- %s: Problem while testing the broadcast ephemeris archive (%s) access:\n%s' \
142151
% (platform.node(), Config.brdc_path, traceback.format_exc())
143152

144153
try:
154+
print(' >> Testing access to precise orbits %s' % Config.sp3_path)
145155
sp3 = pyProducts.GetSp3Orbits(Config.sp3_path, date, Config.sp3types, test_dir)
156+
print(' -- Done')
146157
except:
147158
return ' -- %s: Problem while testing the sp3 orbits archive (%s) access:\n%s' \
148159
% (platform.node(), Config.sp3_path, traceback.format_exc())
@@ -152,25 +163,33 @@ def check_tab_file(tabfile, date):
152163
for prg in ('crz2rnx', 'crx2rnx', 'rnx2crx', 'rnx2crz', 'gfzrnx_lx', 'svdiff', 'svpos', 'tform',
153164
'sh_rx2apr', 'doy', 'sed', 'compress'):
154165
with pyRunWithRetry.command('which ' + prg) as run:
166+
print(' >> Testing %s' % prg)
155167
run.run()
156168
if run.stdout == '':
157169
return ' -- %s: Could not find path to %s' % (platform.node(), prg)
170+
print(' -- Done')
158171

159172
# check grdtab and ppp from the config file
160173
for opt in ('grdtab', 'otlgrid', 'ppp_exe'):
161174
path = Config.options[opt]
175+
print(' >> Testing access to %s' % path)
162176
if not os.path.isfile(path):
163177
return ' -- %s: Could not find %s in %s' % (platform.node(), opt, path)
178+
print(' -- Done')
164179

165180
ppp_path = Config.options['ppp_path']
166181
for f in ('gpsppp.stc', 'gpsppp.svb_gps_yrly', 'gpsppp.flt', 'gpsppp.stc', 'gpsppp.met'):
182+
print(' >> Testing access to %s' % f)
167183
if not os.path.isfile(os.path.join(ppp_path, f)):
168184
return ' -- %s: Could not find %s in %s' % (platform.node(), f, ppp_path)
185+
print(' -- Done')
169186

170187
if check_atx:
171188
for frame in Config.options['frames']:
189+
print(' >> Testing access to %s %s' % (frame, frame['atx']))
172190
if not os.path.isfile(frame['atx']):
173191
return ' -- %s: Could not find atx in %s' % (platform.node(), frame['atx'])
192+
print(' -- Done')
174193

175194
if check_gamit_tables is not None:
176195
# check the gamit tables if not none

0 commit comments

Comments
 (0)