MCPcopy
hub / github.com/AsahiLinux/m1n1 / run_shell

Function run_shell

proxyclient/m1n1/shell.py:132–215  ·  view source on GitHub ↗
(locals, msg=None, exitmsg=None, poll_func=None)

Source from the content-addressed store, hash-verified

130# InteractiveConsole with. It adds in the callables
131# in proxy utils iface and sysreg into locals
132def run_shell(locals, msg=None, exitmsg=None, poll_func=None):
133 saved_display = sys.displayhook
134 try:
135 def display(val):
136 if isinstance(val, int) and not isinstance(val, bool):
137 builtins._ = val
138 print(hex(val))
139 elif callable(val):
140 val()
141 else:
142 saved_display(val)
143
144 sys.displayhook = display
145
146 # convenience
147 locals["h"] = hex
148 locals["sysreg"] = sysreg
149
150 if "proxy" in locals and "p" not in locals:
151 locals["p"] = locals["proxy"]
152 if "utils" in locals and "u" not in locals:
153 locals["u"] = locals["utils"]
154
155 for obj_name in ("iface", "p", "u"):
156 obj = locals.get(obj_name)
157 obj_class = type(obj)
158 if obj is None:
159 continue
160
161 for attr in dir(obj_class):
162 if attr in locals or attr.startswith('_'):
163 continue
164
165 member = getattr(obj_class, attr)
166 if callable(member) and not isinstance(member, property):
167 cmd = getattr(obj, attr)
168 locals[attr] = cmd
169
170 for attr in dir(sysreg):
171 locals[attr] = getattr(sysreg, attr)
172
173 locals['help'] = help_cmd
174 locals['debug'] = debug_cmd
175 for obj_name in locals.keys():
176 obj = locals.get(obj_name)
177 if obj is None or obj_name.startswith('_'):
178 continue
179 if callable(obj) and not isinstance(obj, property):
180 try:
181 desc = obj_name + str(signature(obj))
182 except:
183 continue
184 qn = obj.__qualname__
185 if qn.find('.') > 0:
186 a = qn.split('.')
187 if a[0] not in subcmd_list:
188 subcmd_list[a[0]] = {}
189 if a[0] not in cmd_list:

Callers 15

smccli.pyFile · 0.90
run_guest.pyFile · 0.90
codecshell.pyFile · 0.90
shell.pyFile · 0.90
dcpext_iboot.pyFile · 0.90
aes.pyFile · 0.90
smc_watcher.pyFile · 0.90
dcp_iboot.pyFile · 0.90
dcp.pyFile · 0.90
aop_audio.pyFile · 0.90
agx_boot.pyFile · 0.90
pmp_init.pyFile · 0.90

Calls 4

save_historyMethod · 0.95
HistoryConsoleClass · 0.85
getMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected