send strings instead of ints

This commit is contained in:
Luna Mendes 2018-01-20 17:46:55 -03:00
parent 6c435d5c3e
commit 740e82eb91

View file

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