Bug #5099 ยป modernize_python.patch
chirp/bandplan.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2013 Sean Burford <sburford@google.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
34 | 35 |
for tone in tones: |
35 | 36 |
assert tone in chirp_common.TONES, ( |
36 | 37 |
"tone %s not one of %s" % (tone, chirp_common.TONES)) |
37 |
except AssertionError, e:
|
|
38 |
except AssertionError as e:
|
|
38 | 39 |
raise ValueError("%s %s: %s" % (name, limits, e)) |
39 | 40 | |
40 | 41 |
self.name = name |
chirp/chirp_common.py (revision 83f364736678ae6000c8f4da1e48ab4113b78f69) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
153 | 154 |
return int(math.pow(10, (dBm - 30) / 10)) |
154 | 155 | |
155 | 156 | |
156 |
class PowerLevel: |
|
157 |
class PowerLevel(object):
|
|
157 | 158 |
"""Represents a power level supported by a radio""" |
158 | 159 | |
159 | 160 |
def __init__(self, label, watts=0, dBm=0): |
... | ... | |
228 | 229 |
pass |
229 | 230 | |
230 | 231 | |
231 |
class Memory: |
|
232 |
class Memory(object):
|
|
232 | 233 |
"""Base class for a single radio memory""" |
233 | 234 |
freq = 0 |
234 | 235 |
number = 0 |
... | ... | |
634 | 635 |
super(BankModel, self).__init__(radio, name) |
635 | 636 | |
636 | 637 | |
637 |
class MappingModelIndexInterface: |
|
638 |
class MappingModelIndexInterface(object):
|
|
638 | 639 |
"""Interface for mappings with index capabilities""" |
639 | 640 | |
640 | 641 |
def get_index_bounds(self): |
... | ... | |
673 | 674 |
sys.stdout.write(os.linesep) |
674 | 675 | |
675 | 676 | |
676 |
class RadioPrompts: |
|
677 |
class RadioPrompts(object):
|
|
677 | 678 |
"""Radio prompt strings""" |
678 | 679 |
experimental = None |
679 | 680 |
pre_download = None |
... | ... | |
684 | 685 |
BOOLEAN = [True, False] |
685 | 686 | |
686 | 687 | |
687 |
class RadioFeatures: |
|
688 |
class RadioFeatures(object):
|
|
688 | 689 |
"""Radio Feature Flags""" |
689 | 690 |
_valid_map = { |
690 | 691 |
# General |
... | ... | |
875 | 876 |
lo, hi = self.memory_bounds |
876 | 877 |
if not self.has_infinite_number and \ |
877 | 878 |
(mem.number < lo or mem.number > hi) and \ |
878 |
mem.extd_number not in self.valid_special_chans: |
|
879 |
mem.extd_number not in self.valid_special_chans:
|
|
879 | 880 |
msg = ValidationWarning("Location %i is out of range" % mem.number) |
880 | 881 |
msgs.append(msg) |
881 | 882 | |
882 | 883 |
if (self.valid_modes and |
883 |
mem.mode not in self.valid_modes and |
|
884 |
mem.mode != "Auto"): |
|
884 |
mem.mode not in self.valid_modes and
|
|
885 |
mem.mode != "Auto"):
|
|
885 | 886 |
msg = ValidationError("Mode %s not supported" % mem.mode) |
886 | 887 |
msgs.append(msg) |
887 | 888 | |
... | ... | |
891 | 892 |
else: |
892 | 893 |
if mem.tmode == "Cross": |
893 | 894 |
if self.valid_cross_modes and \ |
894 |
mem.cross_mode not in self.valid_cross_modes: |
|
895 |
mem.cross_mode not in self.valid_cross_modes:
|
|
895 | 896 |
msg = ValidationError("Cross tone mode %s not supported" % |
896 | 897 |
mem.cross_mode) |
897 | 898 |
msgs.append(msg) |
898 | 899 | |
899 | 900 |
if self.has_dtcs_polarity and \ |
900 |
mem.dtcs_polarity not in self.valid_dtcs_pols: |
|
901 |
mem.dtcs_polarity not in self.valid_dtcs_pols:
|
|
901 | 902 |
msg = ValidationError("DTCS Polarity %s not supported" % |
902 | 903 |
mem.dtcs_polarity) |
903 | 904 |
msgs.append(msg) |
904 | 905 | |
905 | 906 |
if self.valid_dtcs_codes and \ |
906 |
mem.dtcs not in self.valid_dtcs_codes: |
|
907 |
mem.dtcs not in self.valid_dtcs_codes:
|
|
907 | 908 |
msg = ValidationError("DTCS Code %03i not supported" % mem.dtcs) |
908 | 909 |
if self.valid_dtcs_codes and \ |
909 |
mem.rx_dtcs not in self.valid_dtcs_codes: |
|
910 |
mem.rx_dtcs not in self.valid_dtcs_codes:
|
|
910 | 911 |
msg = ValidationError("DTCS Code %03i not supported" % mem.rx_dtcs) |
911 | 912 | |
912 | 913 |
if self.valid_duplexes and mem.duplex not in self.valid_duplexes: |
... | ... | |
933 | 934 | |
934 | 935 |
if self.valid_bands and \ |
935 | 936 |
self.valid_duplexes and \ |
936 |
mem.duplex in ["split", "-", "+"]: |
|
937 |
mem.duplex in ["split", "-", "+"]:
|
|
937 | 938 |
if mem.duplex == "split": |
938 | 939 |
freq = mem.offset |
939 | 940 |
elif mem.duplex == "-": |
... | ... | |
953 | 954 | |
954 | 955 |
if mem.power and \ |
955 | 956 |
self.valid_power_levels and \ |
956 |
mem.power not in self.valid_power_levels: |
|
957 |
mem.power not in self.valid_power_levels:
|
|
957 | 958 |
msg = ValidationWarning("Power level %s not supported" % mem.power) |
958 | 959 |
msgs.append(msg) |
959 | 960 | |
... | ... | |
964 | 965 |
msg = ValidationError("Frequency requires %.2fkHz step" % |
965 | 966 |
required_step(mem.freq)) |
966 | 967 |
msgs.append(msg) |
967 |
except errors.InvalidDataError, e:
|
|
968 |
except errors.InvalidDataError as e:
|
|
968 | 969 |
msgs.append(str(e)) |
969 | 970 | |
970 | 971 |
if self.valid_characters: |
... | ... | |
1122 | 1123 | |
1123 | 1124 |
def load_mmap(self, filename): |
1124 | 1125 |
"""Load the radio's memory map from @filename""" |
1125 |
mapfile = file(filename, "rb")
|
|
1126 |
mapfile = open(filename, "rb")
|
|
1126 | 1127 |
self._mmap = memmap.MemoryMap(mapfile.read()) |
1127 | 1128 |
mapfile.close() |
1128 | 1129 |
self.process_mmap() |
... | ... | |
1133 | 1134 |
If IOError raise a File Access Error Exception |
1134 | 1135 |
""" |
1135 | 1136 |
try: |
1136 |
mapfile = file(filename, "wb")
|
|
1137 |
mapfile = open(filename, "wb")
|
|
1137 | 1138 |
mapfile.write(self._mmap.get_packed()) |
1138 | 1139 |
mapfile.close() |
1139 | 1140 |
except IOError: |
... | ... | |
1202 | 1203 |
pass |
1203 | 1204 | |
1204 | 1205 | |
1205 |
class IcomDstarSupport: |
|
1206 |
class IcomDstarSupport(object):
|
|
1206 | 1207 |
"""Base interface for radios supporting Icom's D-STAR technology""" |
1207 | 1208 |
MYCALL_LIMIT = (1, 1) |
1208 | 1209 |
URCALL_LIMIT = (1, 1) |
... | ... | |
1233 | 1234 |
pass |
1234 | 1235 | |
1235 | 1236 | |
1236 |
class ExperimentalRadio: |
|
1237 |
class ExperimentalRadio(object):
|
|
1237 | 1238 |
"""Interface for experimental radios""" |
1239 | ||
1238 | 1240 |
@classmethod |
1239 | 1241 |
def get_experimental_warning(cls): |
1240 | 1242 |
return ("This radio's driver is marked as experimental and may " + |
1241 | 1243 |
"be unstable or unsafe to use.") |
1242 | 1244 | |
1243 | 1245 | |
1244 |
class Status: |
|
1246 |
class Status(object):
|
|
1245 | 1247 |
"""Clone status object for conveying clone progress to the UI""" |
1246 | 1248 |
name = "Job" |
1247 | 1249 |
msg = "Unknown" |
... | ... | |
1480 | 1482 |
myfilter = ''.join( |
1481 | 1483 |
[ |
1482 | 1484 |
[replacechar, chr(x)][chr(x) in validcharset] |
1483 |
for x in xrange(256)
|
|
1485 |
for x in range(256) |
|
1484 | 1486 |
]) |
1485 | 1487 |
return astring.translate(myfilter) |
chirp/detect.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2010 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
42 | 43 |
ser.baudrate = 9600 |
43 | 44 |
md = icf.get_model_data(ser) |
44 | 45 |
return _icom_model_data_to_rclass(md) |
45 |
except errors.RadioError, e:
|
|
46 |
except errors.RadioError as e:
|
|
46 | 47 |
LOG.error(e) |
47 | 48 | |
48 | 49 |
# ICOM IC-91/92 Live-mode radios @ 4800/38400 baud |
chirp/drivers/alinco.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# 2016 Matt Weyland <lt-betrieb@hb9uf.ch> |
3 | 4 |
# |
... | ... | |
199 | 200 |
self._mmap = self._download(self._memsize) |
200 | 201 |
except errors.RadioError: |
201 | 202 |
raise |
202 |
except Exception, e:
|
|
203 |
except Exception as e:
|
|
203 | 204 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
204 | 205 |
self.process_mmap() |
205 | 206 | |
... | ... | |
208 | 209 |
self._upload(self._memsize) |
209 | 210 |
except errors.RadioError: |
210 | 211 |
raise |
211 |
except Exception, e:
|
|
212 |
except Exception as e:
|
|
212 | 213 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
213 | 214 | |
214 | 215 |
def get_raw_memory(self, number): |
chirp/drivers/anytone.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2013 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
177 | 178 |
try: |
178 | 179 |
radio.pipe.write(data) |
179 | 180 |
radio.pipe.read(len(data)) |
180 |
except Exception, e:
|
|
181 |
except Exception as e:
|
|
181 | 182 |
LOG.error("Error writing to radio: %s" % e) |
182 | 183 |
raise errors.RadioError("Unable to write to radio") |
183 | 184 | |
... | ... | |
185 | 186 |
def _read(radio, length): |
186 | 187 |
try: |
187 | 188 |
data = radio.pipe.read(length) |
188 |
except Exception, e:
|
|
189 |
except Exception as e:
|
|
189 | 190 |
LOG.error("Error reading from radio: %s" % e) |
190 | 191 |
raise errors.RadioError("Unable to read from radio") |
191 | 192 |
chirp/drivers/anytone_ht.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2015 Jim Unroe <rock.unroe@gmail.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
233 | 234 |
def _echo_write(radio, data): |
234 | 235 |
try: |
235 | 236 |
radio.pipe.write(data) |
236 |
except Exception, e:
|
|
237 |
except Exception as e:
|
|
237 | 238 |
LOG.error("Error writing to radio: %s" % e) |
238 | 239 |
raise errors.RadioError("Unable to write to radio") |
239 | 240 | |
... | ... | |
241 | 242 |
def _read(radio, length): |
242 | 243 |
try: |
243 | 244 |
data = radio.pipe.read(length) |
244 |
except Exception, e:
|
|
245 |
except Exception as e:
|
|
245 | 246 |
LOG.error("Error reading from radio: %s" % e) |
246 | 247 |
raise errors.RadioError("Unable to read from radio") |
247 | 248 | |
... | ... | |
930 | 931 |
else: |
931 | 932 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
932 | 933 |
setattr(obj, setting, element.value) |
933 |
except Exception, e:
|
|
934 |
except Exception as e:
|
|
934 | 935 |
LOG.debug(element.get_name()) |
935 | 936 |
raise |
936 | 937 |
chirp/drivers/ap510.py (revision 83f364736678ae6000c8f4da1e48ab4113b78f69) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2014 Tom Hayward <tom@tomh.us> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
44 | 45 | |
45 | 46 |
def drain(pipe): |
46 | 47 |
"""Chew up any data waiting on @pipe""" |
47 |
for x in xrange(3):
|
|
48 |
for x in range(3): |
|
48 | 49 |
buf = pipe.read(4096) |
49 | 50 |
if not buf: |
50 | 51 |
return |
... | ... | |
53 | 54 | |
54 | 55 |
def enter_setup(pipe): |
55 | 56 |
"""Put AP510 in configuration mode.""" |
56 |
for x in xrange(30):
|
|
57 |
for x in range(30): |
|
57 | 58 |
if x % 2: |
58 | 59 |
pipe.write("@SETUP") |
59 | 60 |
else: |
... | ... | |
84 | 85 |
radio.pipe.write("@DISP") |
85 | 86 |
buf = "" |
86 | 87 | |
87 |
for status.cur in xrange(status.cur, status.max):
|
|
88 |
for status.cur in range(status.cur, status.max): |
|
88 | 89 |
buf += radio.pipe.read(1024) |
89 | 90 |
if buf.endswith("\r\n"): |
90 | 91 |
status.cur = status.max |
... | ... | |
380 | 381 |
data = download(self) |
381 | 382 |
except errors.RadioError: |
382 | 383 |
raise |
383 |
except Exception, e:
|
|
384 |
except Exception as e:
|
|
384 | 385 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
385 | 386 | |
386 | 387 |
# _mmap isn't a Chirp MemoryMap, but since AP510Memory implements |
... | ... | |
398 | 399 |
upload(self) |
399 | 400 |
except errors.RadioError: |
400 | 401 |
raise |
401 |
except Exception, e:
|
|
402 |
except Exception as e:
|
|
402 | 403 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
403 | 404 | |
404 | 405 |
def load_mmap(self, filename): |
405 | 406 |
"""Load the radio's memory map from @filename""" |
406 |
mapfile = file(filename, "rb")
|
|
407 |
mapfile = open(filename, "rb")
|
|
407 | 408 |
data = mapfile.read() |
408 | 409 |
if data.startswith('\r\n00=%s 20141215' % self._model): |
409 | 410 |
self._mmap = AP510Memory20141215(data) |
chirp/drivers/baofeng_common.py (revision 67117ad7beb06c5d5f0d33211d3b06eadbb9059d) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2016: |
2 | 3 |
# * Jim Unroe KC9HI, <rock.unroe@gmail.com> |
3 | 4 |
# |
... | ... | |
14 | 15 |
# You should have received a copy of the GNU General Public License |
15 | 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 17 | |
18 |
from __future__ import print_function |
|
19 | ||
17 | 20 |
"""common functions for Baofeng (or similar) handheld radios""" |
18 | 21 | |
19 | 22 |
import time |
... | ... | |
164 | 167 |
try: |
165 | 168 |
data = _do_ident(radio, magic) |
166 | 169 |
return data |
167 |
except errors.RadioError, e:
|
|
168 |
print e
|
|
170 |
except errors.RadioError as e:
|
|
171 |
print(e)
|
|
169 | 172 |
error = e |
170 | 173 |
time.sleep(2) |
171 | 174 |
if error: |
... | ... | |
604 | 607 |
elif element.value.get_mutable(): |
605 | 608 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
606 | 609 |
setattr(obj, setting, element.value) |
607 |
except Exception, e:
|
|
610 |
except Exception as e:
|
|
608 | 611 |
LOG.debug(element.get_name()) |
609 | 612 |
raise |
610 | 613 | |
... | ... | |
618 | 621 |
value = int(val.get_value() * 10) |
619 | 622 |
LOG.debug("Setting fm_presets = %s" % (value)) |
620 | 623 |
self._memobj.fm_presets = value |
621 |
except Exception, e:
|
|
624 |
except Exception as e:
|
|
622 | 625 |
LOG.debug(element.get_name()) |
623 | 626 |
raise |
chirp/drivers/baofeng_uv3r.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
51 | 52 |
for _i in range(0, 10): |
52 | 53 |
try: |
53 | 54 |
return _uv3r_prep(radio) |
54 |
except errors.RadioError, e:
|
|
55 |
except errors.RadioError as e:
|
|
55 | 56 |
time.sleep(1) |
56 | 57 | |
57 | 58 |
raise e |
... | ... | |
64 | 65 |
return do_download(radio, 0x0000, 0x0E40, 0x0010) |
65 | 66 |
except errors.RadioError: |
66 | 67 |
raise |
67 |
except Exception, e:
|
|
68 |
except Exception as e:
|
|
68 | 69 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
69 | 70 | |
70 | 71 | |
... | ... | |
75 | 76 |
return do_upload(radio, 0x0000, 0x0E40, 0x0010) |
76 | 77 |
except errors.RadioError: |
77 | 78 |
raise |
78 |
except Exception, e:
|
|
79 |
except Exception as e:
|
|
79 | 80 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
80 | 81 | |
81 | 82 | |
... | ... | |
622 | 623 |
else: |
623 | 624 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
624 | 625 |
setattr(obj, setting, element.value) |
625 |
except Exception, e:
|
|
626 |
except Exception as e:
|
|
626 | 627 |
LOG.debug(element.get_name()) |
627 | 628 |
raise |
628 | 629 | |
... | ... | |
638 | 639 |
LOG.debug("Setting fm_presets[%1i] = %s" % (index, value)) |
639 | 640 |
setting = self._memobj.fm_presets |
640 | 641 |
setting[index] = value |
641 |
except Exception, e:
|
|
642 |
except Exception as e:
|
|
642 | 643 |
LOG.debug(element.get_name()) |
643 | 644 |
raise |
644 | 645 |
chirp/drivers/bj9900.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# |
2 | 3 |
# Copyright 2015 Marco Filippi IZ3GME <iz3gme.marco@gmail.com> |
3 | 4 |
# |
... | ... | |
178 | 179 |
self._mmap = self._clone_in() |
179 | 180 |
except errors.RadioError: |
180 | 181 |
raise |
181 |
except Exception, e:
|
|
182 |
except Exception as e:
|
|
182 | 183 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
183 | 184 |
self.process_mmap() |
184 | 185 | |
... | ... | |
187 | 188 |
self._clone_out() |
188 | 189 |
except errors.RadioError: |
189 | 190 |
raise |
190 |
except Exception, e:
|
|
191 |
except Exception as e:
|
|
191 | 192 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
192 | 193 | |
193 | 194 |
def process_mmap(self): |
chirp/drivers/bjuv55.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2013 Jens Jensen AF5MI <kd4tjx@yahoo.com> |
2 | 3 |
# Based on work by Jim Unroe, Dan Smith, et al. |
3 | 4 |
# Special thanks to Mats SM0BTP for equipment donation. |
... | ... | |
647 | 648 |
value = int(val.get_value() * 10 - 870) |
648 | 649 |
LOG.debug("Setting fm_preset = %s" % (value)) |
649 | 650 |
self._memobj.fm_preset = value |
650 |
except Exception, e:
|
|
651 |
except Exception as e:
|
|
651 | 652 |
LOG.debug(element.get_name()) |
652 | 653 |
raise |
chirp/drivers/btech.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2016-2017: |
2 | 3 |
# * Pavel Milanes CO7WT, <pavelmc@gmail.com> |
3 | 4 |
# * Jim Unroe KC9HI, <rock.unroe@gmail.com> |
... | ... | |
396 | 397 | |
397 | 398 |
except errors.RadioError: |
398 | 399 |
raise |
399 |
except Exception, e:
|
|
400 |
except Exception as e:
|
|
400 | 401 |
raise errors.RadioError("Error sending Magic to radio:\n%s" % e) |
401 | 402 | |
402 | 403 | |
... | ... | |
755 | 756 |
_upload(self) |
756 | 757 |
except errors.RadioError: |
757 | 758 |
raise |
758 |
except Exception, e:
|
|
759 |
except Exception as e:
|
|
759 | 760 |
raise errors.RadioError("Error: %s" % e) |
760 | 761 | |
761 | 762 |
def get_raw_memory(self, number): |
... | ... | |
2761 | 2762 |
elif element.value.get_mutable(): |
2762 | 2763 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
2763 | 2764 |
setattr(obj, setting, element.value) |
2764 |
except Exception, e:
|
|
2765 |
except Exception as e:
|
|
2765 | 2766 |
LOG.debug(element.get_name()) |
2766 | 2767 |
raise |
2767 | 2768 |
chirp/drivers/ft1d.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2010 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# Copyright 2014 Angus Ainslie <angus@akkea.ca> |
3 | 4 |
# |
... | ... | |
1617 | 1618 |
except AttributeError as e: |
1618 | 1619 |
LOG.error("Setting %s is not in the memory map: %s" % |
1619 | 1620 |
(element.get_name(), e)) |
1620 |
except Exception, e:
|
|
1621 |
except Exception as e:
|
|
1621 | 1622 |
LOG.debug(element.get_name()) |
1622 | 1623 |
raise |
1623 | 1624 |
chirp/drivers/ft2800.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
201 | 202 |
self._mmap = _download(self) |
202 | 203 |
except errors.RadioError: |
203 | 204 |
raise |
204 |
except Exception, e:
|
|
205 |
except Exception as e:
|
|
205 | 206 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
206 | 207 |
LOG.info("Downloaded in %.2f sec" % (time.time() - start)) |
207 | 208 |
self.process_mmap() |
... | ... | |
214 | 215 |
_upload(self) |
215 | 216 |
except errors.RadioError: |
216 | 217 |
raise |
217 |
except Exception, e:
|
|
218 |
except Exception as e:
|
|
218 | 219 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
219 | 220 |
LOG.info("Uploaded in %.2f sec" % (time.time() - start)) |
220 | 221 |
chirp/drivers/ft2900.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# FT-2900-specific modifications by Richard Cochran, <ag6qr@sonic.net> |
... | ... | |
537 | 538 |
self._mmap = _download(self) |
538 | 539 |
except errors.RadioError: |
539 | 540 |
raise |
540 |
except Exception, e:
|
|
541 |
except Exception as e:
|
|
541 | 542 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
542 | 543 |
LOG.info("Downloaded in %.2f sec" % (time.time() - start)) |
543 | 544 |
self.process_mmap() |
... | ... | |
549 | 550 |
_upload(self) |
550 | 551 |
except errors.RadioError: |
551 | 552 |
raise |
552 |
except Exception, e:
|
|
553 |
except Exception as e:
|
|
553 | 554 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
554 | 555 |
LOG.info("Uploaded in %.2f sec" % (time.time() - start)) |
555 | 556 | |
... | ... | |
1210 | 1211 |
setattr(_settings, name, value) |
1211 | 1212 | |
1212 | 1213 |
LOG.debug("Setting %s: %s" % (name, value)) |
1213 |
except Exception, e:
|
|
1214 |
except Exception as e:
|
|
1214 | 1215 |
LOG.debug(element.get_name()) |
1215 | 1216 |
raise |
1216 | 1217 |
chirp/drivers/ft50.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
587 | 588 |
def _clone_out(radio): |
588 | 589 |
try: |
589 | 590 |
return __clone_out(radio) |
590 |
except Exception, e:
|
|
591 |
except Exception as e:
|
|
591 | 592 |
raise errors.RadioError("Failed to communicate with the radio: %s" % e) |
592 | 593 | |
593 | 594 |
chirp/drivers/ft60.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
403 | 404 |
self._mmap = _download(self) |
404 | 405 |
except errors.RadioError: |
405 | 406 |
raise |
406 |
except Exception, e:
|
|
407 |
except Exception as e:
|
|
407 | 408 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
408 | 409 |
self.process_mmap() |
409 | 410 |
self.check_checksums() |
... | ... | |
414 | 415 |
_upload(self) |
415 | 416 |
except errors.RadioError: |
416 | 417 |
raise |
417 |
except Exception, e:
|
|
418 |
except Exception as e:
|
|
418 | 419 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
419 | 420 | |
420 | 421 |
def process_mmap(self): |
... | ... | |
716 | 717 |
setattr(_settings, name, value) |
717 | 718 | |
718 | 719 |
LOG.debug("Setting %s: %s" % (name, value)) |
719 |
except Exception, e:
|
|
720 |
except Exception as e:
|
|
720 | 721 |
LOG.debug(element.get_name()) |
721 | 722 |
raise |
722 | 723 |
chirp/drivers/ft7800.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2010 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
321 | 322 |
self._mmap = _download(self) |
322 | 323 |
except errors.RadioError: |
323 | 324 |
raise |
324 |
except Exception, e:
|
|
325 |
except Exception as e:
|
|
325 | 326 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
326 | 327 |
LOG.info("Download finished in %i seconds" % (time.time() - start)) |
327 | 328 |
self.check_checksums() |
... | ... | |
337 | 338 |
_upload(self) |
338 | 339 |
except errors.RadioError: |
339 | 340 |
raise |
340 |
except Exception, e:
|
|
341 |
except Exception as e:
|
|
341 | 342 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
342 | 343 |
LOG.info("Upload finished in %i seconds" % (time.time() - start)) |
343 | 344 | |
... | ... | |
766 | 767 |
oldval = getattr(_settings, setting) |
767 | 768 |
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) |
768 | 769 |
setattr(_settings, setting, newval) |
769 |
except Exception, e:
|
|
770 |
except Exception as e:
|
|
770 | 771 |
LOG.debug(element.get_name()) |
771 | 772 |
raise |
772 | 773 |
chirp/drivers/ft8100.py (revision 67117ad7beb06c5d5f0d33211d3b06eadbb9059d) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2010 Eric Allen <eric@hackerengineer.net> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
13 | 14 |
# You should have received a copy of the GNU General Public License |
14 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 16 | |
17 |
from __future__ import print_function |
|
18 | ||
16 | 19 |
import time |
17 | 20 |
import os |
18 | 21 | |
... | ... | |
175 | 178 | |
176 | 179 |
if _mem.duplex == DUPLEX.index("split"): |
177 | 180 |
tx_freq = int(_mem.offset) * 1000 |
178 |
print self.VARIANT, number, tx_freq, mem.freq
|
|
181 |
print(self.VARIANT, number, tx_freq, mem.freq)
|
|
179 | 182 |
mem.offset = tx_freq - mem.freq |
180 | 183 |
else: |
181 | 184 |
mem.offset = int(_mem.offset) * 1000 |
... | ... | |
189 | 192 |
if not self._memobj.enables[byte] & bit and number != 1: |
190 | 193 |
mem.empty = True |
191 | 194 | |
192 |
print 'R', self.VARIANT, number, _mem.baud9600
|
|
195 |
print('R', self.VARIANT, number, _mem.baud9600)
|
|
193 | 196 | |
194 | 197 |
return mem |
195 | 198 | |
... | ... | |
270 | 273 |
def _clone_out(radio): |
271 | 274 |
try: |
272 | 275 |
return __clone_out(radio) |
273 |
except Exception, e:
|
|
276 |
except Exception as e:
|
|
274 | 277 |
raise errors.RadioError("Failed to communicate with the radio: %s" % e) |
275 | 278 | |
276 | 279 | |
... | ... | |
291 | 294 |
pos = 0 |
292 | 295 |
for block in radio._block_lengths: |
293 | 296 |
if os.getenv("CHIRP_DEBUG"): |
294 |
print "\nSending %i-%i" % (pos, pos + block)
|
|
297 |
print("\nSending %i-%i" % (pos, pos + block))
|
|
295 | 298 |
out = radio.get_mmap()[pos:pos + block] |
296 | 299 | |
297 | 300 |
# need to chew byte-by-byte here or else we lose the ACK...not sure why |
... | ... | |
309 | 312 | |
310 | 313 |
pos += block |
311 | 314 | |
312 |
print "Clone completed in %i seconds" % (time.time() - start)
|
|
315 |
print("Clone completed in %i seconds" % (time.time() - start))
|
|
313 | 316 | |
314 | 317 |
return True |
chirp/drivers/ft817.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# |
2 | 3 |
# Copyright 2012 Filippi Marco <iz3gme.marco@gmail.com> |
3 | 4 |
# |
... | ... | |
413 | 414 |
self._mmap = self._clone_in() |
414 | 415 |
except errors.RadioError: |
415 | 416 |
raise |
416 |
except Exception, e:
|
|
417 |
except Exception as e:
|
|
417 | 418 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
418 | 419 |
self.process_mmap() |
419 | 420 | |
... | ... | |
422 | 423 |
self._clone_out() |
423 | 424 |
except errors.RadioError: |
424 | 425 |
raise |
425 |
except Exception, e:
|
|
426 |
except Exception as e:
|
|
426 | 427 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
427 | 428 | |
428 | 429 |
def process_mmap(self): |
chirp/drivers/ft90.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2011 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# Copyright 2013 Jens Jensen AF5MI <kd4tjx@yahoo.com> |
3 | 4 |
# |
... | ... | |
332 | 333 |
self._mmap = self._clone_in() |
333 | 334 |
except errors.RadioError: |
334 | 335 |
raise |
335 |
except Exception, e:
|
|
336 |
except Exception as e:
|
|
336 | 337 |
trace = traceback.format_exc() |
337 | 338 |
raise errors.RadioError( |
338 | 339 |
"Failed to communicate with radio: %s" % trace) |
... | ... | |
343 | 344 |
self._clone_out() |
344 | 345 |
except errors.RadioError: |
345 | 346 |
raise |
346 |
except Exception, e:
|
|
347 |
except Exception as e:
|
|
347 | 348 |
trace = traceback.format_exc() |
348 | 349 |
raise errors.RadioError( |
349 | 350 |
"Failed to communicate with radio: %s" % trace) |
... | ... | |
670 | 671 |
newval = self._dtmf2bbcd(newval) |
671 | 672 |
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) |
672 | 673 |
setattr(_settings, setting, newval) |
673 |
except Exception, e:
|
|
674 |
except Exception as e:
|
|
674 | 675 |
LOG.debug(element.get_name()) |
675 | 676 |
raise |
chirp/drivers/ftm350.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2013 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
275 | 276 |
self._mmap = _clone_in(self) |
276 | 277 |
except errors.RadioError: |
277 | 278 |
raise |
278 |
except Exception, e:
|
|
279 |
except Exception as e:
|
|
279 | 280 |
raise errors.RadioError("Failed to download from radio (%s)" % e) |
280 | 281 |
self.process_mmap() |
281 | 282 | |
... | ... | |
284 | 285 |
_clone_out(self) |
285 | 286 |
except errors.RadioError: |
286 | 287 |
raise |
287 |
except Exception, e:
|
|
288 |
except Exception as e:
|
|
288 | 289 |
raise errors.RadioError("Failed to upload to radio (%s)" % e) |
289 | 290 | |
290 | 291 |
def process_mmap(self): |
chirp/drivers/generic_csv.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
160 | 161 |
val = typ(val) |
161 | 162 |
if hasattr(mem, attr): |
162 | 163 |
setattr(mem, attr, val) |
163 |
except OmittedHeaderError, e:
|
|
164 |
except OmittedHeaderError as e:
|
|
164 | 165 |
pass |
165 |
except Exception, e:
|
|
166 |
except Exception as e:
|
|
166 | 167 |
raise Exception("[%s] %s" % (attr, e)) |
167 | 168 | |
168 | 169 |
return self._clean(headers, line, mem) |
... | ... | |
176 | 177 | |
177 | 178 |
self._blank() |
178 | 179 | |
179 |
f = file(self._filename, "rU")
|
|
180 |
f = open(self._filename, "rU")
|
|
180 | 181 |
header = f.readline().strip() |
181 | 182 | |
182 | 183 |
f.seek(0, 0) |
... | ... | |
203 | 204 |
mem = self._parse_csv_data_line(header, line) |
204 | 205 |
if mem.number is None: |
205 | 206 |
raise Exception("Invalid Location field" % lineno) |
206 |
except Exception, e:
|
|
207 |
except Exception as e:
|
|
207 | 208 |
LOG.error("Line %i: %s", lineno, e) |
208 | 209 |
self.errors.append("Line %i: %s" % (lineno, e)) |
209 | 210 |
continue |
... | ... | |
223 | 224 |
if filename: |
224 | 225 |
self._filename = filename |
225 | 226 | |
226 |
f = file(self._filename, "wb")
|
|
227 |
f = open(self._filename, "wb")
|
|
227 | 228 |
writer = csv.writer(f, delimiter=chirp_common.SEPCHAR) |
228 | 229 |
writer.writerow(chirp_common.Memory.CSV_FORMAT) |
229 | 230 |
chirp/drivers/generic_xml.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
29 | 30 |
try: |
30 | 31 |
ctx = libxml2.schemaNewParserCtxt(path) |
31 | 32 |
schema = ctx.schemaParse() |
32 |
except libxml2.parserError, e:
|
|
33 |
except libxml2.parserError as e:
|
|
33 | 34 |
LOG.error("Unable to load schema: %s" % e) |
34 | 35 |
LOG.error("Path: %s" % path) |
35 | 36 |
raise errors.RadioError("Unable to load schema") |
... | ... | |
118 | 119 |
if filename: |
119 | 120 |
self._filename = filename |
120 | 121 | |
121 |
f = file(self._filename, "w")
|
|
122 |
f = open(self._filename, "w")
|
|
122 | 123 |
f.write(self.doc.serialize(format=1)) |
123 | 124 |
f.close() |
124 | 125 |
chirp/drivers/h777.py (revision ea406febfb9647e8400cf9d023352fc318ec8fd1) | ||
---|---|---|
521 | 521 |
else: |
522 | 522 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
523 | 523 |
setattr(obj, setting, element.value) |
524 |
except Exception, e:
|
|
524 |
except Exception as e:
|
|
525 | 525 |
LOG.debug(element.get_name()) |
526 | 526 |
raise |
527 | 527 |
chirp/drivers/ic9x.py (revision 67117ad7beb06c5d5f0d33211d3b06eadbb9059d) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
13 | 14 |
# You should have received a copy of the GNU General Public License |
14 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 16 | |
17 |
from __future__ import print_function |
|
18 | ||
16 | 19 |
import time |
17 | 20 |
import threading |
18 | 21 |
import logging |
... | ... | |
181 | 184 |
LOG.debug("Done: %s" % mem) |
182 | 185 |
except errors.InvalidMemoryLocation: |
183 | 186 |
pass |
184 |
except errors.InvalidDataError, e:
|
|
187 |
except errors.InvalidDataError as e:
|
|
185 | 188 |
LOG.error("Error talking to radio: %s" % e) |
186 | 189 |
break |
187 | 190 | |
... | ... | |
417 | 420 |
import serial |
418 | 421 |
ser = IC9xRadioB(serial.Serial(port="/dev/ttyUSB1", |
419 | 422 |
baudrate=38400, timeout=0.1)) |
420 |
print ser.get_urcall_list()
|
|
421 |
print "-- FOO --"
|
|
423 |
print(ser.get_urcall_list())
|
|
424 |
print("-- FOO --")
|
|
422 | 425 |
ser.set_urcall_list(["K7TAY", "FOOBAR", "BAZ"]) |
423 | 426 | |
424 | 427 |
chirp/drivers/ic9x_ll.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
60 | 61 |
try: |
61 | 62 |
start = buf.index("\xfe\xfe") |
62 | 63 |
end = buf[start:].index("\xfd") + start + 1 |
63 |
except Exception, e:
|
|
64 |
except Exception as e:
|
|
64 | 65 |
LOG.error("No trailing bit") |
65 | 66 |
break |
66 | 67 | |
... | ... | |
71 | 72 |
frame = IC92Frame() |
72 | 73 |
frame.from_raw(framedata[2:-1]) |
73 | 74 |
frames.append(frame) |
74 |
except errors.InvalidDataError, e:
|
|
75 |
except errors.InvalidDataError as e:
|
|
75 | 76 |
LOG.error("Broken frame: %s" % e) |
76 | 77 | |
77 | 78 |
# LOG.debug("Parsed %i frames" % len(frames)) |
... | ... | |
102 | 103 |
return _ic9x_parse_frames(data) |
103 | 104 | |
104 | 105 | |
105 |
class IC92Frame: |
|
106 |
class IC92Frame(object):
|
|
106 | 107 |
"""IC9x frame base class""" |
108 | ||
107 | 109 |
def get_vfo(self): |
108 | 110 |
"""Return the vfo number""" |
109 | 111 |
return ord(self._map[0]) |
... | ... | |
153 | 155 |
return response[0] |
154 | 156 | |
155 | 157 |
def __setitem__(self, start, value): |
156 |
self._map[start+4] = value
|
|
158 |
self._map[start + 4] = value
|
|
157 | 159 | |
158 | 160 |
def __getitem__(self, index): |
159 |
return self._map[index+4]
|
|
161 |
return self._map[index + 4]
|
|
160 | 162 | |
161 | 163 |
def __getslice__(self, start, end): |
162 |
return self._map[start+4:end+4]
|
|
164 |
return self._map[start + 4:end + 4]
|
|
163 | 165 | |
164 | 166 | |
165 | 167 |
class IC92GetBankFrame(IC92Frame): |
chirp/drivers/icf.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
32 | 33 |
SAVE_PIPE = None |
33 | 34 | |
34 | 35 | |
35 |
class IcfFrame: |
|
36 |
class IcfFrame(object):
|
|
36 | 37 |
"""A single ICF communication frame""" |
37 | 38 |
src = 0 |
38 | 39 |
dst = 0 |
... | ... | |
77 | 78 |
return frame, data[end+1:] |
78 | 79 | |
79 | 80 | |
80 |
class RadioStream: |
|
81 |
class RadioStream(object):
|
|
81 | 82 |
"""A class to make reading a stream of IcfFrames easier""" |
83 | ||
82 | 84 |
def __init__(self, pipe): |
83 | 85 |
self.pipe = pipe |
84 | 86 |
self.data = "" |
... | ... | |
108 | 110 |
frames.append(frame) |
109 | 111 | |
110 | 112 |
self.data = rest |
111 |
except errors.InvalidDataError, e:
|
|
113 |
except errors.InvalidDataError as e:
|
|
112 | 114 |
LOG.error("Failed to parse frame (cmd=%i): %s" % (cmd, e)) |
113 | 115 |
return [] |
114 | 116 | |
... | ... | |
213 | 215 |
val = int("%s%s" % (bcddata[i], bcddata[i+1]), 16) |
214 | 216 |
i += 2 |
215 | 217 |
data += struct.pack("B", val) |
216 |
except ValueError, e:
|
|
218 |
except ValueError as e:
|
|
217 | 219 |
LOG.error("Failed to parse byte: %s" % e) |
218 | 220 |
break |
219 | 221 | |
... | ... | |
321 | 323 |
"""Do a full clone out of the radio's memory""" |
322 | 324 |
try: |
323 | 325 |
return _clone_from_radio(radio) |
324 |
except Exception, e:
|
|
326 |
except Exception as e:
|
|
325 | 327 |
raise errors.RadioError("Failed to communicate with the radio: %s" % e) |
326 | 328 | |
327 | 329 | |
... | ... | |
361 | 363 |
global SAVE_PIPE |
362 | 364 | |
363 | 365 |
# Uncomment to save out a capture of what we actually write to the radio |
364 |
# SAVE_PIPE = file("pipe_capture.log", "w", 0)
|
|
366 |
# SAVE_PIPE = open("pipe_capture.log", "w", 0)
|
|
365 | 367 | |
366 | 368 |
md = get_model_data(radio.pipe) |
367 | 369 | |
... | ... | |
411 | 413 |
"""Initiate a full memory clone out to @radio""" |
412 | 414 |
try: |
413 | 415 |
return _clone_to_radio(radio) |
414 |
except Exception, e:
|
|
416 |
except Exception as e:
|
|
415 | 417 |
raise errors.RadioError("Failed to communicate with the radio: %s" % e) |
416 | 418 | |
417 | 419 | |
... | ... | |
449 | 451 |
val = int("%s%s" % (data[i], data[i+1]), 16) |
450 | 452 |
i += 2 |
451 | 453 |
_mmap += struct.pack("B", val) |
452 |
except ValueError, e:
|
|
454 |
except ValueError as e:
|
|
453 | 455 |
LOG.debug("Failed to parse byte: %s" % e) |
454 | 456 |
break |
455 | 457 | |
... | ... | |
458 | 460 | |
459 | 461 |
def read_file(filename): |
460 | 462 |
"""Read an ICF file and return the model string and memory data""" |
461 |
f = file(filename)
|
|
463 |
f = open(filename)
|
|
462 | 464 | |
463 | 465 |
mod_str = f.readline() |
464 | 466 |
dat = f.readlines() |
... | ... | |
475 | 477 | |
476 | 478 |
def is_9x_icf(filename): |
477 | 479 |
"""Returns True if @filename is an IC9x ICF file""" |
478 |
f = file(filename)
|
|
480 |
f = open(filename)
|
|
479 | 481 |
mdata = f.read(8) |
480 | 482 |
f.close() |
481 | 483 | |
... | ... | |
484 | 486 | |
485 | 487 |
def is_icf_file(filename): |
486 | 488 |
"""Returns True if @filename is an ICF file""" |
487 |
f = file(filename)
|
|
489 |
f = open(filename)
|
|
488 | 490 |
data = f.readline() |
489 | 491 |
data += f.readline() |
490 | 492 |
f.close() |
chirp/drivers/icq7.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2010 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
338 | 339 |
else: |
339 | 340 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
340 | 341 |
setattr(obj, setting, element.value) |
341 |
except Exception, e:
|
|
342 |
except Exception as e:
|
|
342 | 343 |
LOG.debug(element.get_name()) |
343 | 344 |
raise |
chirp/drivers/kenwood_hmk.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# Copyright 2012 Tom Hayward <tom@tomh.us> |
3 | 4 |
# |
... | ... | |
79 | 80 | |
80 | 81 |
self._blank() |
81 | 82 | |
82 |
f = file(self._filename, "r")
|
|
83 |
f = open(self._filename, "r")
|
|
83 | 84 |
for line in f: |
84 | 85 |
if line.strip() == "// Memory Channels": |
85 | 86 |
break |
... | ... | |
114 | 115 |
mem = self._parse_csv_data_line(header, line) |
115 | 116 |
if mem.number is None: |
116 | 117 |
raise Exception("Invalid Location field" % lineno) |
117 |
except Exception, e:
|
|
118 |
except Exception as e:
|
|
118 | 119 |
LOG.error("Line %i: %s" % (lineno, e)) |
119 | 120 |
self.errors.append("Line %i: %s" % (lineno, e)) |
120 | 121 |
continue |
chirp/drivers/kenwood_itm.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2008 Dan Smith <dsmith@danplanet.com> |
2 | 3 |
# Copyright 2012 Tom Hayward <tom@tomh.us> |
3 | 4 |
# |
... | ... | |
85 | 86 | |
86 | 87 |
self._blank() |
87 | 88 | |
88 |
f = file(self._filename, "r")
|
|
89 |
f = open(self._filename, "r")
|
|
89 | 90 |
for line in f: |
90 | 91 |
if line.strip() == "// Conventional Data": |
91 | 92 |
break |
... | ... | |
118 | 119 |
mem = self._parse_csv_data_line(header, line) |
119 | 120 |
if mem.number is None: |
120 | 121 |
raise Exception("Invalid Location field" % lineno) |
121 |
except Exception, e:
|
|
122 |
except Exception as e:
|
|
122 | 123 |
LOG.error("Line %i: %s" % (lineno, e)) |
123 | 124 |
self.errors.append("Line %i: %s" % (lineno, e)) |
124 | 125 |
continue |
chirp/drivers/kguv8d.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2014 Ron Wellsted <ron@m0rnw.uk> M0RNW |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
376 | 377 |
self._mmap = self._download() |
377 | 378 |
except errors.RadioError: |
378 | 379 |
raise |
379 |
except Exception, e:
|
|
380 |
except Exception as e:
|
|
380 | 381 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
381 | 382 |
self.process_mmap() |
382 | 383 | |
... | ... | |
393 | 394 |
return self._do_download(0, 32768, 64) |
394 | 395 |
except errors.RadioError: |
395 | 396 |
raise |
396 |
except Exception, e:
|
|
397 |
except Exception as e:
|
|
397 | 398 |
LOG.exception('Unknown error during download process') |
398 | 399 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
399 | 400 | |
... | ... | |
426 | 427 |
self._do_upload(0, 32768, 64) |
427 | 428 |
except errors.RadioError: |
428 | 429 |
raise |
429 |
except Exception, e:
|
|
430 |
except Exception as e:
|
|
430 | 431 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
431 | 432 |
return |
432 | 433 |
chirp/drivers/kyd.py (revision 94e21deb6ff7fc0f21a42d81f020121b059c1b8a) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2014 Jim Unroe <rock.unroe@gmail.com> |
2 | 3 |
# Copyright 2014 Dan Smith <dsmith@danplanet.com> |
3 | 4 |
# |
... | ... | |
499 | 500 | |
500 | 501 |
LOG.debug("Setting %s = %s" % (setting, element.value)) |
501 | 502 |
setattr(obj, setting, element.value) |
502 |
except Exception, e:
|
|
503 |
except Exception as e:
|
|
503 | 504 |
LOG.debug(element.get_name()) |
504 | 505 |
raise |
505 | 506 |
chirp/drivers/kyd_IP620.py (revision 67117ad7beb06c5d5f0d33211d3b06eadbb9059d) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2015 Lepik.stv <lepik.stv@gmail.com> |
2 | 3 |
# based on modification of Dan Smith's and Jim Unroe original work |
3 | 4 |
# |
... | ... | |
14 | 15 |
# You should have received a copy of the GNU General Public License |
15 | 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 17 | |
18 |
from __future__ import print_function |
|
19 | ||
17 | 20 |
"""KYD IP-620 radios management module""" |
18 | 21 | |
19 | 22 |
# TODO: Power on message |
... | ... | |
181 | 184 |
self.pipe.write("\x06") |
182 | 185 |
except errors.RadioError: |
183 | 186 |
raise |
184 |
except Exception, e:
|
|
187 |
except Exception as e:
|
|
185 | 188 |
raise errors.RadioError("Radio refused to exit programming mode: %s" % e) |
186 | 189 | |
187 | 190 |
def _ip620_enter_programming_mode(self): |
... | ... | |
192 | 195 |
_ack = self.pipe.read(1) |
193 | 196 |
except errors.RadioError: |
194 | 197 |
raise |
195 |
except Exception, e:
|
|
198 |
except Exception as e:
|
|
196 | 199 |
raise errors.RadioError("Error communicating with radio: %s" % e) |
197 | 200 |
if not _ack: |
198 | 201 |
raise errors.RadioError("No response from radio") |
... | ... | |
203 | 206 |
_ident = self.pipe.read(8) |
204 | 207 |
except errors.RadioError: |
205 | 208 |
raise |
206 |
except Exception, e:
|
|
209 |
except Exception as e:
|
|
207 | 210 |
raise errors.RadioError("Error communicating with radio: %s" % e) |
208 | 211 |
if not _ident.startswith("\x06\x4B\x47\x36\x37\x01\x56\xF8"): |
209 |
print util.hexprint(_ident)
|
|
212 |
print(util.hexprint(_ident))
|
|
210 | 213 |
raise errors.RadioError("Radio returned unknown identification string") |
211 | 214 |
try: |
212 | 215 |
self.pipe.write(CMD_ACK) |
213 | 216 |
_ack = self.pipe.read(1) |
214 | 217 |
except errors.RadioError: |
215 | 218 |
raise |
216 |
except Exception, e:
|
|
219 |
except Exception as e:
|
|
217 | 220 |
raise errors.RadioError("Error communicating with radio: %s" % e) |
218 | 221 |
if _ack != CMD_ACK: |
219 | 222 |
raise errors.RadioError("Radio refused to enter programming mode") |
... | ... | |
316 | 319 |
self._mmap = self._do_download() |
317 | 320 |
except errors.RadioError: |
318 | 321 |
raise |
319 |
except Exception, e:
|
|
322 |
except Exception as e:
|
|
320 | 323 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
321 | 324 |
self.process_mmap() |
322 | 325 | |
... | ... | |
595 | 598 |
setattr(self._memobj.settings_misc, |
596 | 599 |
element.get_name(), |
597 | 600 |
element.value) |
598 |
except Exception, e:
|
|
601 |
except Exception as e:
|
|
599 | 602 |
LOG.debug(element.get_name()) |
600 | 603 |
raise |
601 | 604 | |
... | ... | |
622 | 625 |
setattr(_settings_misc, setting, newval) |
623 | 626 |
else: |
624 | 627 |
setattr(_settings, setting, newval) |
625 |
except Exception, e:
|
|
628 |
except Exception as e:
|
|
626 | 629 |
LOG.debug(element.get_name()) |
627 | 630 |
raise |
chirp/drivers/leixen.py (revision 83f364736678ae6000c8f4da1e48ab4113b78f69) | ||
---|---|---|
1 |
# coding=utf-8 |
|
1 | 2 |
# Copyright 2014 Tom Hayward <tom@tomh.us> |
2 | 3 |
# |
3 | 4 |
# This program is free software: you can redistribute it and/or modify |
... | ... | |
225 | 226 |
] |
226 | 227 | |
227 | 228 |
MODES = ["NFM", "FM"] |
228 |
WTFTONES = map(float, xrange(56, 64))
|
|
229 |
WTFTONES = map(float, range(56, 64)) |
|
229 | 230 |
TONES = WTFTONES + chirp_common.TONES |
230 | 231 |
DTCS_CODES = [17, 50, 645] + chirp_common.DTCS_CODES |
231 | 232 |
DTCS_CODES.sort() |
... | ... | |
260 | 261 |
# util.hexprint(frame).replace("\n", "\n "))) |
261 | 262 |
try: |
262 | 263 |
radio.pipe.write(frame) |
263 |
except Exception, e:
|
|
264 |
except Exception as e:
|
|
264 | 265 |
raise errors.RadioError("Failed to communicate with radio: %s" % e) |
265 | 266 | |
266 | 267 | |
... | ... | |
425 | 426 |
def sync_in(self): |
426 | 427 |
try: |