diff --git a/all_contribution_total.py b/all_contribution_total.py new file mode 100755 index 0000000..5bf5c11 --- /dev/null +++ b/all_contribution_total.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# AUTHOR: hieulq + +import copy +import time +import requests + +# Change this list based on your member's info +USER_LIST = ['hieulq', 'duonghq', 'namnh', 'daidv', 'trungnv', 'kiennt26', 'tovin07'] + +# No need to change in case of changing Stackalytics API or changing cycle +CONTRIB_URL = "http://stackalytics.com/api/1.0/contribution" +RELEASE = "pike" + +# Common query info +PROJECT_TYPE = "openstack" +COMPANY = "fujitsu" +PAYLOAD = {'release': RELEASE, 'project_type': PROJECT_TYPE, + 'company': COMPANY} + + +def get_statistics(is_member=False): + total_ps, total_cm, total_rv, total_mbp, total_rbp = 0, 0, 0, 0, 0 + params = copy.deepcopy(PAYLOAD) + if is_member: + params['start_date'] = int(time.time() - 604800) + params['end_date'] = int(time.time()) + + for user in USER_LIST: + params['user_id'] = user + resp = requests.get(CONTRIB_URL, params=params) + if resp.ok: + parsed = resp.json()['contribution'] + user_ps_count = parsed['patch_set_count'] + user_cm_count = parsed['commit_count'] + user_bp_merge = parsed['completed_blueprint_count'] + user_bp_review = parsed['drafted_blueprint_count'] + user_rv_count = parsed['marks']['-1'] + parsed['marks']['1'] + \ + parsed['marks']['-2'] + parsed['marks']['2'] + + if is_member: + print("* %s's review increase: %d" % (user, user_rv_count)) + else: + print("* %s's review: %d" % (user, user_rv_count)) + + total_ps += user_ps_count + total_cm += user_cm_count + total_rv += user_rv_count + total_mbp += user_bp_merge + total_rbp += user_bp_review + else: + print("There are something wrong with user %s !" % user) + return None + + return total_ps, total_cm, total_rv, total_mbp, total_rbp + + +def main(): + print("===== Member's total review count =====") + team_res = get_statistics(is_member=False) + if team_res: + print("===== %s: Team contribution report =====" % time.ctime()) + print("* Total in-review BP: %d" % team_res[4]) + print("* Total merged BP: %d" % team_res[3]) + print("* Total commits count: %d" % team_res[1]) + print("* Total reviews count: %d" % team_res[2]) + print("* Total in-review patches: %d" % (team_res[0] - team_res[1])) + print("===== FIN ======") + + print("===== Member's contribution compare with last week =====") + member_res = get_statistics(is_member=True) + if member_res: + print("* Total commits since last week: %d" % member_res[1]) + print("* Total patches since last week: %d" % + (member_res[0] - member_res[1])) + + +if __name__ == '__main__': + main() diff --git a/all_v2.py b/all_v2.py new file mode 100755 index 0000000..55dc855 --- /dev/null +++ b/all_v2.py @@ -0,0 +1,184 @@ +from datetime import * +import datetime +import prettytable +import xlsxwriter +import urllib, json + +today = datetime.date.today() + +#Input member launchpad id here. +members = ["hieulq", "duonghq", "tovin07", "kiennt2609", "daidv", "namnh"] +maps = {"hieulq": "Hieu", "duonghq": "Duong", "tovin07": "Vinh", "kiennt2609": "Kien", "daidv": "Dai", "namnh": "Nam"} +#Input target +review_target = 1219 +commit_target = 213 + +# Create a new Excel file and add a worksheet. +year = today.year +month = today.month +day = today.day +a = date(year, month, day).isocalendar()[1] +a1 = date(2017, 12, 31).isocalendar()[1] +b = date(2018, 3, 2).isocalendar()[1] +if a > b: + week = (a1 - a) + b +else: + week = b - a +# Cal start date and end date of a week +def _range_date_of_week(year, week): + d = date(year,1,1) + if(d.weekday()>3): + d = d+timedelta(7-d.weekday()) + else: + d = d - timedelta(d.weekday()) + dlt = timedelta(days = (week-1)*7) + start = str(d + dlt) + end = str(d + dlt + timedelta(days=4)) + return start, end + +filename = 'FVL_UC_Contribution_Summarization_R-' + str(week) + '.xlsx' +workbook = xlsxwriter.Workbook(filename) +worksheet = workbook.add_worksheet() +def output_xlsx (member, reviews, commits, index, sum=None): + # Widen the first column to make the text clearer. + worksheet.set_column('E:E', 30) + worksheet.set_column('H:H', 15) + worksheet.set_column('I:I', 15) + + # Add a bold format to use to highlight cells. + bold = workbook.add_format({'bold': False}) + bold.set_border() + bold.set_font('Times New Roman') + bold.set_font_size(13) + bold_color = workbook.add_format({'bold': False, 'font_color': 'black'}) + bold_color.set_font('Times New Roman') + bold_color.set_font_size(13) + bold_color.set_border() + bold_color.set_pattern(1) + bold_color.set_bg_color('yellow') + # Create a format to use in the merged range. + merge_format = workbook.add_format({ + 'bold': 0, + 'border': 1, + 'align': 'center', + 'valign': 'vcenter', + 'font': 'Times New Roman', + 'font_size': 13}) + + row = 13 + index*4 + # Write some simple text. + if sum: + worksheet.merge_range('D' + str(row - 5) + ':J' + str(row - 5), + 'Week (From ' + _range_date_of_week(year, a)[0] + + ' to ' + _range_date_of_week(year, a)[1] + ' )', merge_format) + worksheet.merge_range('D' + str(row - 4) + ':D' + str(row - 2), 'Team', merge_format) + worksheet.write('E' + str(row - 4), 'R-' + str(week), bold) + worksheet.write('E' + str(row - 3), 'Reviews (Until 2018/02/23)', bold) + worksheet.write('E' + str(row - 2), 'Commits (Until 2018/01/26)', bold) + worksheet.write('F' + str(row - 4), 'Target', bold) + worksheet.write('G' + str(row - 4), 'Actual', bold) + worksheet.write('H' + str(row - 4), 'Target remain', bold) + worksheet.write('I' + str(row - 4), 'Actual remain', bold) + worksheet.write('J' + str(row - 4), 'Status', bold) + worksheet.write('F' + str(row - 3), review_target, bold) + worksheet.write('F' + str(row - 2), commit_target, bold) + worksheet.write('G' + str(row - 3), reviews, bold_color) + worksheet.write('G' + str(row - 2), commits, bold_color) + m1 = review_target - (review_target/25)*(26-week) #25 is total week of the cycle + n1 = commit_target - (commit_target/21)*(26-week) #21 is the week of RC1 + m2 = review_target - reviews + n2 = commit_target - commits + worksheet.write('H' + str(row - 3), round(m1), bold) + worksheet.write('H' + str(row - 2), round(n1), bold) + worksheet.write('I' + str(row - 3), m2, bold) + worksheet.write('I' + str(row - 2), n2, bold) + worksheet.write('J' + str(row - 3), round(m1 - m2), bold_color) + worksheet.write('J' + str(row - 2), round(n1 - n2), bold_color) + else: + worksheet.merge_range('D' + str(row) + ':D' + str(row + 2), member, merge_format) + worksheet.write('E' + str(row ), '', bold) + worksheet.write('E' + str(row + 1), 'Reviews', bold) + worksheet.write('E' + str(row + 2), 'Commits', bold) + worksheet.write('F' + str(row), 'Target', bold) + worksheet.write('G' + str(row), 'Actual', bold) + worksheet.write('H' + str(row), 'Target remain', bold) + worksheet.write('I' + str(row), 'Actual remain', bold) + worksheet.write('J' + str(row), 'Status', bold) + q = review_target / len(members) + p = commit_target / len(members) + q1 = q - (q/25)*(26 - week) + p1 = p - (p/21)*(26 - week) + q2 = q - reviews + p2 = p - commits + worksheet.write('F' + str(row + 1), q, bold) + worksheet.write('F' + str(row + 2), p, bold) + worksheet.write('G' + str(row + 1), reviews, bold_color) + worksheet.write('G' + str(row + 2), commits, bold_color) + worksheet.write('H' + str(row + 1), round(q1), bold) + worksheet.write('H' + str(row + 2), round(p1), bold) + worksheet.write('I' + str(row + 1), q2, bold) + worksheet.write('I' + str(row + 2), p2, bold) + worksheet.write('J' + str(row + 1), round(q1-q2), bold_color) + worksheet.write('J' + str(row + 2), round(p1-p2), bold_color) +# Create an new Excel file and add a worksheet...End + +patches = prettytable.PrettyTable(["UC team results on the community summary", str(today) + " (R-" + str(week) + ")"]) +table = prettytable.PrettyTable(["Team/Members", "Reviews", "Commits"]) +table.align = "l" + +team_stats_patches = 0 +team_stats_commits = 0 +team_stats_reviews = 0 +i = 0 +for member in members: + url = "http://stackalytics.com/api/1.0/contribution?release=queens&company=fujitsu&user_id=" + member + member_url = urllib.urlopen(url) + try: + member_stats = json.loads(member_url.read()) + except ValueError: + print "Something wrong with member " + member + continue + member_stats_patches = member_stats['contribution']['patch_set_count'] + member_stats_commits = member_stats['contribution']['commit_count'] + member_stats_reviews = ( + member_stats['contribution']['marks']['-1'] + + member_stats['contribution']['marks']['1'] + + member_stats['contribution']['marks']['-2'] + + member_stats['contribution']['marks']['2']) + + team_stats_patches += member_stats_patches + team_stats_reviews += member_stats_reviews + team_stats_commits += member_stats_commits + + table.add_row([maps.get(member), member_stats_reviews, member_stats_commits]) + + output_xlsx(maps.get(member), member_stats_reviews, member_stats_commits, i) + i += 1 + if i == len(members): + output_xlsx('Team', team_stats_reviews, team_stats_commits, 0, sum=True) + +workbook.close() +patches.add_row(["Total patches uploaded", team_stats_patches]) +print patches +table.add_row(["*** Team ***", team_stats_reviews, team_stats_commits]) +print table + + +rranking = urllib.urlopen("http://stackalytics.com/api/1.0/stats/companies?release=queens") +rranking_results = json.loads(rranking.read()) +rranking_count = rranking_results['stats'] +for i in rranking_count: + if i['name'] == "Fujitsu": + print "===============REVIEWS - Fujitsu contribution===============" + print "Total reviews count = %d" % i['metric'] + print "Ranking = %d" % i['index'] + +ranking = urllib.urlopen("http://stackalytics.com/api/1.0/stats/companies?release=queens&metric=commits") +ranking_results = json.loads(ranking.read()) +ranking_count = ranking_results['stats'] +for i in ranking_count: + if i['name'] == "Fujitsu": + print "===============COMMITS - Fujitsu contribution===============" + print "Total commits count = %d" % i['metric'] + print "Ranking = %d" % i['index'] + diff --git a/ct_contribution_total.py b/ct_contribution_total.py new file mode 100755 index 0000000..1066d38 --- /dev/null +++ b/ct_contribution_total.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# AUTHOR: hieulq + +import copy +import time +import requests + +# Change this list based on your member's info +USER_LIST = ['hieulq', 'tovin07'] + +# No need to change in case of changing Stackalytics API or changing cycle +CONTRIB_URL = "http://stackalytics.com/api/1.0/contribution" +RELEASE = "queen" + +# Common query info +PROJECT_TYPE = "openstack" +COMPANY = "fujitsu" +PAYLOAD = {'release': RELEASE, 'project_type': PROJECT_TYPE, + 'company': COMPANY} + + +def get_statistics(is_member=False): + total_ps, total_cm, total_rv, total_mbp, total_rbp = 0, 0, 0, 0, 0 + params = copy.deepcopy(PAYLOAD) + if is_member: + params['start_date'] = int(time.time() - 604800) + params['end_date'] = int(time.time()) + + for user in USER_LIST: + params['user_id'] = user + resp = requests.get(CONTRIB_URL, params=params) + if resp.ok: + parsed = resp.json()['contribution'] + user_ps_count = parsed['patch_set_count'] + user_cm_count = parsed['commit_count'] + user_bp_merge = parsed['completed_blueprint_count'] + user_bp_review = parsed['drafted_blueprint_count'] + user_rv_count = parsed['marks']['-1'] + parsed['marks']['1'] + \ + parsed['marks']['-2'] + parsed['marks']['2'] + + if is_member: + print("* %s's review increase: %d" % (user, user_rv_count)) + else: + print("* %s's review: %d" % (user, user_rv_count)) + + total_ps += user_ps_count + total_cm += user_cm_count + total_rv += user_rv_count + total_mbp += user_bp_merge + total_rbp += user_bp_review + else: + print("There are something wrong with user %s !" % user) + return None + + return total_ps, total_cm, total_rv, total_mbp, total_rbp + + +def main(): + print("===== Member's total review count =====") + team_res = get_statistics(is_member=False) + if team_res: + print("===== %s: Team contribution report =====" % time.ctime()) + print("* Total in-review BP: %d" % team_res[4]) + print("* Total merged BP: %d" % team_res[3]) + print("* Total commits count: %d" % team_res[1]) + print("* Total reviews count: %d" % team_res[2]) + print("* Total in-review patches: %d" % (team_res[0] - team_res[1])) + print("===== FIN ======") + + print("===== Member's contribution compare with last week =====") + member_res = get_statistics(is_member=True) + if member_res: + print("* Total commits since last week: %d" % member_res[1]) + print("* Total patches since last week: %d" % + (member_res[0] - member_res[1])) + + +if __name__ == '__main__': + main() diff --git a/gerritssh/gerritsite.py b/gerritssh/gerritsite.py index da179a1..785953f 100644 --- a/gerritssh/gerritsite.py +++ b/gerritssh/gerritsite.py @@ -74,6 +74,13 @@ class InvalidCommandError(GerritsshException): pass +class InvalidUserError(GerritsshException): + ''' + Raised when an username is not found. + ''' + pass + + class Site(object): ''' An individual Gerrit site. @@ -186,6 +193,8 @@ def __do_command(self, command, args=''): retval = [(l if isinstance(l, str) else l.encode('utf8', 'replace')) for l in retval] _logger.debug('Returning:{0}'.format(retval)) + if '"type":"error"' in retval[0]: + raise InvalidUserError() return s.encode('utf-8', 'replace'), retval def connect(self): diff --git a/gtree.py b/gtree.py index 5b08ad9..92dd877 100755 --- a/gtree.py +++ b/gtree.py @@ -63,9 +63,12 @@ def tree(dir, padding, print_files=False, isLast=False, isFirst=False, else: print padding.decode('utf8')[:-1].encode('utf8') + '+---' + \ basename(abspath(dir)) - if dir.split('/')[-1] in locs: - print padding + recur_deli(9, 1) + '- ' + \ - locs[dir.split('/')[-1]][0] + if locs and dir.split('/')[-1] in locs: + # Pull commit message + s = locs[dir.split('/')[-1]][0] + # Get title of commit message only + ss = s.split(" ")[0] + print padding + recur_deli(9, 1) + '- ' + ss if print_files: files = listdir(dir) else: @@ -90,16 +93,23 @@ def tree(dir, padding, print_files=False, isLast=False, isFirst=False, else: if isLast: l = len(padding) + len(file) + 5 - if file in locs: + if locs and file in locs: TOTAL_LOC_INSERTION += int(locs[file][0]) TOTAL_LOC_DELETIONS += int(locs[file][1]) + + get_page_num(path) + print padding + '\---' + file + ' ' + \ recur_deli(LOC_DECO-l+1) + locs[file][0] + \ ' insertions(+), ' + locs[file][1].replace('-','') +\ ' deletions(-)' if len(locs[file]) == 3: + # Pull commit message + s = locs[file][2] + # Get title of commit message only + ss = s.split(" ")[0] print padding + recur_deli(10, 1) + '- ' + \ - locs[file][2] + ss print padding else: print padding + '\---' + file + ' ' + \ @@ -107,16 +117,23 @@ def tree(dir, padding, print_files=False, isLast=False, isFirst=False, print padding else: l = len(padding) + len(file) + 5 - if file in locs: + if locs and file in locs: TOTAL_LOC_INSERTION += int(locs[file][0]) TOTAL_LOC_DELETIONS += int(locs[file][1]) + + get_page_num(path) + print padding + '|---' + file + ' ' + \ recur_deli(LOC_DECO-l+1) + locs[file][0] + \ ' insertions(+), ' + locs[file][1].replace('-','') +\ ' deletions(-)' if len(locs[file]) == 3: + # Pull commit message + s = locs[file][2] + # Get title of commit message only + ss = s.split(" ")[0] print padding + '|' + recur_deli(9, 1) + \ - '- ' + locs[file][2] + '- ' + ss print padding + '|' else: print padding + '|---' + file + ' ' + \ @@ -124,6 +141,7 @@ def tree(dir, padding, print_files=False, isLast=False, isFirst=False, def main(): + global TOTAL_PAGE_COUNT global TOTAL_LOC_INSERTION global TOTAL_LOC_DELETIONS @@ -133,31 +151,43 @@ def main(): parser.add_option("-p", "--path", dest="path", action='store', help="delivery folder path [default: %default]", metavar="PATH", default='~/Deliver') + parser.add_option("-l", "--line-of-code-count", action='store', + type=int, metavar="OPTION", default=0, dest='loc', + help="whether to report patch in line of code or not") (options, args) = parser.parse_args() path = options.path + loc = options.loc locr = get_loc() locs = {} if isdir(path): - print " " \ - " [Page count (for documents)] " \ - " [Line count (for source code)]" - print "\nFolder PATH listing" - for line in locr: - loc = line.split('|') - if len(loc) == 2: - locs[loc[0]] = (loc[1],) - elif len(loc) == 4: - locs[loc[0]] = (loc[1], loc[2], loc[3]) - else: - locs[loc[0]] = (loc[1], loc[2]) - tree(path, '', True, False, True, locs) - print PC_STR + recur_deli(PAGE_DECO - len(PC_STR) + 1) + \ - str(TOTAL_PAGE_COUNT) + ' pages' - print LOC_STR + recur_deli(LOC_DECO - len(LOC_STR) + 1) + \ - str(TOTAL_LOC_INSERTION) + ' insertion(+), ' + \ - str(abs(TOTAL_LOC_DELETIONS)) + ' deletions(-)' + if loc == 1: + print " " \ + " [Page count (for documents)] " \ + " [Line count (for source code)]" + print "\nFolder PATH listing" + for line in locr: + loc = line.split('|') + if len(loc) == 2: + locs[loc[0]] = (loc[1],) + elif len(loc) == 4: + locs[loc[0]] = (loc[1], loc[2], loc[3]) + else: + locs[loc[0]] = (loc[1], loc[2]) + tree(path, '', True, False, True, locs) + print PC_STR + recur_deli(PAGE_DECO - len(PC_STR) + 1) + \ + str(TOTAL_PAGE_COUNT) + ' pages' + print LOC_STR + recur_deli(LOC_DECO - len(LOC_STR) + 1) + \ + str(TOTAL_LOC_INSERTION) + ' insertion(+), ' + \ + str(abs(TOTAL_LOC_DELETIONS)) + ' deletions(-)' + elif loc == 0: + print " " \ + " [Page count] " + print "\nFolder PATH listing" + tree(path, '', True, False, True, None) + print PC_STR + recur_deli(PAGE_DECO - len(PC_STR) + 1) + \ + str(TOTAL_PAGE_COUNT) + ' pages' else: print 'ERROR: \'' + path + '\' is not a directory' diff --git a/input.txt b/input.txt deleted file mode 100644 index c516326..0000000 Binary files a/input.txt and /dev/null differ diff --git a/ut_contribution_total.py b/ut_contribution_total.py new file mode 100755 index 0000000..e47a539 --- /dev/null +++ b/ut_contribution_total.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# AUTHOR: hieulq + +import copy +import time +import requests + +# Change this list based on your member's info +USER_LIST = ['hieulq', 'duonghq', 'namnh', 'daidv', 'trungnv', 'kiennt26'] + +# No need to change in case of changing Stackalytics API or changing cycle +CONTRIB_URL = "http://stackalytics.com/api/1.0/contribution" +RELEASE = "pike" + +# Common query info +PROJECT_TYPE = "openstack" +COMPANY = "fujitsu" +PAYLOAD = {'release': RELEASE, 'project_type': PROJECT_TYPE, + 'company': COMPANY} + + +def get_statistics(is_member=False): + total_ps, total_cm, total_rv, total_mbp, total_rbp = 0, 0, 0, 0, 0 + params = copy.deepcopy(PAYLOAD) + if is_member: + params['start_date'] = int(time.time() - 604800) + params['end_date'] = int(time.time()) + + for user in USER_LIST: + params['user_id'] = user + resp = requests.get(CONTRIB_URL, params=params) + if resp.ok: + parsed = resp.json()['contribution'] + user_ps_count = parsed['patch_set_count'] + user_cm_count = parsed['commit_count'] + user_bp_merge = parsed['completed_blueprint_count'] + user_bp_review = parsed['drafted_blueprint_count'] + user_rv_count = parsed['marks']['-1'] + parsed['marks']['1'] + \ + parsed['marks']['-2'] + parsed['marks']['2'] + + if is_member: + print("* %s's review increase: %d" % (user, user_rv_count)) + else: + print("* %s's review: %d" % (user, user_rv_count)) + + total_ps += user_ps_count + total_cm += user_cm_count + total_rv += user_rv_count + total_mbp += user_bp_merge + total_rbp += user_bp_review + else: + print("There are something wrong with user %s !" % user) + return None + + return total_ps, total_cm, total_rv, total_mbp, total_rbp + + +def main(): + print("===== Member's total review count =====") + team_res = get_statistics(is_member=False) + if team_res: + print("===== %s: Team contribution report =====" % time.ctime()) + print("* Total in-review BP: %d" % team_res[4]) + print("* Total merged BP: %d" % team_res[3]) + print("* Total commits count: %d" % team_res[1]) + print("* Total reviews count: %d" % team_res[2]) + print("* Total in-review patches: %d" % (team_res[0] - team_res[1])) + print("===== FIN ======") + + print("===== Member's contribution compare with last week =====") + member_res = get_statistics(is_member=True) + if member_res: + print("* Total commits since last week: %d" % member_res[1]) + print("* Total patches since last week: %d" % + (member_res[0] - member_res[1])) + + +if __name__ == '__main__': + main() diff --git a/xdeliver.py b/xdeliver.py index 4cee1fa..c4cb286 100755 --- a/xdeliver.py +++ b/xdeliver.py @@ -23,9 +23,10 @@ # DEFAULT SETTINGS -PROTO = 'https://' +PROTO = 'http://' OWNER = 'hieulq' GERRIT_HOST = 'review.openstack.org' +GIT_HOST = 'git.openstack.org' GERRIT_PORT = 29418 START_TIME = (date.today() - timedelta(days=7)).isoformat() OUTPUT = 'Deliver' @@ -63,7 +64,9 @@ def create_file(project_name, bug_name, patch_url, pinfo=None, patch_num=1): f.write(get_content(patch_url)) except TypeError: LOG.error('Failed to get PS raw data! Retrying..') - continue + with open(filename, 'w+') as f: + f.write('Repository moved!') + break break outfile = txt2pdf.convert(filename) os.remove(filename) @@ -105,7 +108,7 @@ def get_topic_name(ps): count = msg.count(bp) for x in range(0, count): topic.bp += 'BP_%s' % \ - msg.split(bp)[x + 1].splitlines()[0].rstrip() + msg.split(bp)[x + 1].splitlines()[0].rstrip() if count > 1: topic.bp += '_' if count > 1: @@ -173,15 +176,9 @@ def main(): server = options.server keyfile = options.keyfile passp = options.passphrase - user = options.user - bdel = options.bdel - rsite = gssh.Site(server, owner, port, keyfile, passp).connect() - plist = gssh.Query('--commit-message', - 'owner:' + user + - ' AND (status:merged OR status:pending)' + - ' since:' + start_time).execute_on(rsite) - LOG.info("| Total gerrit results: %d", len(plist)) + # remove existing folder + bdel = options.bdel if bdel == 1: shutil.rmtree(OUTPUT, True) @@ -198,51 +195,73 @@ def main(): else: root_dir = "/".join([os.getcwd(), OUTPUT]) - for p in plist: - LOG.info("|_ Generating doc from gerrit patch: %s ", p.number) - os.chdir(root_dir) - - project_name = '[' + p.repo_name.split('/')[-1] + ']' - topic = get_topic_name(p) - pss = p.patchsets - patch_urls = {} - if topic.bug: - name = topic.bug - else: - name = topic.change - for num, ps in pss.iteritems(): - patch_urls[num] = PROTO + GERRIT_HOST + \ - '/gitweb?p=' + p.repo_name + \ - '.git;a=patch;h=' + \ - ps.raw['revision'] - - LOG.info('|____ Project: %s', project_name) - LOG.info('|____ Topic: %s', name) - LOG.info('|____ PS count: %s', len(patch_urls)) - patch_name = project_name - if topic.bp: - directory = create_folder(patch_name, topic.bp) - os.chdir("/".join([os.getcwd(), directory])) - patch_name = None - if len(patch_urls) == 1: - create_file(patch_name, name, patch_urls[1], ( - p.patchsets[1].raw['sizeInsertions'], - p.patchsets[1].raw['sizeDeletions'], - p.raw['commitMessage']. + rsite = gssh.Site(server, owner, port, keyfile, passp).connect() + + # get user from user list + user_list = options.user.split(",") + for user in user_list: + try: + plist = gssh.Query('--commit-message', + 'owner:' + user + + ' AND (status:merged OR status:pending)' + + ' since:' + start_time).execute_on(rsite) + + # check invalid username + except gssh.gerritsite.InvalidUserError: + LOG.error('INVALID USERNAME: ' + user) + break + + LOG.info("| Total gerrit results: %d", len(plist)) + + for p in plist: + LOG.info("|_ Generating doc from gerrit patch: %s ", p.number) + os.chdir(root_dir) + + project_name = '[' + p.repo_name.split('/')[-1] + ']' + topic = get_topic_name(p) + pss = p.patchsets + patch_urls = {} + if topic.bug: + name = topic.bug + else: + name = topic.change + for num, ps in pss.iteritems(): + # patch_urls[num] = PROTO + GERRIT_HOST + \ + # '/gitweb?p=' + p.repo_name + \ + # '.git;a=patch;h=' + \ + # ps.raw['revision'] + patch_urls[num] = PROTO + GIT_HOST + \ + '/cgit/' + p.repo_name + \ + '/patch/?id=' + ps.raw['revision'] + + LOG.info('|____ Project: %s', project_name) + LOG.info('|____ Topic: %s', name) + LOG.info('|____ PS count: %s', len(patch_urls)) + patch_name = project_name + if topic.bp: + directory = create_folder(patch_name, topic.bp) + os.chdir("/".join([os.getcwd(), directory])) + patch_name = None + if len(patch_urls) == 1: + create_file(patch_name, name, patch_urls[1], ( + p.patchsets[1].raw['sizeInsertions'], + p.patchsets[1].raw['sizeDeletions'], + p.raw['commitMessage']. split('Change-Id')[0].replace('\n', ' '))) - else: - directory = create_folder(patch_name, name, - p.raw['commitMessage']. - split('Change-Id')[0].replace('\n', ' ')) - os.chdir("/".join([os.getcwd(), directory])) - tmp_name = name - if topic.bug and topic.change: - tmp_name = topic.bug + '_' + topic.change - for patch_num, patch_url in patch_urls.iteritems(): - create_file(None, tmp_name, patch_url, ( - p.patchsets[patch_num].raw['sizeInsertions'], - p.patchsets[patch_num].raw['sizeDeletions']), - patch_num=patch_num) + else: + directory = create_folder(patch_name, name, + p.raw['commitMessage']. + split('Change-Id')[0].replace('\n', + ' ')) + os.chdir("/".join([os.getcwd(), directory])) + tmp_name = name + if topic.bug and topic.change: + tmp_name = topic.bug + '_' + topic.change + for patch_num, patch_url in patch_urls.iteritems(): + create_file(None, tmp_name, patch_url, ( + p.patchsets[patch_num].raw['sizeInsertions'], + p.patchsets[patch_num].raw['sizeDeletions']), + patch_num=patch_num) LF.close() LOG.info("|_ FIN!")