Commits

anatoly techtonik committed 50b1142

add configuration for pulling issues
store them in separate temp directory
add logging/show message about created dir

  • Participants
  • Parent commits 182bfad

Comments (0)

Files changed (1)

File issues/tigris/pull_issues.py

+"""
+Exports issues from tigris.org using interface at:
 
+http://PROJECT.tigris.org/issues/xml.cgi
+"""
 import os
 import sys
 import urllib
 
-def getIssue(fid):
+from logging import INFO, info, basicConfig
+basicConfig(level=INFO, format="%(asctime)s %(levelname)8s %(message)s",
+            datefmt="%H:%M:%S")
+
+
+# --- config ----
+PROJECT = 'scons'
+DATADIR = '_%s_data' % PROJECT
+# --- /config ---
+
+
+def getIssue(prid, fid):
     query = urllib.urlencode({'id':fid})
-    urllib.urlretrieve("http://scons.tigris.org/issues/xml.cgi?%s" % query, "%d.xml" % fid)
+    furl = "http://%s.tigris.org/issues/xml.cgi?%s" % (prid, query)
+    urllib.urlretrieve(furl, DATADIR+"/%d.xml" % fid)
+
 
 def main():
     max = 0
     cur = 0
+
     if len(sys.argv) > 1:
         sl = sys.argv[1].split('-')
         if len(sl) > 1:
         else:
             max = int(sys.argv[1])
             
+    if not os.path.exists(DATADIR):
+        info("Creating %s" % DATADIR)
+        os.mkdir(DATADIR)
+
     while 1:
         if max > 0:
             if cur == max:
                 break
         cur += 1
         print "%d" % cur
-        getIssue(cur)
+        getIssue(PROJECT, cur)
         # Check for contents
-        f = open('%d.xml' % cur)
+        f = open(DATADIR+'/%d.xml' % cur)
         content = f.read()
         f.close()
         if content.find('issue status_code="404" status_message="NotFound"') >= 0:
             # Delete the last file
-            os.remove('%d.xml' % cur)
+            os.remove(DATADIR+'/%d.xml' % cur)
             break
 
 if __name__ == "__main__":