Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1427)

Unified Diff: appengine/findit/util_scripts/local_cache.py

Issue 2557553002: [Culprit-Finder] Seperate gae related part in cache_decorator and gitile repository to gae_libs/ (Closed)
Patch Set: Fix nits. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/lib/test/cache_decorator_test.py ('k') | appengine/findit/util_scripts/script_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/util_scripts/local_cache.py
diff --git a/appengine/findit/util_scripts/local_cache.py b/appengine/findit/util_scripts/local_cache.py
index a010228a4dac5c71998c9d35b0d07cb8f63e482d..0f1adc8d1d612bd0afd2058f67fbcfc7ea44c9ad 100644
--- a/appengine/findit/util_scripts/local_cache.py
+++ b/appengine/findit/util_scripts/local_cache.py
@@ -8,23 +8,24 @@ import pickle
import threading
import zlib
-from lib.cache_decorator import Cacher
+from lib.cache import Cache
CACHE_DIR = os.path.join(os.path.expanduser('~'), '.predator', 'cache')
-class LocalCacher(Cacher):
+class LocalCache(Cache):
"""Cacher that uses local files to cache data."""
lock = threading.Lock()
def __init__(self, cache_dir=CACHE_DIR):
self.cache_dir = cache_dir
- with LocalCacher.lock:
- if not os.path.exists(cache_dir): # pragma: no cover.
- os.makedirs(cache_dir)
+ try: # pragma: no cover.
+ os.makedirs(cache_dir)
+ except Exception:
+ pass
def Get(self, key):
- with LocalCacher.lock:
+ with LocalCache.lock:
path = os.path.join(self.cache_dir, key)
if not os.path.exists(path):
return None
@@ -36,7 +37,7 @@ class LocalCacher(Cacher):
raise Exception('Failed loading cache: %s' % error)
def Set(self, key, data, expire_time=0): # pylint: disable=W
- with LocalCacher.lock:
+ with LocalCache.lock:
try:
with open(os.path.join(self.cache_dir, key), 'wb') as f:
f.write(zlib.compress(pickle.dumps(data)))
« no previous file with comments | « appengine/findit/lib/test/cache_decorator_test.py ('k') | appengine/findit/util_scripts/script_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698