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

Unified Diff: devserver.py

Issue 4906001: Reworked devserver so that update images generated are cached in directories named after (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/dev-util.git@master
Patch Set: Restore changes accidentally removed during merge. Created 10 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
« autoupdate.py ('K') | « autoupdate_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devserver.py
diff --git a/devserver.py b/devserver.py
index 8abdb8fe66befd2d1c7fa36b7641d5f143e8b655..2d5a621dd600002139bf3c533ba11d7c83891e98 100755
--- a/devserver.py
+++ b/devserver.py
@@ -133,6 +133,8 @@ if __name__ == '__main__':
help='base URL, other than devserver, for update images.')
parser.add_option('--use_cached', action="store_true", default=False,
help='Prefer cached image regardless of timestamps.')
+ parser.add_option('--clear_cache', action="store_true", default=False,
+ help='Clear out all cached deltas and exit')
sosa 2010/11/15 21:59:17 Just deltas?
parser.add_option('--validate_factory_config', action="store_true",
dest='validate_factory_config',
help='Validate factory config file, then exit.')
@@ -151,6 +153,20 @@ if __name__ == '__main__':
static_dir = os.path.realpath('%s/static' % devserver_dir)
os.system('mkdir -p %s' % static_dir)
+ cache_dir = os.path.join(static_dir, 'cache')
+ cherrypy.log('Using cache directory %s' % cache_dir, 'DEVSERVER')
+ if options.clear_cache:
+ # Clear the cache and exit
+ sys.exit(os.system('sudo rm -rf %s' % cache_dir))
sosa 2010/11/15 21:59:17 Why not just clean and then startup?
dgarrett 2010/11/15 23:32:39 I wanted a way to clean and exit as well as clean
+ else:
+ if os.path.exists(cache_dir):
+ # Clear all but the last 12 cached deltas
sosa 2010/11/15 21:59:17 Set as a module constant i.e. CACHED_ENTRIES=12
+ cmd = 'cd %s; ls -1tr | head --lines=-12 | xargs rm -rf' % cache_dir
+ if os.system(cmd) != 0:
sosa 2010/11/15 21:59:17 Return return code?
dgarrett 2010/11/15 23:32:39 You can't since you aren't in a function. I wrote
+ cherrypy.log('Failed to clean up old delta cache files with %s' % cmd,
+ 'DEVSERVER')
+ sys.exit(1)
+
cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER')
cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER')
« autoupdate.py ('K') | « autoupdate_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698