diff --git a/setup.cfg b/setup.cfg index 064b462..b7b47cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,4 @@ [flake8] -ignore: E701 +ignore: E701,E128 +max-complexity: 13 +max-line-length: 99 diff --git a/tests/test_client.py b/tests/test_client.py index 88fed89..d1c0a2c 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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])) diff --git a/tests/test_load.py b/tests/test_load.py index 5a651ce..6a98533 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -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 - diff --git a/tests/test_server.py b/tests/test_server.py index 60625c5..33e5956 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -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') diff --git a/uosc/fakelogging.py b/uosc/fakelogging.py index 2438a1d..55b3d10 100644 --- a/uosc/fakelogging.py +++ b/uosc/fakelogging.py @@ -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 - diff --git a/uosc/server.py b/uosc/server.py index b8b0da6..8e7e2a9 100644 --- a/uosc/server.py +++ b/uosc/server.py @@ -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 @@ -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) -