sqlpython relies on HOME env variable

56 views
Skip to first unread message

Paul Moore

unread,
Mar 11, 2010, 9:08:50 AM3/11/10
to sqlpython
If I run sqlpython on my PC, I get

>python -c "from sqlpython.mysqlpy import run; run()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Apps\Python26\lib\site-packages\sqlpython\__init__.py",
line 1, in <module>
import mysqlpy
File "D:\Apps\Python26\lib\site-packages\sqlpython\mysqlpy.py", line
11, in <module>
from sqlpyPlus import *
File "D:\Apps\Python26\lib\site-packages\sqlpython\sqlpyPlus.py",
line 26, in <module>
import sys, os, re, sqlpython, pyparsing, re, completion
File "D:\Apps\Python26\lib\site-packages\sqlpython\sqlpython.py",
line 12, in <module>
import pyparsing, connections
File "D:\Apps\Python26\lib\site-packages\sqlpython\connections.py",
line 216, in <module>
class DatabaseInstance(object):
File "D:\Apps\Python26\lib\site-packages\sqlpython\connections.py",
line 222, in DatabaseInstance
pickledir = os.path.join(os.getenv('HOME'), '.sqlpython')
File "D:\Apps\Python26\lib\ntpath.py", line 96, in join
assert len(path) > 0
TypeError: object of type 'NoneType' has no len()

This is because I do not have a HOME environment variable (a normal
situation on Windows).

It looks like it's only needed for the PICKLE command. Can I suggest
that (1) this defaults to the current directory if HOME isn't set (I'd
prefer it if it defaulted to the current dir always, but backward
compatilibility probably makes that impossible), (2) there's a
specific environment variable (say, SQLPYTHON_PICKLEDIR) that
overrides %HOME%\.sqlpython, and (3) there's the option for the user
to specify a specific file to pickle to in the pickle command?

I can't be sure these suggestions are appropriate as there's no
documentation on the pickle command, so I'm sort of guessing how it
might be used. But at the very least, it would be better to disable
the one command than to crash sqlpython in this situation.

Paul

Catherine Devlin

unread,
Mar 11, 2010, 4:06:51 PM3/11/10
to sqlp...@googlegroups.com
Hi Paul!  Thanks for the report.

This was my bad (oh - wait - they're *all* my bad.)  I forgot that $HOME doesn't work in Windows, and my workplace - the only place I use Windows - has cut off access to PyPI; Windows testing has suffered...

Anyway, the trunk version now finds the home the proper, cross-platform way: with os.path.expanduser('~')

As for what it's doing - because gathering metadata through Gerald takes a while, and I don't want to frustrate users by telling them that metadata isn't ready for the first several minutes after they fire up the tool, sqlpython pickles the metadata it finds and stashes it for next time.  The next time it's started, it works off the pickled metadata until a fresh metadata collection (run in the background) completes.  I want to have only one place for that pickled metadata to be stored; if you choose your own destination, everytime you choose a new one you'll lose the benefit of what you'd already stored.

I should get this all into the docs.... thanks for the nudge!


--
You received this message because you are subscribed to the Google Groups "sqlpython" group.
To post to this group, send email to sqlp...@googlegroups.com.
To unsubscribe from this group, send email to sqlpython+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlpython?hl=en.




--
- Catherine
http://catherinedevlin.blogspot.com/
*** PyCon * Feb 17-25, 2010 * Atlanta, GA * us.pycon.org ***
Reply all
Reply to author
Forward
0 new messages