diff --git a/memed.py b/memed.py index 2491018..b64eed4 100644 --- a/memed.py +++ b/memed.py @@ -33,9 +33,9 @@ bot = None async def wrap(coro): try: await coro() - except ConnectionError as e: - log.warning('connection err: %r', e) - except: + except ConnectionError as err: + log.warning(f'connection err: {err!r}') + except Exception: log.exception('error inside wrapped') @@ -56,10 +56,10 @@ def parse_logstr(string): lst = important.replace('[', '').replace(']', '').split() # filder uid and cwd - s = [s.split(':') for s in lst if 'uid' in s or 'cwd' in s] + spl = [s.split(':') for s in lst if 'uid' in s or 'cwd' in s] - uid = [e[1] for e in s if e[0] == 'uid'][0] - cwd = [e[1] for e in s if e[0] == 'cwd'][0] + uid = [e[1] for e in spl if e[0] == 'uid'][0] + cwd = [e[1] for e in spl if e[0] == 'cwd'][0] return int(uid), cwd, command @@ -81,6 +81,7 @@ class MemeClient: return op, data async def read_payload(self) -> dict: + """Read a payload from the socket.""" op, message = await self.read_msg() if op > 10: return op, json.loads(message) @@ -131,10 +132,12 @@ class MemeClient: return await self.send_msg(1, 'no rsudo cog') log.info('[process] got rsudo! %r', message) + + # this doesnt wait for the thing self.loop.create_task(rsudo.request(message)) - return await self.send_msg(1, int(True)) + return await self.send_msg(1, "true") elif op == 3: - # handle rsudo, waitinG + # handle rsudo, steroid version if not bot: return await self.send_msg(1, 'no bot') @@ -143,8 +146,10 @@ class MemeClient: return await self.send_msg(1, 'no rsudo cog') log.info('[process - wait] %r', message) + # this does ok = await rsudo.request(message, True) - return await self.send_msg(1, int(ok)) + ok_str = 'true' if ok else 'false' + return await self.send_msg(1, ok_str) async def client_loop(self): try: