Commit f9d30db0 authored by Vasilis Tsiligiannis's avatar Vasilis Tsiligiannis

Reformat code with 'yapf' (closes #338)

Signed-off-by: Vasilis Tsiligiannis's avatarVasilis Tsiligiannis <acinonyx@openwrt.gr>
parent c260c715
......@@ -32,9 +32,10 @@ class Locator(object):
no_timeout = True
LOGGER.info('No default coordinates, GPS timeout disabled')
else:
LOGGER.info(
'Last coordinates %f %f %d', settings.SATNOGS_STATION_LAT,
settings.SATNOGS_STATION_LON, settings.SATNOGS_STATION_ELEV)
LOGGER.info('Last coordinates %f %f %d',
settings.SATNOGS_STATION_LAT,
settings.SATNOGS_STATION_LON,
settings.SATNOGS_STATION_ELEV)
end_time = time.time() + self.timeout
try:
......@@ -53,8 +54,9 @@ class Locator(object):
settings.SATNOGS_STATION_LAT = gpsd.fix.latitude
settings.SATNOGS_STATION_LON = gpsd.fix.longitude
settings.SATNOGS_STATION_ELEV = gpsd.fix.altitude
LOGGER.info(
'Updating coordinates %f %f %d', settings.SATNOGS_STATION_LAT,
settings.SATNOGS_STATION_LON, settings.SATNOGS_STATION_ELEV)
LOGGER.info('Updating coordinates %f %f %d',
settings.SATNOGS_STATION_LAT,
settings.SATNOGS_STATION_LON,
settings.SATNOGS_STATION_ELEV)
else:
LOGGER.info("GPS timeout, using last known coordinates")
......@@ -171,16 +171,17 @@ class Observer(object):
client_metadata['frequency'] = self.frequency
try:
resp = requests.put(
url,
headers=headers,
data={
'client_version': satnogsclient.config.VERSION,
'client_metadata': json.dumps(client_metadata)
},
verify=settings.SATNOGS_VERIFY_SSL,
stream=True,
timeout=45)
resp = requests.put(url,
headers=headers,
data={
'client_version':
satnogsclient.config.VERSION,
'client_metadata':
json.dumps(client_metadata)
},
verify=settings.SATNOGS_VERIFY_SSL,
stream=True,
timeout=45)
except requests.exceptions.ConnectionError:
LOGGER.error('%s: Connection Refused', url)
except requests.exceptions.Timeout:
......@@ -194,25 +195,23 @@ class Observer(object):
LOGGER.error('Bad status code: %s', resp.status_code)
def run_rot(self):
self.tracker_rot = WorkerTrack(
ip=self.rot_ip,
port=self.rot_port,
frequency=self.frequency,
time_to_stop=self.observation_end,
proc=self._gnu_proc,
sleep_time=3)
self.tracker_rot = WorkerTrack(ip=self.rot_ip,
port=self.rot_port,
frequency=self.frequency,
time_to_stop=self.observation_end,
proc=self._gnu_proc,
sleep_time=3)
LOGGER.debug('TLE: %s', self.tle)
LOGGER.debug('Observation end: %s', self.observation_end)
self.tracker_rot.trackobject(self.location, self.tle)
self.tracker_rot.trackstart()
def run_rig(self):
self.tracker_freq = WorkerFreq(
ip=self.rig_ip,
port=self.rig_port,
frequency=self.frequency,
time_to_stop=self.observation_end,
proc=self._gnu_proc)
self.tracker_freq = WorkerFreq(ip=self.rig_ip,
port=self.rig_port,
frequency=self.frequency,
time_to_stop=self.observation_end,
proc=self._gnu_proc)
LOGGER.debug('Rig Frequency %s', self.frequency)
LOGGER.debug('Observation end: %s', self.observation_end)
self.tracker_freq.trackobject(self.location, self.tle)
......@@ -274,15 +273,14 @@ class Observer(object):
vmax = settings.SATNOGS_WATERFALL_MAX_VALUE
LOGGER.info('Plot waterfall file')
plt.figure(figsize=(10, 20))
plt.imshow(
spec,
origin='lower',
aspect='auto',
interpolation='None',
extent=[fmin, fmax, tmin, tmax],
vmin=vmin,
vmax=vmax,
cmap="viridis")
plt.imshow(spec,
origin='lower',
aspect='auto',
interpolation='None',
extent=[fmin, fmax, tmin, tmax],
vmin=vmin,
vmax=vmax,
cmap="viridis")
plt.xlabel("Frequency (kHz)")
plt.ylabel("Time (seconds)")
fig = plt.colorbar(aspect=50)
......
......@@ -154,9 +154,9 @@ class WorkerTrack(Worker):
observer.elevation = observer_dict["elev"]
observer.date = ephem.Date(start)
satellite = ephem.readtle(
str(satellite_dict["tle0"]), str(satellite_dict["tle1"]),
str(satellite_dict["tle2"]))
satellite = ephem.readtle(str(satellite_dict["tle0"]),
str(satellite_dict["tle1"]),
str(satellite_dict["tle2"]))
timestamp_max = pytz.utc.localize(
ephem.Date(observer.next_pass(satellite)[2]).datetime())
......
......@@ -16,8 +16,7 @@ EXECUTORS = {
JOB_DEFAULTS = {'coalesce': True, 'max_instances': 1, 'misfire_grace_time': 30}
SCHEDULER = BackgroundScheduler(
jobstores=JOBSTORES,
executors=EXECUTORS,
job_defaults=JOB_DEFAULTS,
timezone=utc)
SCHEDULER = BackgroundScheduler(jobstores=JOBSTORES,
executors=EXECUTORS,
job_defaults=JOB_DEFAULTS,
timezone=utc)
......@@ -123,13 +123,12 @@ def post_data():
LOGGER.debug('URL: %s', url)
LOGGER.debug('Headers: %s', headers)
LOGGER.debug('Observation file: %s', observation)
response = requests.put(
url,
headers=headers,
files=observation,
verify=settings.SATNOGS_VERIFY_SSL,
stream=True,
timeout=45)
response = requests.put(url,
headers=headers,
files=observation,
verify=settings.SATNOGS_VERIFY_SSL,
stream=True,
timeout=45)
if response.status_code == 200:
LOGGER.info('Success: status code 200')
if settings.SATNOGS_COMPLETE_OUTPUT_PATH != "":
......@@ -149,8 +148,8 @@ def post_data():
def get_jobs():
"""Query SatNOGS Network API to GET jobs."""
gps_locator = locator.Locator(
settings.SATNOGS_NETWORK_API_QUERY_INTERVAL * 60)
gps_locator = locator.Locator(settings.SATNOGS_NETWORK_API_QUERY_INTERVAL *
60)
gps_locator.update_location()
LOGGER.info('Get jobs started')
url = urljoin(settings.SATNOGS_NETWORK_API_URL, 'jobs/')
......@@ -165,12 +164,11 @@ def get_jobs():
LOGGER.debug('Params: %s', params)
LOGGER.debug('Headers: %s', headers)
LOGGER.info('Trying to GET observation jobs from the network')
response = requests.get(
url,
params=params,
headers=headers,
verify=settings.SATNOGS_VERIFY_SSL,
timeout=45)
response = requests.get(url,
params=params,
headers=headers,
verify=settings.SATNOGS_VERIFY_SSL,
timeout=45)
if not response.status_code == 200:
raise Exception('Status code: {0} on request: {1}'.format(
......@@ -188,13 +186,12 @@ def get_jobs():
kwargs = {'obj': obj}
LOGGER.info('Adding new job: %s', job_id)
LOGGER.debug('Observation obj: %s', obj)
SCHEDULER.add_job(
spawn_observer,
'date',
run_date=start,
id='{0}'.format(job_id),
kwargs=kwargs,
replace_existing=True)
SCHEDULER.add_job(spawn_observer,
'date',
run_date=start,
id='{0}'.format(job_id),
kwargs=kwargs,
replace_existing=True)
def status_listener():
......
......@@ -90,8 +90,8 @@ def exec_gnuradio(observation_file, waterfall_file, freq, baud, script_name,
args += ['--dev-args=' + client_settings.SATNOGS_DEV_ARGS]
if client_settings.ENABLE_IQ_DUMP:
args += [
'--enable-iq-dump=' + str(
int(client_settings.ENABLE_IQ_DUMP is True))
'--enable-iq-dump=' +
str(int(client_settings.ENABLE_IQ_DUMP is True))
]
if client_settings.IQ_DUMP_FILENAME:
args += ['--iq-file-path=' + client_settings.IQ_DUMP_FILENAME]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment