Merge pull request #1020 from gpotter2/ipython-old

Support old IPython versions
This commit is contained in:
Pierre Lalet 2018-01-10 14:26:08 +01:00 committed by GitHub
commit 8857f01511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View File

@ -502,10 +502,13 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20):
"traitlets not available. Some Scapy shell features won't be "
"available."
)
try:
ipshell = InteractiveShellEmbed(
banner1=banner,
user_ns=SESSION,
)
except:
code.interact(banner = the_banner, local=SESSION)
else:
cfg = Config()
try:
@ -518,10 +521,20 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20):
cfg.TerminalInteractiveShell.separate_in = u''
cfg.TerminalInteractiveShell.hist_file = conf.histfile
# configuration can thus be specified here.
try:
ipshell = InteractiveShellEmbed(config=cfg,
banner1=banner,
hist_file=conf.histfile if conf.histfile else None,
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)
else:
code.interact(banner = the_banner, local=SESSION)

View File

@ -296,7 +296,7 @@ def apply_ipython_style(shell):
except:
from scapy.error import log_loading
log_loading.warning(
"IPython too old. Some Scapy shell features won't be available."
"IPython too old. Shell color won't be handled."
)
return
from scapy.config import conf