Skip to content

Commit

Permalink
Fix os.environ boolean bug for main.config
Browse files Browse the repository at this point in the history
  • Loading branch information
oceancolorcoder committed Sep 20, 2024
1 parent 5c02193 commit 4e34960
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ def processSingle(self, lvl):
sys.exit()

# Select data files
if not self.inputDirectory[0]:
print("Bad input parent directory.")
return
# if not self.inputDirectory[0]:
# print("Bad input parent directory.")
# return

if lvl == "L1A":
inLevel = "raw"
Expand Down Expand Up @@ -814,13 +814,13 @@ def __init__(

# If the cmd argument is given, run the Command class without the GUI
if cmd:
os.environ["HYPERINSPACE_CMD"] = "TRUE"
os.environ["HYPERINSPACE_CMD"] = "TRUE" # Must be a string
if not (args.username is None or args.password is None):
# Only for L2 processing set credentials
GetAnc.userCreds(username, password)
Command(configFilePath, inputFile, multiLevel, outputDirectory, level, ancFile)
else:
os.environ["HYPERINSPACE_CMD"] = "FALSE"
os.environ["HYPERINSPACE_CMD"] = "FALSE" # Must be a string
app = QtWidgets.QApplication(sys.argv)
win = Window()
sys.exit(app.exec_())
4 changes: 2 additions & 2 deletions Source/ConfigFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def saveConfig(filename):
params['RadCalDir'] = os.path.relpath(params['RadCalDir'])
fp = os.path.join(PATH_TO_CONFIG, filename)

with open(fp, 'w') as f:
with open(fp, 'w', encoding="utf-8") as f:
json.dump(params,f,indent=4)
ConfigFile.createCalibrationFolder()

Expand All @@ -231,7 +231,7 @@ def loadConfig(filename):
# print(f'Populating ConfigFile with saved parameters: {filename}')
ConfigFile.filename = filename
text = ""
with open(configPath, 'r') as f:
with open(configPath, 'r', encoding="utf-8") as f:
text = f.read()
# ConfigFile.settings = json.loads(text, object_pairs_hook=collections.OrderedDict)
fullCollection = json.loads(text, object_pairs_hook=collections.OrderedDict)
Expand Down
2 changes: 1 addition & 1 deletion Source/MainConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MainConfig:
# Saves the cfg file
@staticmethod
def saveConfig(fileName):
print("ConfigFile - Save Config")
print("MainConfig - Save Config")
# jsn = json.dumps(MainConfig.settings)
fp = os.path.join(PATH_TO_CONFIG, fileName)

Expand Down
2 changes: 1 addition & 1 deletion Source/ProcessL1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def processL1a(fp, calibrationMap):
# Generate root attributes
root = HDFRoot()
root.id = "/"
if os.environ['HYPERINSPACE_CMD'] == 'TRUE':
if os.environ['HYPERINSPACE_CMD'].lower == 'true': # os.environ must be string
MainConfig.loadConfig('cmdline_main.config','version')
else:
MainConfig.loadConfig('main.config','version')
Expand Down
4 changes: 2 additions & 2 deletions Source/SeaBASSHeaderWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def configUpdateButtonPressed(self, caller):

# First try to fill left column metadata headers using the Ancillary fill if provided.
# Only when opening, not when saving
if caller == 'config1' and not os.environ["HYPERINSPACE_CMD"]:
if caller == 'config1' and not os.environ["HYPERINSPACE_CMD"].lower() == 'true': # os.environ must be string
fp = MainConfig.settings["ancFile"]
if not os.path.isfile(fp):
print("Specified ancillary file not found: " + fp)
Expand Down Expand Up @@ -570,7 +570,7 @@ def configUpdateButtonPressed(self, caller):
else:
NegativeFilt = "Off"

if os.environ["HYPERINSPACE_CMD"]:
if os.environ["HYPERINSPACE_CMD"].lower() == 'true': #os.environs must be strings
MainConfig.loadConfig('cmdline_main.config','version')
else:
MainConfig.loadConfig('main.config','version')
Expand Down
2 changes: 1 addition & 1 deletion run_Sample_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
else:
PATH_CFG = os.path.join(PATH_HCP, "Config", f"{CRUISE}.cfg")
################################################# END CUSTOM SET UP #################################################
os.environ["HYPERINSPACE_CMD"] = "TRUE"
os.environ["HYPERINSPACE_CMD"].lower() = "true"

## Setup remaining globals ##
TO_LEVELS = ["L1A", "L1AQC", "L1B", "L1BQC", "L2"]
Expand Down

0 comments on commit 4e34960

Please sign in to comment.