Skip to content

Commit

Permalink
Merge pull request #4 from thomasbaden/format_updates
Browse files Browse the repository at this point in the history
Format updates
  • Loading branch information
KM4YRI committed Feb 21, 2021
2 parents 4404afc + 488a57c commit b6bd14c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyfldigi/client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def send(self, data, block=True, timeout=10):
if time.time() - tx_start >= timeout:
raise TimeoutError('Timeout while transmitting, waiting for first byte to go out')
else:
raise Exception('cannot transmit if FLDIGI state is \'{}\''.format(state))
raise Exception('cannot transmit if FLDIGI state is {!r}'.format(state))

if block is True:
while(1):
Expand Down
10 changes: 5 additions & 5 deletions pyfldigi/client/txmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def __str__(self):
else:
data = str(self.data)
if len(self.data) > 25:
data = '\'{}\'... (length={})'.format(data[0:25], len(data))
data = '{!r}... (length={})'.format(data[:25], len(data))
else:
data = '\'{}\''.format(data)
data = '{!r}'.format(data)
return 'T={:.3f}s: {}'.format(self.time, data)


Expand All @@ -74,8 +74,8 @@ def __init__(self, initialState='RX', max_history=900):
self.txdata_history = []

def __str__(self):
s = 'State History:\n{}\n'.format('\n'.join([' {}'.format(str(i)) for i in self.state_history]))
s += 'TX data History:\n{}\n'.format('\n'.join([' {}'.format(str(i)) for i in self.txdata_history]))
s = 'State History:\n{}\n'.format('\n'.join(' {}'.format(str(i)) for i in self.state_history))
s += 'TX data History:\n{}\n'.format('\n'.join(' {}'.format(str(i)) for i in self.txdata_history))
s += 'Last TX time was: {}\n'.format(self.get_last_txdata_time())
return s

Expand Down Expand Up @@ -201,7 +201,7 @@ def run(self):

except Exception as e:
raise
print('TXMONITOR: Exception: {}'.format(e))
self.logger.exception('TXMONITOR: Exception')
pass # Daemon threads might run after python starts shutting down. Ignore errors.
self.heartbeat = time.time()
time.sleep(self.interval)
Expand Down
9 changes: 5 additions & 4 deletions pyfldigi/xmlconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def read(self):
self.tree = ElementTree.parse(self.location)
self.root = self.tree.getroot()
if not self.root.tag == 'FLDIGI_DEFS':
raise Exception('Expected root tag to be \'FLDIGI_DEFS\' but got {}'.format(self.root.tag))
raise Exception('Expected root tag to be \'FLDIGI_DEFS\' but got {!r}'.format(self.root.tag))
for child in self.root:
self.settings[str(child.tag).lower()] = child.text

Expand Down Expand Up @@ -89,9 +89,10 @@ def __str__(self):
SETTING2 : 1
# and so on
'''
s = ''
for key, value in self.settings.items():
s += ('{} : {}\n'.format(key, value))
s = ''.join(
'{} : {}\n'.format(key, value)
for key, value in self.settings.items()
)
return s

def __getitem__(self, key):
Expand Down

0 comments on commit b6bd14c

Please sign in to comment.