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

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

Issue 2456603003: [Predator] Add local cache for get command output. (Closed)
Patch Set: . Created 4 years, 1 month 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
Index: appengine/findit/util_scripts/script_util.py
diff --git a/appengine/findit/util_scripts/script_util.py b/appengine/findit/util_scripts/script_util.py
index dc4da5cf06aa4618ecacfb9279df174e69ab996d..9f6486dec46f1715cc1787c67ccc859236cbddeb 100644
--- a/appengine/findit/util_scripts/script_util.py
+++ b/appengine/findit/util_scripts/script_util.py
@@ -9,6 +9,12 @@ import os
import subprocess
import sys
+from lib.cache_decorator import Cached
+from local_cache import LocalCacher # pylint: disable=W
+
+_COMMAND_OUPUT_CACHE_DIR = os.path.join(os.path.dirname(__file__),
+ '.command_output_cache')
wrengr 2016/11/11 18:26:26 Wait, weren't we putting temp files in ~/.predator
Sharu Jiang 2016/11/12 01:01:50 Oops.. should have put this into the ~/*
+
def SetUpSystemPaths(): # pragma: no cover
"""Sets system paths so as to import modules in findit, third_party and
@@ -29,7 +35,8 @@ def SetUpSystemPaths(): # pragma: no cover
sys.path.insert(1, findit_root_dir)
-# TODO(katesonia): Add local cache for this function.
+@Cached(namespace='Command-output',
+ cacher=LocalCacher(cache_dir=_COMMAND_OUPUT_CACHE_DIR))
def GetCommandOutput(command):
"""Gets the output stream of executable command.

Powered by Google App Engine
This is Rietveld 408576698