Browse Source

I don't know

master
squeaky otter 3 years ago
parent
commit
3c7adfa2ab
Signed by: dashie GPG Key ID: C2D57B325840B755
  1. 4
      autowx.ini
  2. 21
      autowx.py
  3. 4
      models.py
  4. 55
      noaa.py
  5. 12
      web.py

4
autowx.ini

@ -72,7 +72,7 @@ debug=true
[PROCESSING]
# Record Meteor ?
recordMeteor=true
recordMeteor=True
# Should we decode meteor too ?
decodeMeteor=false
# Should I remove RAWs after transcoding?
@ -131,4 +131,4 @@ lrpts=PATH_TO_OLEG_OFFLINE_DECODER
imgs=/opt/wxsat/img/MeteorMN2/
[DB]
path = sqlite:///autowx.db
path = sqlite:///autowx.db

21
autowx.py

@ -30,12 +30,15 @@ if __name__ == '__main__':
print "Using config file: {}".format(arguments['--config'])
if arguments['update-keps']:
keps.update_keps(config, arguments['--force'])
elif arguments['auto']:
if arguments['--force-keps-update']:
keps.update_keps(config, force=True)
noaa.auto_sat_magic(config, arguments['--config'])
elif arguments['web']:
web.static_web_generation(config)
try:
if arguments['update-keps']:
keps.update_keps(config, arguments['--force'])
elif arguments['auto']:
if arguments['--force-keps-update']:
keps.update_keps(config, force=True)
noaa.auto_sat_magic(config, arguments['--config'])
elif arguments['web']:
web.static_web_generation(config)
except KeyboardInterrupt, e:
print "Exiting."

4
models.py

@ -9,7 +9,7 @@ def init(config):
"""
Returns the engine after creating all tables if needed.
"""
engine = create_engine(config.get('DB', 'path'), echo=True)
engine = create_engine(config.get('DB', 'path'), echo=False)
Base.metadata.create_all(engine)
return engine
@ -34,4 +34,4 @@ class Passes(Base):
def __repr__(self):
return "<Passes(id='%i', sat='%s', aos='%s', los='%s', max_elev='%i')>".format(
self.id, self.sat_name, self.aos_time, self.los_time, self.max_elev
)
)

55
noaa.py

