From 6f74b5c765fd4d8a5182927a5d545622580649dc Mon Sep 17 00:00:00 2001 From: jay817 Date: Thu, 29 Aug 2024 23:01:21 -0400 Subject: [PATCH] Update jimm.py --- jimm.py | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/jimm.py b/jimm.py index 8cf27a4..7ca7714 100644 --- a/jimm.py +++ b/jimm.py @@ -1,4 +1,12 @@ -import os, asyncio, contextlib, multiprocessing +import os, asyncio, contextlib, multiprocessing, threading +from inspect import iscoroutinefunction + +def go(func, *args, **kwargs): + if iscoroutinefunction(func): + target = lambda: asyncio.runners.run(func(*args, **kwargs)) + else: + target = lambda: func(*args, **kwargs) + multiprocessing.Process(target=target).start() unsafe = contextlib.suppress(Exception) @@ -7,7 +15,35 @@ with unsafe: asyncio.run = lambda main: threading.Thread( target=lambda: asyncio.runners.run(main)).start() -def go(func, *args, **kwargs): - multiprocessing.Process(target=func, args=args, kwargs=kwargs).start() +os.environ['DISPLAY'] = ':0' -os.environ['DISPLAY'] = ':0' \ No newline at end of file +import rich, rich.theme, rich.traceback +console = rich.console.Console(width=75, + theme=rich.theme.Theme({ + 'inspect.callable': 'bold color(114)', # inspect + 'inspect.attr': 'white', + 'inspect.help': 'white', + 'inspect.def': 'color(69)', + 'inspect.class': 'color(69)', + 'repr.tag_name': 'color(43)', # repr + 'repr.tag_contents': 'white', + 'repr.bool_true': 'color(77)', # True, False, None + 'repr.bool_false': 'color(161)', + 'repr.none': 'white', + 'repr.attrib_name': 'color(216)', # Name + 'repr.call': 'color(111)', + 'repr.tag_name': 'color(38)', + 'repr.number': 'bold color(113)', + 'repr.str': 'color(183)', + 'traceback.title': 'color(160)', # Traceback + 'traceback.exc_type': 'color(160)', + 'traceback.border': 'color(203)', + 'traceback.error': 'white', + 'traceback.border.syntax_error': 'white', + 'traceback.text': 'white', + 'traceback.exc_value': 'white', + 'traceback.offset': 'white', + 'scope.border': 'color(111)'})) +rich.traceback.install(console=console) +def inspect(obj): + rich.inspect(obj, methods=True, console=console) \ No newline at end of file