mirror of https://github.com/secdev/scapy.git
Merge pull request #1020 from gpotter2/ipython-old
Support old IPython versions
This commit is contained in:
commit
8857f01511
|
@ -502,10 +502,13 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20):
|
||||||
"traitlets not available. Some Scapy shell features won't be "
|
"traitlets not available. Some Scapy shell features won't be "
|
||||||
"available."
|
"available."
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
ipshell = InteractiveShellEmbed(
|
ipshell = InteractiveShellEmbed(
|
||||||
banner1=banner,
|
banner1=banner,
|
||||||
user_ns=SESSION,
|
user_ns=SESSION,
|
||||||
)
|
)
|
||||||
|
except:
|
||||||
|
code.interact(banner = the_banner, local=SESSION)
|
||||||
else:
|
else:
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
try:
|
try:
|
||||||
|
@ -518,10 +521,20 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20):
|
||||||
cfg.TerminalInteractiveShell.separate_in = u''
|
cfg.TerminalInteractiveShell.separate_in = u''
|
||||||
cfg.TerminalInteractiveShell.hist_file = conf.histfile
|
cfg.TerminalInteractiveShell.hist_file = conf.histfile
|
||||||
# configuration can thus be specified here.
|
# configuration can thus be specified here.
|
||||||
|
try:
|
||||||
ipshell = InteractiveShellEmbed(config=cfg,
|
ipshell = InteractiveShellEmbed(config=cfg,
|
||||||
banner1=banner,
|
banner1=banner,
|
||||||
hist_file=conf.histfile if conf.histfile else None,
|
hist_file=conf.histfile if conf.histfile else None,
|
||||||
user_ns=SESSION)
|
user_ns=SESSION)
|
||||||
|
except (AttributeError, TypeError):
|
||||||
|
log_loading.warning("IPython too old. Won't support history and color style.")
|
||||||
|
try:
|
||||||
|
ipshell = InteractiveShellEmbed(
|
||||||
|
banner1=banner,
|
||||||
|
user_ns=SESSION,
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
code.interact(banner = the_banner, local=SESSION)
|
||||||
ipshell(local_ns=SESSION)
|
ipshell(local_ns=SESSION)
|
||||||
else:
|
else:
|
||||||
code.interact(banner = the_banner, local=SESSION)
|
code.interact(banner = the_banner, local=SESSION)
|
||||||
|
|
|
@ -296,7 +296,7 @@ def apply_ipython_style(shell):
|
||||||
except:
|
except:
|
||||||
from scapy.error import log_loading
|
from scapy.error import log_loading
|
||||||
log_loading.warning(
|
log_loading.warning(
|
||||||
"IPython too old. Some Scapy shell features won't be available."
|
"IPython too old. Shell color won't be handled."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
from scapy.config import conf
|
from scapy.config import conf
|
||||||
|
|
Loading…
Reference in New Issue