@ -53,7 +53,7 @@ def record_fm(config, frequency, filename, sleep_for, sat_name):
xf_no_space = sat_name.replace(" ", "")
output_file = os.path.join(config.get('DIRS', 'rec'), "{}-{}.raw".format(xf_no_space, filename))
cmdline = ['/usr/bin/rtl_fm',
cmdline = ['/usr/local/bin/rtl_fm',
'-f', str(frequency),
'-s', config.get('SDR', 'sample'),
'-g', config.get('SDR', 'gain'),
@ -626,6 +626,11 @@ def auto_sat_magic(config, cfg_file):
aos_time_cnv = strftime('%H:%M:%S', time.localtime(aosTime))
los_time_cnv = strftime('%H:%M:%S', time.localtime(losTime))
print "now {}".format(now)
print "aosTime {}".format(aosTime)
print "aosTime > now {}".format(aosTime > now)
print "towait {}".format(towait)
# OK, now we have to decide what if recording or sleeping
if towait > 0:
print cfg.logLineStart + "waiting " + cfg.AsciiColors.CYAN + str(towait).split(".")[
@ -646,6 +651,8 @@ def auto_sat_magic(config, cfg_file):
if record_time < 1:
record_time = 1
pass_ok = True
fname = str(aosTime)
print cfg.logLineStart + "Beginning pass of " + cfg.AsciiColors.YELLOW + satName + cfg.AsciiColors.OKGREEN + \
" at " + cfg.AsciiColors.CYAN + str(maxElev) + "\xb0" + cfg.AsciiColors.OKGREEN + " elev.\n" + \
@ -657,31 +664,45 @@ def auto_sat_magic(config, cfg_file):
satName, maxElev, 'RECORDING')
if satName in ('NOAA 15', 'NOAA 19', 'NOAA 18'):
record_wav(config, freq, fname, record_time, satName)
try:
record_wav(config, freq, fname, record_time, satName)
except:
pass_ok = False
elif satName == 'METEOR-M 2':
if config.getboolean("PROCESSING", "recordMeteor"):
record_qpsk(config, cfg_file, record_time)
try:
record_qpsk(config, cfg_file, record_time)
except:
pass_ok = False
print cfg.logLineStart + "Decoding data" + cfg.logLineEnd
if satName in ('NOAA 15', 'NOAA 19', 'NOAA 18'):
if satName in ('NOAA 15', 'NOAA 19', 'NOAA 18') and pass_ok:
write_status(config, freq, aosTime, los_time_cnv, str(losTime), str(record_time).split(".")[0], satName,
maxElev, 'DECODING')
decode(config, fname, aosTime, satName, maxElev, record_time, wxtoimg_cfg) # make picture
elif satName == 'METEOR-M 2':
try:
decode(config, fname, aosTime, satName, maxElev, record_time, wxtoimg_cfg) # make picture
except:
pass_ok = False
elif satName == 'METEOR-M 2' and pass_ok:
if config.getboolean('PROCESSING', 'decodeMeteor'):
print "This may take a loooong time and is resource hungry!!!"
write_status(config, freq, aosTime, los_time_cnv, str(losTime), str(record_time).split(".")[0], satName,
maxElev, 'DECODING')
decode_qpsk(config)
tle_draw.generate_pass_trace(config, pass_transit, tle_sat, satName, fname)
# No METEOR currently managed
# Generate Static uses the CSV records so we should not add METEOR in it if not managed by the static thing
if 'NOAA' in satName:
web.add_db_record(config, satName, now, aosTime, losTime, maxElev, record_time)
web.generate_static_web(config, satName, now, aosTime, losTime, maxElev, record_time)
else:
print "METEOR currently not managed for static webpages generation"
try:
decode_qpsk(config)
except:
pass_ok = False
if pass_ok:
tle_draw.generate_pass_trace(config, pass_transit, tle_sat, satName, fname)
if pass_ok:
# No METEOR currently managed
# Generate Static uses the CSV records so we should not add METEOR in it if not managed by the static thing
if 'NOAA' in satName:
web.add_db_record(config, satName, now, aosTime, losTime, maxElev, record_time)
web.generate_static_web(config, satName, now, aosTime, losTime, maxElev, record_time)
else:
print "METEOR currently not managed for static webpages generation"
print cfg.logLineStart + "Finished pass of " + cfg.AsciiColors.YELLOW + satName + cfg.AsciiColors.OKGREEN + \
" at " + cfg.AsciiColors.CYAN + los_time_cnv + cfg.AsciiColors.OKGREEN + ". Sleeping for" + \

12
web.py

@ -180,9 +180,9 @@ def generate_static_web(config, sat_name, automate_started,
html = render_template(config.get('STATIC_WEB', 'index_passes'), ctx)
index_page_file.write(html)
page = 1 # index created, increment page
print cfg.logLineStart + \
"Wrote web page for index passes, page 0 0-{}".format(passes_per_pages) + \
cfg.logLineEnd
#print cfg.logLineStart + \
# "Wrote web page for index passes, page 0 0-{}".format(passes_per_pages) + \
# cfg.logLineEnd
if passes.count() > passes_per_pages:
# We have more pages to show
@ -204,9 +204,9 @@ def generate_static_web(config, sat_name, automate_started,
}
html = render_template(config.get('STATIC_WEB', 'index_passes'), ctx)
passes_page_file.write(html)
print cfg.logLineStart + "Wrote web page for index passes, page {} {}-{}".format(
page, start_passes, start_passes + passes_per_pages
) + cfg.logLineEnd
#print cfg.logLineStart + "Wrote web page for index passes, page {} {}-{}".format(
# page, start_passes, start_passes + passes_per_pages
#) + cfg.logLineEnd
page = page + 1 # page created, increment
print cfg.logLineStart + "Finished web page processing" + cfg.logLineEnd

Loading…
Cancel
Save