def do_check (self, issues):
     if not issues:
         return
     patches = []
     tests_results_dir = config.get (
         "server", "tests_results_install_dir")
     for issue_id in issues:
         info ("Trying issue %i" % issue_id)
         try:
             codereview_issue = self.get_codereview_issue_from_issue_tracker (issue_id)
             change_reference = codereview_issue.get_patch ()
         except Exception, e:
             warn ("something went wrong; omitting patch for issue %i" % issue_id)
             codereview_issue = None
         if codereview_issue:
             info ("Found patch: %s" % ",".join (str (x) for x in (
                         issue_id, change_reference, codereview_issue.title)))
             if (cache.has_section (str (issue_id))
                 and cache.has_option (
                     str (issue_id), codereview_issue.patch_id)
                 and (tests_results_dir
                      or cache.get (
                         str (issue_id),
                         codereview_issue.patch_id).lower () == "testing")):
                 info (("Last patch for issue %i already tested or under testing\n" +
                        "by another Patchy instance, skipping.") % issue_id)
                 continue
             if not cache.has_section (str (issue_id)):
                 cache.add_section (str (issue_id))
             cache.set (str (issue_id), codereview_issue.patch_id, "testing")
             cache.save ()
             patches.append (codereview_issue)
示例#2
0
def main (issues_id = None):
    patchy = projecthosting_patches.PatchBot ()
    if issues_id:
        issues = patchy.get_issues (issues_id)
    elif config.get ("server", "tests_results_base_url"):
        issues = patchy.get_testable_issues ()
    else:
        issues = patchy.get_new_patches ()
    patchy.do_check (issues)
import json

# API docs:
#   http://code.google.com/p/support/wiki/IssueTrackerAPIPython
import gdata.projecthosting.client
import gdata.projecthosting.data
import gdata.gauth
import gdata.client
import gdata.data
import atom.http_core
import atom.core

import compile_lilypond_test
from compile_lilypond_test import info, warn, error, config, cache

patches_dirname = os.path.expanduser (config.get ("patches", "directory"))
if (os.path.isdir (patches_dirname) and
    config.getboolean ("patches", "clean_dir_at_startup")):
    [os.remove (f)
     for f in (glob.glob (os.path.join (patches_dirname, "issue*.diff")))]
if not os.path.exists (patches_dirname):
    os.makedirs (patches_dirname)

class CodeReviewIssue (object):
    def __init__ (self, url, tracker_id, title=""):
        self.url = url
        for url_base in self.url_bases:
            if url.startswith (url_base):
                self.url_base = url_base
                break
        self.tracker_id = tracker_id