简体   繁体   中英

Shelve.open failing on creation

I'm having trouble using shelve on my dev server. My local machine will create a new file just fine when I call shelve.open(). But when I push the file to the remote server, an error happens. It looks like it is trying to find the file first and it's failing because it isn't there. I'm not changing the file extension. My local machine is Ubuntu 14 and my remote is CentOS 6. Here is the python stack trace. Python 2.6.

File "/var/lib/jenkins/................/translation.py", line 51, in _market
    lang_db = shelve.open(market + "_pydb")
File "/usr/lib64/python2.6/shelve.py", line 239, in open
  return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib64/python2.6/shelve.py", line 223, in __init__
  Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
File "/usr/lib64/python2.6/anydbm.py", line 83, in open
  return mod.open(file, flag, mode)
File "/usr/lib64/python2.6/dbhash.py", line 19, in open
  return bsddb.hashopen(file, flag, mode)
File "/usr/lib64/python2.6/bsddb/__init__.py", line 361, in hashopen
  d.open(file, db.DB_HASH, flags, mode)
DBNoSuchFileError: (2, 'No such file or directory')

For the record, I changed the default to dumbdbm and it's still giving me an IO error (file not found).

import anydbm
anydbm._defaultmod = __import__('dumbdbm')

I found out that when I was pushing to the repository, git wasn't including the directory I was looking in because it was empty. If you try to use shelve.open with an argument that is in a directory that doesn't exist, it will give you an IO error. I simply forced the creation of the directory and now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM