Commits

Manabu TERADA  committed 7aab407 Draft

for 1.0b6 - modify bug fixed for getting issue limit number, max to has issues [Manabu TERADA]

  • Participants
  • Parent commits 0ab12d3

Comments (0)

Files changed (3)

+1.0b6 (2012-09-02)
+----------------------
+
+- modify bug fixed for getting issue limit number, max to has issues [Manabu TERADA]
+
+1.0b5 (2012-08-26)
+----------------------
+
+- modify bugs for using api [Manabu TERADA]
+- modify getting issue limit number of from 15 to 5000 [Manabu TERADA]
+
+1.0b4 (2012-08-26)
+----------------------
+
+- modify bugs for getting issue comments [Manabu TERADA]
+
 1.0b3 (2012-08-26)
 ----------------------
 

File c2/recipe/bitbucketbk/backuprunner.py

 Created by Manabu Terada on 2012-01-08.
 Copyright (c) 2012 CMScom. All rights reserved.
 """
+#from StringIO import StringIO
 from datetime import datetime
 from functools import partial
 import os
 import json
 import urllib2
+from urllib2 import HTTPError
 import base64
 import xlwt
 from mercurial import hg, ui, commands
     authString = base64.encodestring('%s:%s' % (user, passwd))
     headers = {'Authorization':"Basic %s" % authString}
     req = urllib2.Request(api_url, None, headers)
-    bitbucket_obj = urllib2.urlopen(req)
+    try:
+        bitbucket_obj = urllib2.urlopen(req)
+    except HTTPError:
+        raise "Could not get JSON from bitbucket"
     return bitbucket_obj
 
 def get_repositories(access_api_base, user):
         wb.save(f)
 
 def backup_isseus(access_api_base, repo_name, user, issues_folder_location):
-    api_url = BITBUCKET_API + "repositories/" + user + "/" + repo_name + "/issues"
+    api_url = BITBUCKET_API + "repositories/" + user + "/" + repo_name.lower() + "/issues?limit=50"
     bitbucket_obj = access_api_base(api_url)
-    issues = json.load(bitbucket_obj).get('issues', [])
+    issues_obj = json.load(bitbucket_obj)
+    count = issues_obj.get('count', 0)
+    issues = issues_obj.get('issues', [])
+    for c in range(count / 50):
+        start = str((c + 1) * 50)
+        bitbucket_add_obj = access_api_base(api_url+"&start="+start)
+        issues_add = json.load(bitbucket_add_obj).get('issues', [])
+        issues.append(issues_add)
     _save_excel_data(issues_folder_location, repo_name, issues, access_api_base, api_url)
 
 
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
-version = '1.0b3'
+version = '1.0b6'
 
 long_description = (
     read('README.txt')