diff --git a/pepperboard/__init__.py b/pepperboard/__init__.py index b4c4472..c53f601 100755 --- a/pepperboard/__init__.py +++ b/pepperboard/__init__.py @@ -1,2 +1,2 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- \ No newline at end of file +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- diff --git a/pepperboard/core/__init__.py b/pepperboard/core/__init__.py index 39a05ae..2228db5 100644 --- a/pepperboard/core/__init__.py +++ b/pepperboard/core/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- import getopt @@ -13,15 +13,15 @@ def usage(): - print "USAGE: " + sys.argv[0] + " [OPTIONS]" - print "Pepperboard : neat and simple salt dashboards" - print "--help|-h : Prints an awesome help message" - print "--output=|-o : comma separated values of files to write dashboards given with the \"-d\" argument" - print "--dashboards=|-d : comma separated values of dashboards" - 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" - print "--grains=|-g : comma separated values of grains to be used with the mgrains dashboard. This argument implies \"-d 'mgrains'\"" - print "--dellapikey=|-a : Dell API key used by the dellwarranty dashboard. This argument implies \"-d 'mgrains'\"" - print "--list|-l : List available dashboards" + print("USAGE: " + sys.argv[0] + " [OPTIONS]") + print("Pepperboard : neat and simple salt dashboards") + print("--help|-h : Prints an awesome help message") + print("--output=|-o : comma separated values of files to write dashboards given with the \"-d\" argument") + print("--dashboards=|-d : comma separated values of dashboards") + 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") + print("--grains=|-g : comma separated values of grains to be used with the mgrains dashboard. This argument implies \"-d 'mgrains'\"") + print("--dellapikey=|-a : Dell API key used by the dellwarranty dashboard. This argument implies \"-d 'mgrains'\"") + print("--list|-l : List available dashboards") def getmasterstatus(): @@ -44,17 +44,17 @@ def countminions(): def pepper_main(): if getmasterstatus() == 1: - print "Error : Your Salt Master isn't running. Exiting..." + print("Error : Your Salt Master isn't running. Exiting...") usage() sys.exit(2) if countminions() == 0: - print "Error : You don't have any minions registered to the Salt Master. Exiting..." + print("Error : You don't have any minions registered to the Salt Master. Exiting...") usage() sys.exit(2) if not sys.argv[1:]: - print "Error : Pepperboard wrongly called" + print("Error : Pepperboard wrongly called") usage() sys.exit(2) @@ -62,7 +62,7 @@ def pepper_main(): opts, args = getopt.getopt(sys.argv[1:], 'o:d:t:g:a:lh', ['output=', 'dashboards=', 'threads=', 'grains=', 'dellapikey=', 'list', 'help']) except getopt.GetoptError as err: - print str(err) + print(str(err)) usage() sys.exit(2) @@ -78,14 +78,14 @@ def pepper_main(): for o, a in opts: if o in ("-o", "--output"): if not a: - print "Error : missing output file" + print("Error : missing output file") usage() sys.exit(2) else: outputs = a.split(',') elif o in ("-t", "--threads"): if not a: - print "Error : Missing thread number" + print("Error : Missing thread number") usage() sys.exit(2) else: @@ -99,28 +99,28 @@ def pepper_main(): except ImportError: raise ImportError("You need psutil python module") if int(th) > cpu_count(logical=True): - print "Error : threads count cannot be greater than CPU core count unless you force it with \"f\" before the number" + print("Error : threads count cannot be greater than CPU core count unless you force it with \"f\" before the number") sys.exit(2) elif int(th) == 0: - print "Error : threads count must be greater than 0" + print("Error : threads count must be greater than 0") usage() sys.exit(2) else: nthreads.append(int(th)) elif o in ("-d", "--dashboards"): if not a: - print "Error : Missing dashboards list" + print("Error : Missing dashboards list") usage() sys.exit(2) else: dashs = a.split(',') for dash in dashs: if dash not in available_dashboards: - print "Error : Dashboard " + dash + " not available." + print("Error : Dashboard " + dash + " not available.") sys.exit(2) elif o in ("-g", "--grains"): if not a: - print "Error : mgrains argument must be a CSV list" + print("Error : mgrains argument must be a CSV list") usage() sys.exit(2) else: @@ -129,7 +129,7 @@ def pepper_main(): grains = a.split(',') elif o in ("-a", "--dellapikey"): if not a: - print "Error : dellapikey argument can't be empty" + print("Error : dellapikey argument can't be empty") usage() sys.exit(2) else: @@ -137,36 +137,36 @@ def pepper_main(): dashs.append("dellwarranty") dellapikey = a elif o in ("-l", "--list"): - print "\n".join(available_dashboards) + print("\n".join(available_dashboards)) elif o in ("-h", "--help"): usage() sys.exit(0) else: - print "Unhandled option" + print("Unhandled option") if 'mgrains' in dashs and len(grains) == 0: - print "Error : You must the grains list when using the mgrains dashboard" + print("Error : You must the grains list when using the mgrains dashboard") sys.exit(2) if 'dellwarranty' in dashs and not dellapikey: - print "Error : You must set the dellapikey when using the dellwarranty dashboard" + print("Error : You must set the dellapikey when using the dellwarranty dashboard") sys.exit(2) if len(nthreads) == 0: if not len(outputs) == len(dashs): - print "Error : All lists aren't the same size" + print("Error : All lists aren't the same size") sys.exit(2) else: for dash, out in zip(dashs, outputs): if dash == 'mgrains': - pepperboard.dashboards.gendashboard(dash, out, None, grains) + pepperboard.dashboards.gendashboard(dash, out, input=grains) elif dash == 'dellwarranty': - pepperboard.dashboards.gendashboard(dash, out, None, dellapikey) + pepperboard.dashboards.gendashboard(dash, out, input=dellapikey) else: pepperboard.dashboards.gendashboard(dash, out) else: if not len(outputs) == len(nthreads) == len(dashs): - print "Error : All lists aren't the same size" + print("Error : All lists aren't the same size") sys.exit(2) else: for dash, out, nth in zip(dashs, outputs, nthreads): diff --git a/pepperboard/dashboards/__init__.py b/pepperboard/dashboards/__init__.py index 8e8debb..3356482 100644 --- a/pepperboard/dashboards/__init__.py +++ b/pepperboard/dashboards/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- import importlib @@ -14,7 +14,7 @@ def gendashboard(ident, output, nthreads=None, input=None): elif "gendash" in dir(mod): mod.gendash(output, nthreads) else: - print "Error : gendata() or gendash() methods not found in "+mod.__name__ + print("Error : gendata() or gendash() methods not found in "+mod.__name__) sys.exit(2) @@ -35,7 +35,7 @@ def gentable(input, output): for header in input['headers']: foutput.write(''+header+'') foutput.write('\n') - for k, v in input['data'].iteritems(): + for k, v in input['data'].items(): if input['ncol'] == 2: foutput.write(''+str(k)+'') if isinstance(v,dict): diff --git a/pepperboard/dashboards/dellwarranty.py b/pepperboard/dashboards/dellwarranty.py index 43389d9..ce2cc15 100644 --- a/pepperboard/dashboards/dellwarranty.py +++ b/pepperboard/dashboards/dellwarranty.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- diff --git a/pepperboard/dashboards/highstates.py b/pepperboard/dashboards/highstates.py index 799bfc9..209a9a3 100644 --- a/pepperboard/dashboards/highstates.py +++ b/pepperboard/dashboards/highstates.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- @@ -24,7 +24,7 @@ def simhighstate(server): if server in hst: minionos = c.cmd(server, 'grains.items')[server]['os'].lower() if isinstance(hst[server], dict): - for k, v in hst[server].iteritems(): + for k, v in hst[server].items(): if not v['result']: tbc.append("
  • " + v['name'] + "
  • ") processedserver.append(server) @@ -60,7 +60,7 @@ def simhighstate(server): ) foutput.write('') foutput.write('') foutput.write('') diff --git a/pepperboard/dashboards/mgrains.py b/pepperboard/dashboards/mgrains.py index 45eb160..6b9b8e6 100644 --- a/pepperboard/dashboards/mgrains.py +++ b/pepperboard/dashboards/mgrains.py @@ -1,21 +1,23 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- +import sys +import concurrent.futures +import salt.client +import salt.runner +import collections +import warnings + def gendata(grains, nthreads): - import sys - import concurrent.futures - import salt.client - import salt.runner - import collections - import warnings + warnings.simplefilter("ignore", DeprecationWarning) result = {} toreturn = {} if nthreads is None: nthreads = 8 if grains is None: - print "Error : Grains must be specified" + print("Error : Grains must be specified") sys.exit(2) def getgrainscontent(grains, server): diff --git a/pepperboard/dashboards/upgrades.py b/pepperboard/dashboards/upgrades.py index db96ff3..f011c0a 100644 --- a/pepperboard/dashboards/upgrades.py +++ b/pepperboard/dashboards/upgrades.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- @@ -35,7 +35,7 @@ def checkupdates(server): len(upd[ server])) + '
    ' + collections.OrderedDict(sorted(upd[server].items())).items()]) + '' result[server] = '' + displogo + server + '' + displaypkgs + '\n' else: result[server] = '' + displogo + server + 'Error during upgrades retrieveing (' + upd[server] + ')\n' @@ -55,7 +55,7 @@ def checkupdates(server): ) foutput.write('') foutput.write('') foutput.write('') diff --git a/requirements.txt b/requirements.txt index 93ab576..530f436 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -futures>=3 psutil -salt \ No newline at end of file +salt diff --git a/scripts/pepperboard b/scripts/pepperboard index 26e0f1d..d6e02e4 100644 --- a/scripts/pepperboard +++ b/scripts/pepperboard @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- from pepperboard import core diff --git a/setup.py b/setup.py index 75bc6ce..5dab747 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- from setuptools import setup @@ -8,11 +8,11 @@ setup( name='pepperboard', - version='2.4', + version='3.0', packages=['pepperboard', 'pepperboard.core', 'pepperboard.dashboards'], scripts=['scripts/pepperboard'], url='https://github.com/webedia-dev/pepperboard', - download_url='https://github.com/webedia-dev/pepperboard/releases/tag/v2.4', + download_url='https://github.com/webedia-dev/pepperboard/releases/tag/v3.0', license='Apache', author='Cyril LAVIER', author_email='cyril.lavier@webedia-group.com', @@ -22,9 +22,9 @@ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: System Administrators', 'Natural Language :: English', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', 'License :: OSI Approved :: Apache Software License', 'Topic :: System :: Monitoring', ], -) \ No newline at end of file +)