-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmsvc.py
More file actions
201 lines (169 loc) · 5.83 KB
/
msvc.py
File metadata and controls
201 lines (169 loc) · 5.83 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import requests
import json
from datetime import datetime, timedelta
import os
BASE_URL = "https://sendvsfeedback2.azurewebsites.net/api/searchquery/searchV2"
MAX_TAKE = 40
REMOVED_STATE = ["notabug", "duplicate", "otherproduct", "notenoughinfo", "outofscope"]
REMOVED_ROADMAP = "roadmap" # tags
current_bug_count = 0
file_index = 1
MAX_BUGS_PER_FILE = 240
compile_name = 'MSVC'
file_name = ''
now = ''
def create_folder(formatted_time):
output_directory = f"output/{formatted_time}"
if not os.path.exists(output_directory):
os.makedirs(output_directory)
return output_directory
def save_data(issue) :
global now
formatted_time = now.strftime('%Y%m%d_%H%M%S')
output_directory = create_folder(formatted_time)
file_name = f'{output_directory}/{compile_name}_COMMUNITY_{formatted_time}'
global current_bug_count
global file_index
if current_bug_count >= MAX_BUGS_PER_FILE:
file_index += 1
current_bug_count = 0
with open(file_name + f"_{file_index}.md", 'a') as f:
# print("TITLE : ", issue["title"])
# print("TAGS : ")
# for tag in issue["tags"]:
# print(tag["value"], ", ")
# print("LINK : ", issue["communityUrl"])
# print("STATE : ", issue["state"])
# print("CREATED TIME : ", issue["createdDateUtc"])
# print('TEXT : ', issue["text"])
title = "None"
if issue["title"] is not None :
title = issue["title"]
created_at = "None"
if issue["createdDateUtc"] is not None :
created_at = issue["createdDateUtc"]
html_url = "None"
if issue["communityUrl"] is not None:
html_url = issue["communityUrl"]
state = "None"
if issue["state"] is not None:
state = issue["state"]
body = "None"
if issue["text"] is not None :
body = issue["text"]
f.write("\n\n")
f.write(f"### compiler : `{compile_name}`\n")
f.write(f"### title : `{title}`\n")
f.write("### open_at : `" + created_at + "`\n")
f.write("### link : " + html_url + "\n")
f.write("### status : `" + state + "`\n")
f.write("### tags : `")
for label in issue["tags"]:
f.write(label["value"] + ", ")
f.write("`\n")
f.write("### content : \n" + body + "")
f.write("\n\n\n")
f.write("---\n")
current_bug_count += 1
def create_headers():
return {
"Host": "sendvsfeedback2.azurewebsites.net",
"Content-Length": "826",
"Sec-Ch-Ua": "",
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json",
"Sec-Ch-Ua-Mobile": "?0",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.97 Safari/537.36",
"Sec-Ch-Ua-Platform": "",
"Origin": "https://developercommunity.visualstudio.com",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://developercommunity.visualstudio.com/",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
"Connection": "close"
}
def create_data(page):
# 바디 (JSON) 데이터
return {
"searchFor": {
"source": "developer-community",
"tags": [
{"type": "feedbackSessionId", "value": "WEB_78dcbe97-ebee-4afe-8a1f-9999"},
{"type": "vs-otuid", "value": None},
{"type": "vote-userid", "value": None},
{"type": "vs-providerid", "value": None},
{"type": "vsts-email", "value": None},
{"type": "vsts-displayname", "value": None}
],
"version": 20220110,
"text": "",
"customerChosenArea": None,
"user": "",
"title": "",
"dotNetEntries": [],
"watsonEntries": []
},
"skip": page,
"take": MAX_TAKE,
"sort": "relevance",
"filter": "all",
"spaceIds": ["62"],
"stateGroup": None,
"version": 3,
"topicsToFilterBy": [],
"returnTotalCount": False,
"typesFilterFlags": 3,
"includeCountsByType": True,
"searchStartTimeMsec": 1698322985385,
"searchSource": "SearchPage",
"clientVersion": "1.0.151",
"capabilities": {
"canDisplayTypedMarkdown": True,
"expRichEditor": True,
"rawTextSupport": True,
"expFlights": ""
}
}
def send_request(page):
headers = create_headers()
data = create_data(page)
while True:
try:
response = requests.post(BASE_URL, headers=headers, json=data)
response.raise_for_status()
return response.json()
except (requests.ConnectionError, requests.Timeout, requests.RequestException, json.JSONDecodeError) as e:
print(f"Error occurred: {e}, retrying.. {page}")
continue
def print_issue_data(issue):
print(issue)
print("\n\n")
def is_issue_relevant(issue):
if issue["state"] in REMOVED_STATE: # 상태 체크
return False
for tag in issue["tags"]:
if REMOVED_ROADMAP in tag["value"]: # 태그 체크
return False
return True
def get_msvc_issue(page):
data = send_request(page)
if not data:
return True
print(len(data["results"]))
for issue in data["results"]:
if is_issue_relevant(issue):
save_data(issue)
return False
def main():
global now
now = datetime.now()
page = 0
while True:
if get_msvc_issue(page):
break
page += MAX_TAKE
print("end")
if __name__ == "__main__":
main()