Skip to content

Commit

Permalink
fix: fix errors & complaints found by flake8
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
  • Loading branch information
SpotlightKid committed Nov 13, 2023
1 parent 87c3e28 commit fb55d93
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
ignore: E701
ignore: E701,E128
max-complexity: 13
max-line-length: 99
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_create_message_midi_fromtuple(self):
self.assertMessage(b'/midi\0\0\0,m\0\0\0\xB0 \0', '/midi',
('m', (0, 0xB0, 32, 0)))

def test_create_message_midi_fromtuple(self):
def test_create_message_midi_fromlist(self):
self.assertMessage(b'/midi\0\0\0,m\0\0\0\xB0 \0', '/midi',
('m', [0, 0xB0, 32, 0]))

Expand Down
4 changes: 2 additions & 2 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def run_loadtest(c):
c.send('/foo', 42, 23)
e = time.time()
if e - s > 5.0:
print("{} req/s".format(nreq/5.0))
print("{} req/s".format(nreq / 5.0))
nreq = 0
s = time.time()


if __name__ == '__main__':
c = Client(9001)
try:
run_loadtest(c)
except KeyboardInterrupt:
pass

3 changes: 0 additions & 3 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ def test_parse_message_float(self):
def test_parse_message_str(self):
self.assertMessage(('/s', 's', ('foo',)), b'/s\0\0,s\0\0foo\0')

def test_parse_message_float(self):
self.assertMessage(('/f', 'f', (42.0,)), b'/f\0\0,f\0\0B(\0\0')

def test_parse_message_blob(self):
self.assertMessage(('/b', 'b', (b'\xDE\xAD\xBE\xEF',)),
b'/b\0\0,b\0\0\0\0\0\x04\xDE\xAD\xBE\xEF')
Expand Down
13 changes: 8 additions & 5 deletions uosc/fakelogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

DEBUG = WARNING = INFO = ERROR = CRITICAL = None


class Logger:
def __init__(self, name):
self.name = name

def log(self, level=DEBUG, msg="", *args):
print("%s: %s" % (self.name, msg % args), file=sys.stderr)

def debug(self, msg, *args):
self.log(DEBUG, msg, *args)

exception = critical = error = warning = info = debug


log = Logger("uosc.fakelogger")


def basicConfig(*args, **kwargs):
pass



def getLogger(name):
return log

4 changes: 1 addition & 3 deletions uosc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ def handle_osc(data, src, dispatch=None, strict=False):
messages = parse_bundle(data, strict)
except Exception as exc:
if __debug__:
log.debug("Could not parse message from %s:%i: %s",
*get_hostport(src), exc)
log.debug("Could not parse message from %r: %s", src, exc)
log.debug("Data: %r", data)
return

Expand All @@ -143,4 +142,3 @@ def handle_osc(data, src, dispatch=None, strict=False):
dispatch(timetag, (oscaddr, tags, args, src))
except Exception as exc:
log.error("Exception in OSC handler: %s", exc)

0 comments on commit fb55d93

Please sign in to comment.