python3 and simplify import
This commit is contained in:
64
data/diag.py
64
data/diag.py
@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
###########################################################################
|
||||
# Eole NG - 2009
|
||||
# Copyright Pole de Competence Eole (Ministere Education - Academie Dijon)
|
||||
# http://eole.orion.education.fr - eole@ac-dijon.fr
|
||||
#
|
||||
# Licence CeCill
|
||||
# cf: http://www.cecill.info/licences.fr.html
|
||||
###########################################################################
|
||||
|
||||
import sys
|
||||
import socket
|
||||
from os.path import isfile
|
||||
from os import system, stat
|
||||
from pyeole.httprequest import HTTPRequest
|
||||
from creole.config import configeol
|
||||
from creole.client import CreoleClient
|
||||
|
||||
client = CreoleClient()
|
||||
|
||||
# adresse IP et port du serveur d'enregistrement
|
||||
server = "http://194.167.18.21/apps/AutoDiag/index.n/diagnose"
|
||||
md5file = "/etc/eole/.server.MD5"
|
||||
module = "%s-%s" % (client.get_creole('eole_module'), client.get_creole('eole_version'))
|
||||
|
||||
def get_md5():
|
||||
""" calcul de l'identifiant md5 """
|
||||
if not isfile(md5file) or stat(md5file).st_size == 0:
|
||||
system("md5sum %s | awk '{print $1}' > %s" % (configeol, md5file))
|
||||
fp = file(md5file)
|
||||
return (fp.read().split()[0])
|
||||
|
||||
def get_proxy():
|
||||
""" récupération du proxy à utiliser """
|
||||
if client.get_creole('activer_proxy_client') == 'oui':
|
||||
return "http://{0}:{1}".format(
|
||||
client.get_creole('proxy_client_adresse'),
|
||||
client.get_creole('proxy_client_port'))
|
||||
return ''
|
||||
|
||||
if __name__ == "__main__":
|
||||
id5 = get_md5()
|
||||
rne = client.get_creole('numero_etab')
|
||||
data = {"ID5":id5, "module":module, "rne":rne, "dep":rne[0:3]}
|
||||
socket.setdefaulttimeout(5)
|
||||
proxy = get_proxy()
|
||||
if proxy != '':
|
||||
# essai avec proxy
|
||||
try:
|
||||
req = HTTPRequest(proxy={'http':proxy})
|
||||
req.request(server, post_datas=data)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
sys.exit(0)
|
||||
# essai sans proxy
|
||||
try:
|
||||
req = HTTPRequest()
|
||||
req.request(server, post_datas=data)
|
||||
except:
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.exit(0)
|
@ -1,2 +0,0 @@
|
||||
"""Module de fonctions supplémentaires accessibles à creole. Tous les fichiers python
|
||||
contenus dans ce répertoire sont lus par le module eosfunc de creole"""
|
@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
"""
|
||||
script de generation d'un certificat ssl
|
||||
prend un nom de fichier facultatif en argument (destination du certificat)
|
||||
|
||||
usage::
|
||||
|
||||
soit
|
||||
%prog (-fc) [nom_certif]
|
||||
soit
|
||||
%prog (-f)
|
||||
|
||||
si [nom_certif] non renseigne, regenere tous les certificats par defaut ainsi que la ca locale.
|
||||
Sinon, ne genere que [nom_certif]
|
||||
|
||||
-f :force la regeneration du (ou des) certificat(s) s'il(s) existe(nt)
|
||||
-c : dans le cas de la generation d'un seul certificat, on copie la clef
|
||||
|
||||
"""
|
||||
import sys, os
|
||||
from optparse import OptionParser
|
||||
|
||||
from creole import cert
|
||||
from pyeole.encode import normalize
|
||||
|
||||
def parse_command_line():
|
||||
parser = OptionParser(__doc__)
|
||||
parser.add_option("-c",
|
||||
action="store_true", dest="copy", default=False,
|
||||
help="copie de la clef")
|
||||
|
||||
parser.add_option("-f",
|
||||
action="store_true", dest="regen", default=False,
|
||||
help="force la regeneration de la clef")
|
||||
|
||||
options, args = parser.parse_args()
|
||||
if len(args) > 1:
|
||||
parser.error("Il faut au maximum un certificat")
|
||||
return options, args
|
||||
|
||||
options, args = parse_command_line()
|
||||
|
||||
regen = options.regen
|
||||
copy = options.copy
|
||||
|
||||
if len(args) == 1:
|
||||
certfile = args[0]
|
||||
else:
|
||||
certfile = None
|
||||
|
||||
try:
|
||||
cert.rehash_if_needed()
|
||||
if certfile != None:
|
||||
certfile = os.path.abspath(certfile)
|
||||
dest_dir = os.path.dirname(certfile)
|
||||
if not os.path.isdir(dest_dir):
|
||||
print "Répertoire de destination inexistant (%s)" % dest_dir
|
||||
sys.exit(1)
|
||||
print "Generation du certificat machine"
|
||||
cert.gen_certif(certfile, regen=regen, copy_key=copy)
|
||||
else:
|
||||
# génération de tous les certificats (CA, eole, scribe...)
|
||||
cert.gen_certs(regen=regen)
|
||||
sys.exit(0)
|
||||
except Exception, err:
|
||||
print "Erreur : "
|
||||
print u'{0}'.format(normalize(err))
|
||||
sys.exit(1)
|
@ -1,26 +0,0 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
"""
|
||||
Test des patches pour diagnose
|
||||
réutilisation du code de zephir-client
|
||||
"""
|
||||
import sys
|
||||
from glob import glob
|
||||
from os.path import basename
|
||||
from creole import utils
|
||||
from creole.config import patch_dir
|
||||
from zephir.monitor.agents import patches
|
||||
from os.path import join
|
||||
|
||||
patchs = glob(join(patch_dir, '*.patch'))
|
||||
patchs.extend(glob(join(patch_dir, 'variante', '*.patch')))
|
||||
err = []
|
||||
for patch in patchs:
|
||||
verif = patches.verify_patch(patch).values()
|
||||
if len(verif) > 0 and len(verif[0]) > 0:
|
||||
err.append(basename(patch))
|
||||
if len(err) != 0:
|
||||
utils.print_red('Erreur')
|
||||
print "fichiers : %s" % (", ".join(err),)
|
||||
else:
|
||||
utils.print_green('Ok')
|
Reference in New Issue
Block a user