-
Notifications
You must be signed in to change notification settings - Fork 5
/
checkPool.py
executable file
·155 lines (139 loc) · 4.81 KB
/
checkPool.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
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
# Note this requires an internet connection
# Filename: checkPool.py
import os
import sys
import urllib.request
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
EPS=1e-8
#following from Python cookbook, #475186
def has_colours(stream):
if not hasattr(stream, "isatty"):
return False
if not stream.isatty():
return False # auto color only on TTYs
try:
import curses
curses.setupterm()
return curses.tigetnum("colors") > 2
except:
# guess false in case of error
return False
has_colours = has_colours(sys.stdout)
def normalprintout(text, colour=WHITE):
if has_colours:
seq = "\x1b[1;%dm" % (30+colour) + text + "\x1b[0m"
#sys.stdout.write(seq)
sys.stdout.write('{}'.format(seq))
else:
sys.stdout.write('{}'.format(text))
def printout(text, colour=WHITE):
if has_colours:
seq = "\x1b[1;%dm" % (30+colour) + text + "\x1b[0m"
#sys.stdout.write(seq)
sys.stdout.write('{:>50}'.format(seq))
else:
sys.stdout.write('{:>50}'.format(text))
#import urllib2
response = urllib.request.urlopen("http://biorg.cis.fiu.edu/pluma/plugins.html")
page_source = str(response.read())
#print(page_source)
pool = set()
local = set()
normalprintout("************************************", GREEN)
print("")
normalprintout("PLUGIN COUNTS:", GREEN)
print("")
websites =set()
# Plugin Table
while (page_source.find("</table>") != -1):
plugin_table = page_source[page_source.find("<table "):page_source.find("</table>")]
plugins = plugin_table.split("<tr>")
count=0
for plugin in plugins:
while(plugin.find("</a>") != -1):
content = plugin[plugin.find("<a href="):plugin.find("</a>")]
content = content.replace('<a href=', '')
data = content.split('>')
websites.add(data[0][1:len(data[0])-1])
plugin = plugin[plugin.find("</a>")+1:]
#if (len(data) == 2):
#print(data[0])
#pool.add(data[1])
#count += 1
#if (os.path.exists(data[1])):
# print("Plugin "+data[1]+" already installed.")
#else:
# repo = data[0][1:len(data[0])-1] # Remove quotes
#os.system("git clone "+repo)
#normalprintout(str(count)+" ", GREEN)
#print(count,end=" ")
page_source = page_source[page_source.find("</table>")+1:]
count=0
for website in websites:
localcount = 0
response = urllib.request.urlopen("http://biorg.cis.fiu.edu/pluma/"+website)
page_source = str(response.read())
while (page_source.find("</table>") != -1):
plugin_table = page_source[page_source.find("<table "):page_source.find("</table>")]
# Individual Plugins
plugins = plugin_table.split("<tr>")
for plugin in plugins:
while(plugin.find("</a>") != -1):
content = plugin[plugin.find("<a href="):plugin.find("</a>")]
content = content.replace('<a href=', '')
data = content.split('>')
if (len(data) == 2):
pool.add(data[1])
count += 1
localcount += 1
#if (os.path.exists(data[1])):
# print("Plugin "+data[1]+" already installed.")
#else:
# repo = data[0][1:len(data[0])-1] # Remove quotes
#os.system("git clone "+repo)
plugin = plugin[plugin.find("</a>")+1:]
#normalprintout(str(count)+" ", GREEN)
#print(count,end=" ")
page_source = page_source[page_source.find("</table>")+1:]
normalprintout(website+"\t["+str(localcount)+"]\n", GREEN)
if (len(sys.argv) > 1):
plugins = [sys.argv[1]]
else:
plugins = os.listdir("./plugins")
for plugin in plugins:
local.add(plugin)
normalprintout("\nTOTAL\t["+str(len(pool))+"]\n", RED)
print("")
normalprintout("************************************", GREEN)
print("")
normalprintout("************************************", BLUE)
print("")
normalprintout("PLUGINS IN POOL, NOT LOCAL:", BLUE)
print("")
for plugin in pool-local:
normalprintout(plugin, BLUE)
print("")
normalprintout("************************************", BLUE)
print("")
normalprintout("************************************", MAGENTA)
print("")
normalprintout("PLUGINS LOCAL, NOT IN POOL:", MAGENTA)
print("")
for plugin in local-pool:
if (plugin[0] != "." and plugin != "README" and not plugin.endswith(".py") and not plugin.endswith(".txt")):
normalprintout(plugin, MAGENTA)
print("")
normalprintout("************************************", MAGENTA)
print("")
normalprintout("************************************", YELLOW)
print("")
normalprintout("PLUGINS THAT DIFFER FROM REPOSITORY:", YELLOW)
print("")
for plugin in local.intersection(pool):
x = os.popen('cd plugins/'+plugin+'; git diff; cd ..').read()
if (len(x) != 0):
normalprintout(plugin, YELLOW)
print("")
os.system("cd ..")
normalprintout("************************************", YELLOW)
print("")