Update jimm.py
This commit is contained in:
44
jimm.py
44
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'
|
||||
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)
|
||||
Reference in New Issue
Block a user