5 from subprocess
import Popen
6 from os.path
import normpath, basename
7 from threading
import Thread
9 from pathlib
import Path
13 sys.path.insert(1,
'../logInspector')
14 sys.path.insert(1,
'..')
16 from logReader
import Log
19 def __init__(self, directory, config_serials, startMode=0, computeRMS=0):
30 print(
"===================== Init SuperNPP =====================")
35 print(
" subdirs:", self.
subdirs)
43 for file
in os.listdir(directory):
44 if ".sdat" in file
or ".dat" in file:
48 for subdir
in os.listdir(directory):
49 subdir2 = os.path.join(directory, subdir)
50 if not os.path.isdir(subdir2):
52 if "post_processed" in subdir:
57 print(
'\nDirectories to reprocess:')
59 print(
'\n' + str(len(self.
subdirs)) +
' directories')
66 for thread
in threads:
68 for thread
in threads:
74 sdir = subdir +
"/post_processed" 78 self.
log.calculateRMS()
79 passRMS = self.
log.printRMSReport()
82 print(
"RMS Test PASSED: " + sdir)
85 print(
"RMS Test FAILED: " + sdir)
91 (folder, subdir) = os.path.split(folder)
93 if config_serials == [
"ALL"]:
95 for file
in os.listdir(os.path.join(folder,subdir)):
96 if ".sdat" in file
or ".dat" in file:
97 ser = int(re.sub(
'[^0-9]',
'', file.split(
"_")[1]))
98 if ser
not in serials:
101 serials = config_serials
103 print(
"serial numbers")
106 if os.name ==
'posix':
107 cmds = [
'./navpp -d ' + folder +
' -s ' + str(s) +
" -sd " + subdir
for s
in serials]
108 npp_build_folder =
"../../../cpp/NavPostProcess/build" 110 cmds = [
r'.\NavPostProcess.exe -d "' + folder +
r'" -s ' + str(s) +
" -sd " + subdir
for s
in serials]
111 npp_build_folder =
"../../../cpp/NavPostProcess/VS_project/Release" 114 for i
in range(len(cmds)):
115 cmds[i] +=
' -mode COLD -kml' 118 for i
in range(len(cmds)):
119 cmds[i] +=
' -mode FACTORY -kml' 121 for i
in range(len(cmds)):
122 cmds[i] +=
' --outputoff' 124 print(
"Running NPP...")
129 processes = [Popen(cmd, shell=
True, cwd=npp_build_folder)
for cmd
in cmds]
156 print(
"All processes done!")
159 if not os.path.exists(npp_build_folder):
160 os.makedirs(npp_build_folder)
162 print(
"building NPP")
163 cmd = [
'cmake .. -DCMAKE_BUILD_TYPE=Debug && make -j12 -l12']
164 process = Popen(cmd, shell=
True, cwd=npp_build_folder)
167 if __name__ ==
"__main__":
169 print(
"Running SuperNPP")
170 npp_build_folder =
"../../../cpp/NavPostProcess/build" 180 if len(sys.argv) >= 2:
181 directory = sys.argv[1]
189 if 'directory' not in locals():
190 print(
"First parameter must be directory!")
194 if len(sys.argv) >= 3:
195 serials = sys.argv[2]
198 print(
"Using default value for serials: ", serials)
201 if len(sys.argv) >= 4:
202 computeRMS = sys.argv[3]
207 snpp =
SuperNPP(directory, serials, computeRMS=computeRMS)
210 print(
"==================== Super NPP Results ====================")
211 rmsPassFilename = directory+
"/rms_pass.txt" 212 rmsFailFilename = directory+
"/rms_fail.txt" 218 os.remove(rmsPassFilename)
222 os.remove(rmsFailFilename)
226 if snpp.rmsPassResults != []:
227 print(
" RMS Tests PASSED")
228 f = open(rmsPassFilename,
"w")
229 for val
in snpp.rmsPassResults:
234 if snpp.rmsFailResults != []:
235 print(
" RMS Tests FAILED:")
236 f = open(rmsFailFilename,
"w")
237 for val
in snpp.rmsFailResults:
243 print(
"=============================================================")
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)
def findLogFiles(self, directory)
def run_log_folder(self, folder, config_serials)
def __init__(self, directory, config_serials, startMode=0, computeRMS=0)
def buildNPP(npp_build_folder)