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

Fix 978696 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions suds/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import os
import suds
from tempfile import gettempdir as tmp
import errno
from suds.transport import *
from suds.sax.parser import Parser
from suds.sax.element import Element
Expand Down Expand Up @@ -137,9 +137,7 @@ def __init__(self, location=None, **duration):
The duration may be: (months|weeks|days|hours|minutes|seconds).
@type duration: {unit:value}
"""
if location is None:
location = os.path.join(tmp(), 'suds')
self.location = location
self.location = location or os.path.expanduser('~/.suds/cache')
self.duration = (None, 0)
self.setduration(**duration)
self.checkversion()
Expand Down Expand Up @@ -176,15 +174,16 @@ def setlocation(self, location):
"""
self.location = location

def mktmp(self):
def mkdir(self):
"""
Make the I{location} directory if it doesn't already exits.
"""
try:
if not os.path.isdir(self.location):
os.makedirs(self.location)
except:
log.debug(self.location, exc_info=1)
os.makedirs(self.location)
os.chmod(self.location, 0700)
except OSError, e:
if e.errno != errno.EEXIST:
raise
return self

def put(self, id, bfr):
Expand Down Expand Up @@ -262,13 +261,12 @@ def open(self, fn, *args):
"""
Open the cache file making sure the directory is created.
"""
self.mktmp()
self.mkdir()
return open(fn, *args)

def checkversion(self):
path = os.path.join(self.location, 'version')
try:

f = self.open(path)
version = f.read()
f.close()
Expand Down