-
Notifications
You must be signed in to change notification settings - Fork 0
/
autobot.py
54 lines (43 loc) · 1.52 KB
/
autobot.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
# Autobot (c) 2019 Alexander Pick
import glob
import sys
import os
import urllib.request
import urllib.parse
import xml.etree.ElementTree as ET
import time
import subprocess
from pprint import pprint
files = glob.glob(sys.argv[1]+"/*")
projectname = sys.argv[2]
host = "127.0.0.1:7340"
url = "http://" + host + "/index.xml"
for file in files:
poll = 1
while(poll):
try:
baseurl = parsed_uri = urllib.parse.urlparse(url)
root = ET.parse(urllib.request.urlopen(url)).getroot()
projects = root.findall("project")
#polling code
isActive = 0
currentState = ""
for project in projects:
state = project.find("state").text
#print(state)
if state not in { "Finished", "Stalled", "None"}:
isActive = 1
currentState = state
break
if isActive == 0:
print("queing.. "+file)
break
else:
print("AUTOBOT: waiting... "+currentState)
time.sleep(150)
except Exception as e:
print(e)
time.sleep(150)
pass
subprocess.Popen(r'"C:\Program Files\GrammaTech\CodeSonar\codesonar\bin\codesonar.exe" analyze '+projectname+' '+host+' cs-bin-scan '+file+' -use_ida yes -foreground -clean-backend', shell=True)
time.sleep(150)