forked from vlead/import-issues-to-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
issues.py
84 lines (72 loc) · 2.39 KB
/
issues.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
import sys
import csv
import json
import urllib
from config import *
import time
column = {}
def defineTitle(header):
index = 0
for title in header:
column[title] = index
index+=1
return
def printIssue(reader):
issueNumber = 1
for row in reader:
if issueNumber >= 5:
break
print issueNumber, row[column["Description"]],
issueNumber+=1
return
def postRequest(curl):
os.system(curl)
return
def createIssue(row, projectName):
dictionary = {}
project = projectName
experimentName = row[column["Experiment name"]]
feature = row[column["Feature"]]
testStepNum = row[column["Test Step No"]]
testStepNum = testStepNum.zfill(2)
subject = "QA_%s_%s" %(experimentName, feature)
explink = urllib.quote(experimentName)
featureLink = urllib.quote(feature)
link = "https://github.com/%s/%s/blob/master/test-cases/integration_test-cases/%s/%s_%s_%s.org" %(organization, project, explink, explink, testStepNum, featureLink)
description = row[column["Description"]] + "\n Test Step Link:\n%s" %(link)
statusLabel = "Status: " + row[column["Status"]]
severityLabel = "Severity: " + row[column["Severity"]]
categoryLabel = "Category: " + row[column["Category"]]
#assignedByLabel = "Assigned by: " + row[column["Assigned by"]]
releaseNumLabel = "Release Number: " + row[column["Release Number"]]
# dateLabel = "Start Date: " + row[column["Start date"]]
developedByLabel = "Developed By: " + row[column["Developed By"]]
dictionary["title"] = subject
dictionary["body"] = description
dictionary["labels"] = [statusLabel, severityLabel, categoryLabel, releaseNumLabel, developedByLabel]
jsonString = json.dumps(dictionary)
curl = """curl -g -i -H 'Authorization: token %s' -d '%s' %s""" %(token, jsonString, githubUrl)
postRequest(curl)
return
def main(args):
filePointer = open(args[1], 'r')
basename = os.path.basename(args[1])
projectName = basename.rstrip(".csv")
reader = csv.reader(filePointer, delimiter=',')
header = reader.next()
defineTitle(header)
# printIssue(reader)
rowIndex = 1
row = reader.next()
while row:
if rowIndex >= 35:
time.sleep(20)
rowIndex = 0
createIssue(row, projectName)
row = reader.next()
rowIndex+=1
filePointer.close()
return
if __name__ == "__main__":
main(sys.argv)