Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history writing on exit without ipython broken #5

Closed
juliantaylor opened this issue Aug 7, 2011 · 4 comments
Closed

history writing on exit without ipython broken #5

juliantaylor opened this issue Aug 7, 2011 · 4 comments

Comments

@juliantaylor
Copy link

readline is imported lazily in 0.5.1 causing write_history_file to fail due to the undefined readline variable.
the variable must be declared global for it to work:

    except ImportError:
        global readline
        readline = None

This only happens when ipython is not installed.

# snimpy 
Snimpy (0.5.1) -- An interactive SNMP tool.
  load        -> load an additional MIB
  M           -> manager object
[snimpy]> exit()
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/dist-packages/snimpy/main.py", line 47, in write_history_file
    if readline and conf.histfile:
NameError: global name 'readline' is not defined
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/dist-packages/snimpy/main.py", line 47, in write_history_file
    if readline and conf.histfile:
NameError: global name 'readline' is not defined
@juliantaylor
Copy link
Author

with this fix you now get this when you don't have a config file:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.6/dist-packages/snimpy/main.py", line 111, in <lambda>
    os.path.expanduser(conf.histfile)))
IOError: [Errno 2] No such file or directory
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.6/dist-packages/snimpy/main.py", line 111, in <lambda>
    os.path.expanduser(conf.histfile)))
IOError: [Errno 2] No such file or directory

a better error message would be nice

@vincentbernat
Copy link
Owner

Even without a configuration file, you should get your history written in ~/.snimpy_history. I don't understand why you get such a message. Maybe you have a configuration file that asks to write history into an inexistant directory?

@juliantaylor
Copy link
Author

sorry, that is what happened. I forgot to set my HOME folder correctly when testing in a chroot.
It works fine, thanks

@vincentbernat
Copy link
Owner

Great to know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants