Skip to content

Commit

Permalink
Merge 91991ad into 2dae40f
Browse files Browse the repository at this point in the history
  • Loading branch information
geektophe committed Jul 25, 2022
2 parents 2dae40f + 91991ad commit 19cec66
Show file tree
Hide file tree
Showing 386 changed files with 4,392 additions and 3,510 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Expand Up @@ -9,6 +9,12 @@ cache: pip

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"

# command to install dependencies
# some are only used for travis/coveralls so we are installing them here only
Expand All @@ -28,9 +34,14 @@ env:
- TEST_SUITE=UBUNTU

before_install:
- sudo apt-get -y install python-setuptools
- sudo apt-get -y install python3-setuptools
- sudo apt-get -y install python-pycurl
- sudo apt-get -y install python3-pycurl
- sudo apt-get -y install python-nose
- sudo apt-get -y install python3-nose
- sudo apt-get -y install python-pip
- sudo apt-get -y install python3-pip
- sudo apt-get -y install libgnutls-dev
addons:
apt:
Expand Down
1 change: 1 addition & 0 deletions bin/shinken-arbiter
Expand Up @@ -29,6 +29,7 @@ For example, if a scheduler dies, it sends the late scheduler's conf
to another scheduler available.
It also reads orders form users (nagios.cmd) and sends them to schedulers.
"""
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys
Expand Down
1 change: 1 addition & 0 deletions bin/shinken-broker
Expand Up @@ -32,6 +32,7 @@
In case the arbiter has a new conf to send, the broker forget its old
schedulers (and their associated broks) and take the new ones instead.
'''
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys
Expand Down
1 change: 1 addition & 0 deletions bin/shinken-poller
Expand Up @@ -32,6 +32,7 @@
In case the arbiter has a new conf to send, the poller forget its old
schedulers (and the associated checks) and take the new ones instead.
'''
from __future__ import absolute_import, division, print_function, unicode_literals

import sys
import os
Expand Down
1 change: 1 addition & 0 deletions bin/shinken-reactionner
Expand Up @@ -33,6 +33,7 @@
In case the arbiter has a new conf to send, the reactionner forget its old
schedulers (and the associated actions) and take the new ones instead.
'''
from __future__ import absolute_import, division, print_function, unicode_literals

import sys
import os
Expand Down
1 change: 1 addition & 0 deletions bin/shinken-receiver
Expand Up @@ -32,6 +32,7 @@
In case the arbiter has a new conf to send, the receiver forget its old
schedulers (and their associated broks) and take the new ones instead.
'''
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys
Expand Down
2 changes: 2 additions & 0 deletions bin/shinken-scheduler
Expand Up @@ -63,6 +63,8 @@
In case the arbiter has a new conf to send, the scheduler is stopped
and a new one is created.
'''
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys
import optparse
Expand Down
9 changes: 4 additions & 5 deletions cli/desc/cli.py
Expand Up @@ -21,17 +21,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function, unicode_literals

import os

from shinken.objects import Host
from shinken.log import logger

# Will be populated by the shinken CLI command
CONFIG = None



############# ******************** SERVE ****************###########
def serve(port):
port = int(port)
Expand All @@ -47,7 +46,7 @@ def serve(port):
httpd.serve_forever()
except KeyboardInterrupt:
pass
except Exception, exp:
except Exception as exp:
logger.error(exp)

def do_desc(cls='host'):
Expand All @@ -57,9 +56,9 @@ def do_desc(cls='host'):
for k in prop_names:
v = properties[k]
if v.has_default:
print k, '(%s)' % v.default
print(k, '(%s)' % v.default)
else:
print k
print(k)



Expand Down
7 changes: 3 additions & 4 deletions cli/doc/cli.py
Expand Up @@ -21,16 +21,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function, unicode_literals

import os

from shinken.log import logger

# Will be populated by the shinken CLI command
CONFIG = None



############# ******************** SERVE ****************###########
def serve(port):
port = int(port)
Expand All @@ -46,7 +45,7 @@ def serve(port):
httpd.serve_forever()
except KeyboardInterrupt:
pass
except Exception, exp:
except Exception as exp:
logger.error(exp)

def do_serve(port='8080'):
Expand Down Expand Up @@ -74,7 +73,7 @@ def _compile():
s = 'sphinx-build -b html -d %s %s %s' % (doctrees_dir, source_dir, html_dir)
args = s.split(' ')
main(args)
except Exception, exp:
except Exception as exp:
logger.error(exp)
return

Expand Down
30 changes: 15 additions & 15 deletions cli/shinkenio/cli.py
Expand Up @@ -21,6 +21,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function, unicode_literals

import pycurl
import os
Expand All @@ -38,7 +39,6 @@
CONFIG = None



############# ******************** PUBLISH ****************###########

def read_package_json(fd):
Expand All @@ -47,7 +47,7 @@ def read_package_json(fd):
buf = buf.decode('utf8', 'ignore')
try:
package_json = json.loads(buf)
except ValueError, exp:
except ValueError as exp:
logger.error("Bad package.json file : %s", exp)
sys.exit(2)
if not package_json:
Expand Down Expand Up @@ -125,7 +125,7 @@ def publish_archive(archive):
c.setopt(c.VERBOSE, 1)
try:
c.perform()
except pycurl.error, exp:
except pycurl.error as exp:
logger.error("There was a critical error : %s", exp)
sys.exit(2)
return
Expand Down Expand Up @@ -177,7 +177,7 @@ def search(look_at):
#c.setopt(c.VERBOSE, 1)
try:
c.perform()
except pycurl.error, exp:
except pycurl.error as exp:
logger.error("There was a critical error : %s", exp)
return

Expand Down Expand Up @@ -207,11 +207,11 @@ def print_search_matches(matches):
names = [p['name'] for p in matches]
names = list(set(names))
names.sort()

for p in matches:
name = p['name']
ps[name] = p

for name in names:
p = ps[name]
user_id = p['user_id']
Expand All @@ -224,7 +224,7 @@ def print_search_matches(matches):


def do_search(*look_at):
# test for generic search
# test for generic search
if look_at == ('all',):
matches = []
look_at = ('pack',)
Expand All @@ -250,11 +250,11 @@ def inventor(look_at):
inventory = CONFIG['paths']['inventory']
logger.debug("dumping inventory %s", inventory)
# get all sub-direcotries

for d in os.listdir(inventory):
if os.path.exists(os.path.join(inventory, d, 'package.json')):
if not look_at or d in look_at:
print d
print(d)
# If asked, dump the content.package content
if look_at or d in look_at:
content_p = os.path.join(inventory, d, 'content.json')
Expand All @@ -263,7 +263,7 @@ def inventor(look_at):
continue
try:
j = json.loads(open(content_p, 'r').read())
except Exception, exp:
except Exception as exp:
logger.error('Bad %s file "%s"', content_p, exp)
continue
for d in j:
Expand All @@ -273,7 +273,7 @@ def inventor(look_at):
else:
s += '(f)'
s += d['name']
print s
print(s)


def do_inventory(*look_at):
Expand Down Expand Up @@ -338,7 +338,7 @@ def grab_package(pname):
#c.setopt(c.VERBOSE, 1)
try:
c.perform()
except pycurl.error, exp:
except pycurl.error as exp:
logger.error("There was a critical error : %s", exp)
sys.exit(2)
return ''
Expand Down Expand Up @@ -499,7 +499,7 @@ def install_package(pname, raw, update_only=False):
shutil.copytree(p_doc, doc_dest)
logger.info("Copy done in the doc directory %s", doc_dest)


if not update_only:
# Now install the pack from $TMP$/pack/* to $PACKS$/pname/*
p_pack = os.path.join(tmpdir, 'pack')
Expand Down Expand Up @@ -554,7 +554,7 @@ def install_package(pname, raw, update_only=False):
cont = open(os.path.join(p_inv, 'content.json'), 'w')
cont.write(json.dumps(package_content))
cont.close()

# We now clean (rm) the tmpdir we don't need any more
try:
shutil.rmtree(tmpdir, ignore_errors=True)
Expand Down Expand Up @@ -588,7 +588,7 @@ def do_install(pname='', local=False, download_only=False):
f.write(raw)
f.close()
cprint('Download OK: %s' % tmpf, 'green')
except Exception, exp:
except Exception as exp:
logger.error("Package save fail: %s", exp)
sys.exit(2)
return
Expand Down
11 changes: 7 additions & 4 deletions contrib/clients/TSCA/python/PythonClient.py
Expand Up @@ -18,6 +18,9 @@
# specific language governing permissions and limitations
# under the License.
#

from __future__ import absolute_import, division, print_function, unicode_literals

import csv
import time
import sys
Expand All @@ -27,8 +30,8 @@
from org.shinken_monitoring.tsca import StateService
from org.shinken_monitoring.tsca.ttypes import *
except:
print "Can't import tsca stub."
print "Have you run thrift --gen py ../../../../shinken/modules/tsca/tsca.thrift ?"
print("Can't import tsca stub.")
print("Have you run thrift --gen py ../../../../shinken/modules/tsca/tsca.thrift ?")
sys.exit(1)

from thrift import Thrift
Expand Down Expand Up @@ -77,5 +80,5 @@
# Close!
transport.close()

except Thrift.TException, tx:
print '%s' % tx.message
except Thrift.TException as tx:
print('%s' % tx.message)
5 changes: 4 additions & 1 deletion contrib/clients/zmq_client/zmq_broker_client.py
Expand Up @@ -33,6 +33,9 @@
# python zmq_broker_client.py "json" "tcp://127.0.0.1:12345" "host"
# python zmq_broker_client.py "msgpack" "ipc:///tmp/shinken_pub" ""
# python zmq_broker_client.py "json" "tcp://172.23.2.189:9067" "log"

from __future__ import absolute_import, division, print_function, unicode_literals

import zmq
import sys

Expand Down Expand Up @@ -63,7 +66,7 @@
topic = ""
if len(sys.argv) > 3:
topic = sys.argv[3]

# Subscribe
context = zmq.Context()
s_sub = context.socket(zmq.SUB)
Expand Down
6 changes: 4 additions & 2 deletions contrib/install.d/tools/checkmodule.py
Expand Up @@ -20,6 +20,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function, unicode_literals

import sys
import getopt

Expand All @@ -32,9 +34,9 @@ def main(argv):
if o == "-m":
try:
exec("import " + a)
print "OK"
print("OK")
except Exception:
print "KO"
print("KO")
ret = 2
except Exception:
ret = 1
Expand Down
4 changes: 3 additions & 1 deletion contrib/livestatus/splitlivelogs.py
Expand Up @@ -23,6 +23,8 @@
split up the contents in single datafiles (1 for each day of data found).
"""

from __future__ import absolute_import, division, print_function, unicode_literals

import sys
import optparse
import os
Expand Down Expand Up @@ -66,7 +68,7 @@
dbh.log_db_do_archive()
dbh.close()
else:
print "database %s does not exist" % opts.database
print("database %s does not exist" % opts.database)


# For perf tuning:

0 comments on commit 19cec66

Please sign in to comment.