Skip to content

Commit

Permalink
Change method of managing CFG file
Browse files Browse the repository at this point in the history
  • Loading branch information
k5map committed Aug 13, 2023
1 parent 4644fd6 commit d5f79d7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
33 changes: 17 additions & 16 deletions BalloonCfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,23 @@

import sys
import logging
import configparser
import argparse
from configupdater import ConfigUpdater
import configparser

from constants import CFG_FILE


def getBalloonCfg():
cfgFile = "BalloonTelemetry.cfg"
parser = argparse.ArgumentParser()
parser.add_argument("bCallSign", help="Enter Balloon Callsign with SSID")
args = parser.parse_args()

config_object = configparser.ConfigParser()
file = open(cfgFile, "r")
config_object.read_file(file)
output_dict = dict()
sections = config_object.sections()
for section in sections:
items = config_object.items(section)
output_dict[section] = dict(items)

return output_dict[args.bCallSign.upper()]

cfgUpdater = ConfigUpdater()
cfgUpdater.read(CFG_FILE)
cfg = cfgUpdater.to_dict()
return cfg[args.bCallSign.upper()]

#==============================================================================================================#

Expand Down Expand Up @@ -80,12 +75,18 @@ def checkCfg(bCallsign):

def putBalloonCfg(Balloon, lDateTime):
# save last datetime to ini
cfgFile = "BalloonTelemetry.cfg"
cfgUpdater = ConfigUpdater()
cfgUpdater.read(CFG_FILE)
cfgUpdater[Balloon]['ldatetime'].value = lDateTime
cfgUpdater.update_file()
return

"""
config_obj = configparser.ConfigParser()
config_obj.read(cfgFile)
config_obj.read(CFG_FILE)
cSection = config_obj[Balloon]
cSection["lDateTime"] = lDateTime
with open(cfgFile, 'w') as configfile:
with open(CFG_FILE, 'w') as configfile:
config_obj.write(configfile)
logging.info(' lDateTime has been updated in the config file')
return
"""
10 changes: 9 additions & 1 deletion BalloonTelemetry.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# This is a comment line
# BALLOON parms
# tracker = Z (Zachtek), A (AB5SS), Q (QRP-Labs), U (U4B)
# timeslot = 0, 2, 4, 6, 8 (last digit of the minute for xmit)
# uploadsite = A (APRS-IS), S (SondeHub) or T (no upload, used for testing)
# telemetryfile = Y or N (this will output telemetry data to a file named callsign-ssd.txt)
# ldatetime = last date/time of successful upload of telemetry data
#

[K5WH-117]
uploadcallsign = W5MOM
wsprcallsign = K5WH/B
Expand Down Expand Up @@ -32,6 +39,7 @@ timeslot = 6
comment = BLT-100 WSPR, South Tx Balloon Launch Team 3
uploadsite = T
telemetryfile = Y
#ldatetime = 2023-06-29 00:00:00
ldatetime = 2023-06-29 00:00:00

[N5EKO-113]
Expand Down
6 changes: 4 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# (at your option) any later version. #
# #
#==============================================================================================================#
__version__ = '0.2.0'
__version__ = '0.2.2'

SOFTWARE_NAME = "k5map-python"
SOFTWARE_NAME = "k5map-python"

CFG_FILE = "BalloonTelemetry.cfg"

0 comments on commit d5f79d7

Please sign in to comment.