[llvm-commits] [zorg] r147995 - /zorg/trunk/lnt/lnt/server/ui/views.py

Daniel Dunbar daniel at zuster.org
Wed Jan 11 17:27:29 PST 2012


Author: ddunbar
Date: Wed Jan 11 19:27:29 2012
New Revision: 147995

URL: http://llvm.org/viewvc/llvm-project?rev=147995&view=rev
Log:
[lnt] lnt.server.ui.views/submitRun: Organize stashed copies of submitted runs
by database and date.

Modified:
    zorg/trunk/lnt/lnt/server/ui/views.py

Modified: zorg/trunk/lnt/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=147995&r1=147994&r2=147995&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/views.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Jan 11 19:27:29 2012
@@ -1,3 +1,4 @@
+import datetime
 import os
 import re
 import tempfile
@@ -115,10 +116,22 @@
             data_value = input_data
 
         # Stash a copy of the raw submission.
-        prefix = time.strftime("data-%Y-%m-%d_%H-%M-%S")
-        fd,path = tempfile.mkstemp(prefix=prefix,
-                                   suffix='.plist',
-                                   dir=current_app.old_config.tempDir)
+        #
+        # To keep the temporary directory organized, we keep files in
+        # subdirectories organized by (database, year-month).
+        utcnow = datetime.datetime.utcnow()
+        tmpdir = os.path.join(current_app.old_config.tempDir, g.db_name,
+                              "%04d-%02d" % (utcnow.year, utcnow.month))
+        try:
+            os.makedirs(tmpdir)
+        except OSError,e:
+            pass
+
+        # Save the file under a name prefixed with the date, to make it easier
+        # to use these files in cases we might need them for debugging or data
+        # recovery.
+        prefix = utcnow.strftime("data-%Y-%m-%d_%H-%M-%S")
+        fd,path = tempfile.mkstemp(prefix=prefix, suffix='.plist', dir=tmpdir)
         os.write(fd, data_value)
         os.close(fd)
 





More information about the llvm-commits mailing list