Handling empty mode/frequency values.
This commit is contained in:
parent
01eb5bf886
commit
37c864e3d4
|
|
@ -37,8 +37,12 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def renderService(c):
|
def renderService(c):
|
||||||
# Choose units based on frequency
|
# Choose units based on frequency
|
||||||
|
mode = c["mode"]
|
||||||
freq = c["freq"]
|
freq = c["freq"]
|
||||||
if freq >= 1000000000:
|
if freq is None:
|
||||||
|
freq = ""
|
||||||
|
unit = ""
|
||||||
|
elif freq >= 1000000000:
|
||||||
freq = freq / 1000000000
|
freq = freq / 1000000000
|
||||||
unit = "GHz"
|
unit = "GHz"
|
||||||
elif freq >= 30000000:
|
elif freq >= 30000000:
|
||||||
|
|
@ -49,9 +53,10 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
unit = "kHz"
|
unit = "kHz"
|
||||||
else:
|
else:
|
||||||
unit = "Hz"
|
unit = "Hz"
|
||||||
# Removing trailing zeros
|
# Removing trailing zeros, converting mode to upper case
|
||||||
freq = re.sub(r"\.?0+$", "", "{0}".format(freq))
|
freq = re.sub(r"\.?0+$", "", "{0}".format(freq))
|
||||||
|
mode = "???" if mode is None else mode.upper()
|
||||||
# Format row
|
# Format row
|
||||||
return "<tr><td>{0}</td><td>{1} {2}</td><td>{3}{4}</td></tr>".format(
|
return "<tr><td>{0}</td><td>{1} {2}</td><td>{3}{4}</td></tr>".format(
|
||||||
c["mode"].upper(), c["sdr"], c["band"], freq, unit
|
mode, c["sdr"], c["band"], freq, unit
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue