Skip to content

Commit 904020f

Browse files
authored
Merge pull request #9 from Vaarlion/v3.0-branch
V3.0 branch
2 parents 95a2ace + 3e23fc0 commit 904020f

10 files changed

+60
-59
lines changed

pepperboard/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/usr/bin/env python
2-
# -*- coding:utf-8 -*-
1+
#!/usr/bin/env python3
2+
# -*- coding:utf-8 -*-

pepperboard/core/__init__.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

44
import getopt
@@ -13,15 +13,15 @@
1313

1414

1515
def usage():
16-
print "USAGE: " + sys.argv[0] + " [OPTIONS]"
17-
print "Pepperboard : neat and simple salt dashboards"
18-
print "--help|-h : Prints an awesome help message"
19-
print "--output=|-o : comma separated values of files to write dashboards given with the \"-d\" argument"
20-
print "--dashboards=|-d : comma separated values of dashboards"
21-
print "--threads=|-t : comma separated values of threads count to be used (must be greater than 0). Prefix the number by \"f\" if you want more threads than CPU core count"
22-
print "--grains=|-g : comma separated values of grains to be used with the mgrains dashboard. This argument implies \"-d 'mgrains'\""
23-
print "--dellapikey=|-a : Dell API key used by the dellwarranty dashboard. This argument implies \"-d 'mgrains'\""
24-
print "--list|-l : List available dashboards"
16+
print("USAGE: " + sys.argv[0] + " [OPTIONS]")
17+
print("Pepperboard : neat and simple salt dashboards")
18+
print("--help|-h : Prints an awesome help message")
19+
print("--output=|-o : comma separated values of files to write dashboards given with the \"-d\" argument")
20+
print("--dashboards=|-d : comma separated values of dashboards")
21+
print("--threads=|-t : comma separated values of threads count to be used (must be greater than 0). Prefix the number by \"f\" if you want more threads than CPU core count")
22+
print("--grains=|-g : comma separated values of grains to be used with the mgrains dashboard. This argument implies \"-d 'mgrains'\"")
23+
print("--dellapikey=|-a : Dell API key used by the dellwarranty dashboard. This argument implies \"-d 'mgrains'\"")
24+
print("--list|-l : List available dashboards")
2525

2626

2727
def getmasterstatus():
@@ -44,25 +44,25 @@ def countminions():
4444

4545
def pepper_main():
4646
if getmasterstatus() == 1:
47-
print "Error : Your Salt Master isn't running. Exiting..."
47+
print("Error : Your Salt Master isn't running. Exiting...")
4848
usage()
4949
sys.exit(2)
5050

5151
if countminions() == 0:
52-
print "Error : You don't have any minions registered to the Salt Master. Exiting..."
52+
print("Error : You don't have any minions registered to the Salt Master. Exiting...")
5353
usage()
5454
sys.exit(2)
5555

5656
if not sys.argv[1:]:
57-
print "Error : Pepperboard wrongly called"
57+
print("Error : Pepperboard wrongly called")
5858
usage()
5959
sys.exit(2)
6060

6161
try:
6262
opts, args = getopt.getopt(sys.argv[1:], 'o:d:t:g:a:lh',
6363
['output=', 'dashboards=', 'threads=', 'grains=', 'dellapikey=', 'list', 'help'])
6464
except getopt.GetoptError as err:
65-
print str(err)
65+
print(str(err))
6666
usage()
6767
sys.exit(2)
6868

@@ -78,14 +78,14 @@ def pepper_main():
7878
for o, a in opts:
7979
if o in ("-o", "--output"):
8080
if not a:
81-
print "Error : missing output file"
81+
print("Error : missing output file")
8282
usage()
8383
sys.exit(2)
8484
else:
8585
outputs = a.split(',')
8686
elif o in ("-t", "--threads"):
8787
if not a:
88-
print "Error : Missing thread number"
88+
print("Error : Missing thread number")
8989
usage()
9090
sys.exit(2)
9191
else:
@@ -99,28 +99,28 @@ def pepper_main():
9999
except ImportError:
100100
raise ImportError("You need psutil python module")
101101
if int(th) > cpu_count(logical=True):
102-
print "Error : threads count cannot be greater than CPU core count unless you force it with \"f\" before the number"
102+
print("Error : threads count cannot be greater than CPU core count unless you force it with \"f\" before the number")
103103
sys.exit(2)
104104
elif int(th) == 0:
105-
print "Error : threads count must be greater than 0"
105+
print("Error : threads count must be greater than 0")
106106
usage()
107107
sys.exit(2)
108108
else:
109109
nthreads.append(int(th))
110110
elif o in ("-d", "--dashboards"):
111111
if not a:
112-
print "Error : Missing dashboards list"
112+
print("Error : Missing dashboards list")
113113
usage()
114114
sys.exit(2)
115115
else:
116116
dashs = a.split(',')
117117
for dash in dashs:
118118
if dash not in available_dashboards:
119-
print "Error : Dashboard " + dash + " not available."
119+
print("Error : Dashboard " + dash + " not available.")
120120
sys.exit(2)
121121
elif o in ("-g", "--grains"):
122122
if not a:
123-
print "Error : mgrains argument must be a CSV list"
123+
print("Error : mgrains argument must be a CSV list")
124124
usage()
125125
sys.exit(2)
126126
else:
@@ -129,44 +129,44 @@ def pepper_main():
129129
grains = a.split(',')
130130
elif o in ("-a", "--dellapikey"):
131131
if not a:
132-
print "Error : dellapikey argument can't be empty"
132+
print("Error : dellapikey argument can't be empty")
133133
usage()
134134
sys.exit(2)
135135
else:
136136
if not "dellwarranty" in dashs:
137137
dashs.append("dellwarranty")
138138
dellapikey = a
139139
elif o in ("-l", "--list"):
140-
print "\n".join(available_dashboards)
140+
print("\n".join(available_dashboards))
141141
elif o in ("-h", "--help"):
142142
usage()
143143
sys.exit(0)
144144
else:
145-
print "Unhandled option"
145+
print("Unhandled option")
146146

147147
if 'mgrains' in dashs and len(grains) == 0:
148-
print "Error : You must the grains list when using the mgrains dashboard"
148+
print("Error : You must the grains list when using the mgrains dashboard")
149149
sys.exit(2)
150150

151151
if 'dellwarranty' in dashs and not dellapikey:
152-
print "Error : You must set the dellapikey when using the dellwarranty dashboard"
152+
print("Error : You must set the dellapikey when using the dellwarranty dashboard")
153153
sys.exit(2)
154154

155155
if len(nthreads) == 0:
156156
if not len(outputs) == len(dashs):
157-
print "Error : All lists aren't the same size"
157+
print("Error : All lists aren't the same size")
158158
sys.exit(2)
159159
else:
160160
for dash, out in zip(dashs, outputs):
161161
if dash == 'mgrains':
162-
pepperboard.dashboards.gendashboard(dash, out, None, grains)
162+
pepperboard.dashboards.gendashboard(dash, out, input=grains)
163163
elif dash == 'dellwarranty':
164-
pepperboard.dashboards.gendashboard(dash, out, None, dellapikey)
164+
pepperboard.dashboards.gendashboard(dash, out, input=dellapikey)
165165
else:
166166
pepperboard.dashboards.gendashboard(dash, out)
167167
else:
168168
if not len(outputs) == len(nthreads) == len(dashs):
169-
print "Error : All lists aren't the same size"
169+
print("Error : All lists aren't the same size")
170170
sys.exit(2)
171171
else:
172172
for dash, out, nth in zip(dashs, outputs, nthreads):

pepperboard/dashboards/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

44
import importlib
@@ -14,7 +14,7 @@ def gendashboard(ident, output, nthreads=None, input=None):
1414
elif "gendash" in dir(mod):
1515
mod.gendash(output, nthreads)
1616
else:
17-
print "Error : gendata() or gendash() methods not found in "+mod.__name__
17+
print("Error : gendata() or gendash() methods not found in "+mod.__name__)
1818
sys.exit(2)
1919

2020

@@ -35,7 +35,7 @@ def gentable(input, output):
3535
for header in input['headers']:
3636
foutput.write('<th>'+header+'</th>')
3737
foutput.write('</tr></thead><tbody>\n')
38-
for k, v in input['data'].iteritems():
38+
for k, v in input['data'].items():
3939
if input['ncol'] == 2:
4040
foutput.write('<tr><td valign=\"top\">'+str(k)+'</td><td>')
4141
if isinstance(v,dict):

pepperboard/dashboards/dellwarranty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

44

pepperboard/dashboards/highstates.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

44

@@ -24,7 +24,7 @@ def simhighstate(server):
2424
if server in hst:
2525
minionos = c.cmd(server, 'grains.items')[server]['os'].lower()
2626
if isinstance(hst[server], dict):
27-
for k, v in hst[server].iteritems():
27+
for k, v in hst[server].items():
2828
if not v['result']:
2929
tbc.append("<li>" + v['name'] + "</li>")
3030
processedserver.append(server)
@@ -60,7 +60,7 @@ def simhighstate(server):
6060
)
6161
foutput.write('<script src=\"//www.kryogenix.org/code/browser/sorttable/sorttable.js\"></script>')
6262
foutput.write('<style>table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {content: \" \\25B4\\25BE\"}')
63-
for os, logo in core.logos.iteritems():
63+
for os, logo in core.logos.items():
6464
foutput.write('#'+os+'{background:url(data:image/png;base64,'+logo+') left no-repeat;height:20px;width:20px;float:left;padding-right:5px}')
6565
foutput.write('</style>')
6666
foutput.write('<link rel=\"stylesheet\" href=\"//yui-s.yahooapis.com/pure/0.6.0/pure-min.css\">')

pepperboard/dashboards/mgrains.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

4+
import sys
5+
import concurrent.futures
6+
import salt.client
7+
import salt.runner
8+
import collections
9+
import warnings
10+
411

512
def gendata(grains, nthreads):
6-
import sys
7-
import concurrent.futures
8-
import salt.client
9-
import salt.runner
10-
import collections
11-
import warnings
13+
1214
warnings.simplefilter("ignore", DeprecationWarning)
1315
result = {}
1416
toreturn = {}
1517
if nthreads is None:
1618
nthreads = 8
1719
if grains is None:
18-
print "Error : Grains must be specified"
20+
print("Error : Grains must be specified")
1921
sys.exit(2)
2022

2123
def getgrainscontent(grains, server):

pepperboard/dashboards/upgrades.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

44

@@ -35,7 +35,7 @@ def checkupdates(server):
3535
len(upd[
3636
server])) + '</a><div class=\"pkglist\" id=\"' + server + '\" style=\"display:none\"><ul>' + ''.join(
3737
['<li>{} : {}</li>'.format(k, v) for k, v in
38-
collections.OrderedDict(sorted(upd[server].items())).iteritems()]) + '</ul></div>'
38+
collections.OrderedDict(sorted(upd[server].items())).items()]) + '</ul></div>'
3939
result[server] = '<tr><td valign=\"top\">' + displogo + server + '</td><td>' + displaypkgs + '</td></tr>\n'
4040
else:
4141
result[server] = '<tr><td valign=\"top\">' + displogo + server + '</td><td>Error during upgrades retrieveing (' + upd[server] + ')</td></tr>\n'
@@ -55,7 +55,7 @@ def checkupdates(server):
5555
)
5656
foutput.write('<script src=\"//www.kryogenix.org/code/browser/sorttable/sorttable.js\"></script>')
5757
foutput.write('<style>table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {content: \" \\25B4\\25BE\"}')
58-
for os, logo in core.logos.iteritems():
58+
for os, logo in core.logos.items():
5959
foutput.write('#'+os+'{background:url(data:image/png;base64,'+logo+') left no-repeat;height:20px;width:20px;float:left;padding-right:5px}')
6060
foutput.write('</style>')
6161
foutput.write('<link rel=\"stylesheet\" href=\"//yui-s.yahooapis.com/pure/0.6.0/pure-min.css\">')

requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
futures>=3
21
psutil
3-
salt
2+
salt

scripts/pepperboard

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding:utf-8 -*-
33

44
from pepperboard import core

setup.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
from setuptools import setup
@@ -8,11 +8,11 @@
88

99
setup(
1010
name='pepperboard',
11-
version='2.4',
11+
version='3.0',
1212
packages=['pepperboard', 'pepperboard.core', 'pepperboard.dashboards'],
1313
scripts=['scripts/pepperboard'],
1414
url='https://github.com/webedia-dev/pepperboard',
15-
download_url='https://github.com/webedia-dev/pepperboard/releases/tag/v2.4',
15+
download_url='https://github.com/webedia-dev/pepperboard/releases/tag/v3.0',
1616
license='Apache',
1717
author='Cyril LAVIER',
1818
author_email='cyril.lavier@webedia-group.com',
@@ -22,9 +22,9 @@
2222
'Development Status :: 5 - Production/Stable',
2323
'Intended Audience :: System Administrators',
2424
'Natural Language :: English',
25-
'Programming Language :: Python :: 2',
26-
'Programming Language :: Python :: 2.7',
25+
'Programming Language :: Python :: 3',
26+
'Programming Language :: Python :: 3.5',
2727
'License :: OSI Approved :: Apache Software License',
2828
'Topic :: System :: Monitoring',
2929
],
30-
)
30+
)

0 commit comments

Comments
 (0)