本文整理汇总了Python中IPython.terminal.interactiveshell.TerminalInteractiveShell.mainloop方法的典型用法代码示例。如果您正苦于以下问题:Python TerminalInteractiveShell.mainloop方法的具体用法?Python TerminalInteractiveShell.mainloop怎么用?Python TerminalInteractiveShell.mainloop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.terminal.interactiveshell.TerminalInteractiveShell
的用法示例。
在下文中一共展示了TerminalInteractiveShell.mainloop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import mainloop [as 别名]
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cto_tree.settings")
try:
if len(sys.argv) >= 2 and sys.argv[1] == '--plain':
raise ImportError
user_ns = locals()
if has_ushell:
app = UmengIPythonApp.instance()
app.initialize()
app.shell.user_ns.update(user_ns)
sys.exit(app.start())
else:
from IPython.terminal.interactiveshell import TerminalInteractiveShell
shell = TerminalInteractiveShell(user_ns=user_ns)
shell.mainloop()
except ImportError:
import code
shell = code.InteractiveConsole(locals=locals())
shell.interact()
示例2: interactive
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import mainloop [as 别名]
def interactive(idx=0, DongleClass=RfCat, intro=''):
global d
import rflib.chipcon_nic as rfnic
import atexit
d = DongleClass(idx=idx)
d.setModeRX() # this puts the dongle into receive mode
atexit.register(cleanupInteractiveAtExit)
gbls = globals()
lcls = locals()
try:
import IPython.Shell
ipsh = IPython.Shell.IPShell(argv=[''], user_ns=lcls, user_global_ns=gbls)
print intro
ipsh.mainloop(intro)
except ImportError, e:
try:
from IPython.terminal.interactiveshell import TerminalInteractiveShell
ipsh = TerminalInteractiveShell()
ipsh.user_global_ns.update(gbls)
ipsh.user_global_ns.update(lcls)
ipsh.autocall = 2 # don't require parenthesis around *everything*. be smart!
ipsh.mainloop(intro)
except ImportError, e:
try:
from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
ipsh = TerminalInteractiveShell()
ipsh.user_global_ns.update(gbls)
ipsh.user_global_ns.update(lcls)
ipsh.autocall = 2 # don't require parenthesis around *everything*. be smart!
ipsh.mainloop(intro)
except ImportError, e:
print e
shell = code.InteractiveConsole(gbls)
shell.interact(intro)
示例3: interactive
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import mainloop [as 别名]
def interactive(port='/dev/ttyACM0', InterfaceClass=CanInterface, intro='', load_filename=None):
global c
import atexit
c = InterfaceClass(port=port, load_filename=load_filename)
atexit.register(cleanupInteractiveAtExit)
gbls = globals()
lcls = locals()
try:
import IPython.Shell
ipsh = IPython.Shell.IPShell(argv=[''], user_ns=lcls, user_global_ns=gbls)
print intro
ipsh.mainloop(intro)
except ImportError, e:
try:
from IPython.terminal.interactiveshell import TerminalInteractiveShell
ipsh = TerminalInteractiveShell()
ipsh.user_global_ns.update(gbls)
ipsh.user_global_ns.update(lcls)
ipsh.autocall = 2 # don't require parenthesis around *everything*. be smart!
ipsh.mainloop(intro)
except ImportError, e:
try:
from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
ipsh = TerminalInteractiveShell()
ipsh.user_global_ns.update(gbls)
ipsh.user_global_ns.update(lcls)
ipsh.autocall = 2 # don't require parenthesis around *everything*. be smart!
ipsh.mainloop(intro)
except ImportError, e:
print e
shell = code.InteractiveConsole(gbls)
shell.interact(intro)
示例4: main
# 需要导入模块: from IPython.terminal.interactiveshell import TerminalInteractiveShell [as 别名]
# 或者: from IPython.terminal.interactiveshell.TerminalInteractiveShell import mainloop [as 别名]
#.........这里部分代码省略.........
print (
term.render(
"Running regex search/replace on ${BOLD}REQUESTS${NORMAL} with regex: 's/%s/%s'"
% (sr_request[1], sr_request[2])
)
)
sr_request[0] = True
else:
print (
term.render(
"Running string search/replace on ${BOLD}REQUESTS${NORMAL} with search/replace: 's/%s/%s'"
% (sr_request[1], sr_request[2])
)
)
sr_request[0] = False
else:
sr_request = None
if options.search_response and options.replace_response:
sr_response = [
None,
options.search_response.decode("string-escape"),
options.replace_response.decode("string-escape"),
]
# Check if we want to use regex instead of string constants
if options.response_use_regex:
print (
term.render(
"Running regex search/replace on ${BOLD}RESPONSES${NORMAL} with regex: 's/%s/%s'"
% (sr_response[1], sr_response[2])
)
)
sr_response[0] = True
else:
print (
term.render(
"Running string search/replace on ${BOLD}RESPONSES${NORMAL} with search/replace: 's/%s/%s'"
% (sr_response[1], sr_response[2])
)
)
sr_response[0] = False
else:
sr_response = None
# Setup which to fuzz - request, response, neither, both?
if options.fuzz_request:
fuzz_request = options.fuzz_request
run_additional_info = "Fuzzing REQUESTS; " + run_additional_info
print (term.render("Fuzzing ${BOLD}REQUESTS${NORMAL}"))
else:
fuzz_request = False
if options.fuzz_response:
fuzz_response = options.fuzz_response
run_additional_info = "Fuzzing RESPONSES; " + run_additional_info
print (term.render("Fuzzing ${BOLD}RESPONSES${NORMAL}"))
else:
fuzz_response = False
if not (options.fuzz_response or options.fuzz_request):
run_additional_info = "Fuzzing NONE; " + run_additional_info
print (
term.render(
"Fuzzing ${BOLD}<NOTHING>${NORMAL} (Maybe you wanted ${BOLD}--fuzz-request or --fuzz-response${NORMAL}?)"
)
)
if fuzz_request and fuzz_response:
print (
term.render(
"${YELLOW}\nWARNING! WARNING!\n${BOLD}Fuzzing BOTH the request and response is probably a bad idea, ensure this is what you want to do!${NORMAL}${YELLOW}\nWARNING! WARNING!\n${NORMAL}"
)
)
# host, db, username, passwd
if logging_enabled:
logger = postgresLogger("postgreshost", "dbname", "dbuser", "dbpass")
logger.log_run_info("CompanyName", "ProjectName-v1.2.3", run_additional_info)
# create object that spawns reciever/sender pairs upon connection
fwdr = forwarder(options.local_addr, options.local_port, options.remote_addr, options.remote_port)
print ("Listener running...")
# asyncore.loop()
# A quick hack to be able to control fuzz on/off while running
# separate asyncore.loop into its own thread so we can have terminal control
asyncThread = Thread(target=asyncore.loop)
asyncThread.start()
# start a console (ipython)
from IPython.terminal.interactiveshell import TerminalInteractiveShell
shell = TerminalInteractiveShell(user_ns=globals())
shell.mainloop()
# cleanup otherwise thread wont die and program hangs
fwdr.close()
# asyncore.close_all()
asyncThread._Thread__stop()