diff --git a/swagger/sdrangel/examples/add_channel.py b/swagger/sdrangel/examples/add_channel.py old mode 100644 new mode 100755 index ee35a6b4a..27a2320c8 --- a/swagger/sdrangel/examples/add_channel.py +++ b/swagger/sdrangel/examples/add_channel.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import requests, json, traceback, sys from optparse import OptionParser @@ -12,12 +12,12 @@ def getInputOptions(): parser = OptionParser(usage="usage: %%prog [-t]\n") parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string") parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int") - parser.add_option("-c", "--channel-id", dest="channel_id", help="channel ID of channel to add", metavar="ID", type="string") + parser.add_option("-c", "--channel-id", dest="channel_id", help="channel ID of channel to add (E.g. NFMDemod)", metavar="ID", type="string") (options, args) = parser.parse_args() if options.address is None: - options.address = "127.0.0.1:8888" + options.address = "127.0.0.1:8091" if options.device_index is None or options.device_index < 0: options.device_index = 0 @@ -37,12 +37,12 @@ def main(): base_url = "http://%s/sdrangel" % options.address device_url = base_url + ("/deviceset/%d/channel" % options.device_index) r = requests.post(url=device_url, json={"direction": 0, "channelType": options.channel_id}) - if r.status_code / 100 == 2: + if r.status_code // 100 == 2: print("Success") - print json.dumps(r.json(), indent=4, sort_keys=True) + print(json.dumps(r.json(), indent=4, sort_keys=True)) else: print("Error adding channel. HTTP: %d" % r.status_code) - print json.dumps(r.json(), indent=4, sort_keys=True) + print(json.dumps(r.json(), indent=4, sort_keys=True)) except Exception as ex: tb = traceback.format_exc() diff --git a/swagger/sdrangel/examples/rtlsdr_settings.py b/swagger/sdrangel/examples/rtlsdr_settings.py old mode 100644 new mode 100755 index a07d7ce84..af59174d6 --- a/swagger/sdrangel/examples/rtlsdr_settings.py +++ b/swagger/sdrangel/examples/rtlsdr_settings.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import requests, json base_url = "http://127.0.0.1:8091/sdrangel" @@ -14,7 +14,7 @@ requests_methods = { def getHwType(): r = requests.get(url=base_url + "/deviceset/0") - if r.status_code / 100 == 2: + if r.status_code // 100 == 2: rj = r.json() devj = rj.get('samplingDevice', None) if devj is not None: @@ -27,8 +27,8 @@ def getHwType(): def selectRtlSdr(): r = requests.put(url=base_url + "/deviceset/0/device", json={"hwType": "RTLSDR"}) - if r.status_code / 100 == 2: - print json.dumps(r.json(), indent=4, sort_keys=True) + if r.status_code // 100 == 2: + print(json.dumps(r.json(), indent=4, sort_keys=True)) return True else: return False @@ -36,7 +36,7 @@ def selectRtlSdr(): def getRtlSdrSettings(): r = requests.get(url=base_url + "/deviceset/0/device/settings") - if r.status_code / 100 == 2: + if r.status_code // 100 == 2: rj = r.json() hwType = rj.get('deviceHwType', None) if hwType is not None and hwType == "RTLSDR": @@ -51,10 +51,10 @@ def getRtlSdrSettings(): def patchRtlSdrSettings(settings): new_settings = {"deviceHwType": "RTLSDR", "direction": 0, "rtlSdrSettings": settings} r = requests.patch(url=base_url + "/deviceset/0/device/settings", json=new_settings) - if r.status_code / 100 == 2: - print json.dumps(r.json(), indent=4, sort_keys=True) + if r.status_code // 100 == 2: + print(json.dumps(r.json(), indent=4, sort_keys=True)) else: - print "Error HTTP:", r.status_code + print("Error HTTP:", r.status_code) def deviceRun(run): @@ -62,10 +62,10 @@ def deviceRun(run): r = requests.post(url=base_url + "/deviceset/0/device/run") else: r = requests.delete(url=base_url + "/deviceset/0/device/run") - if r.status_code / 100 == 2: - print json.dumps(r.json(), indent=4, sort_keys=True) + if r.status_code // 100 == 2: + print(json.dumps(r.json(), indent=4, sort_keys=True)) else: - print "Error HTTP:", r.status_code + print("Error HTTP:", r.status_code) def main(): @@ -73,8 +73,10 @@ def main(): if hwType is not None: if hwType != "RTLSDR": if not selectRtlSdr(): + print("Device set 0 is not an RTLSDR device") return else: + print("Device set 0 does not exist") return settings = getRtlSdrSettings() if settings is not None: diff --git a/swagger/sdrangel/examples/rx_test.py b/swagger/sdrangel/examples/rx_test.py index 1eafec6a0..b2651834c 100755 --- a/swagger/sdrangel/examples/rx_test.py +++ b/swagger/sdrangel/examples/rx_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import requests, json, traceback, sys, time from optparse import OptionParser