summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c581e4)
raw | patch | inline | side by side (parent: 6c581e4)
author | Sven Velt <sven@velt.de> | |
Wed, 16 Dec 2009 16:35:45 +0000 (17:35 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Wed, 16 Dec 2009 16:35:45 +0000 (17:35 +0100) |
2.4: Only "md5" available
2.5: "md5" and "hashlib" work
2.6: Only "hashlib"
So try to "from hashlib import md5" and if it doesn't work just do a
"from md5 import md5" and just use "md5(___).hexdigest()" in the code.
2.5: "md5" and "hashlib" work
2.6: Only "hashlib"
So try to "from hashlib import md5" and if it doesn't work just do a
"from md5 import md5" and just use "md5(___).hexdigest()" in the code.
nagixsc_conf2http.py | patch | blob | history | |
nagixsc_http2nagios.py | patch | blob | history |
diff --git a/nagixsc_conf2http.py b/nagixsc_conf2http.py
index d5200e09e34102b91729145eeebb8d4988827a23..995fa453f85e288958390823fbda4a2be7883c41 100755 (executable)
--- a/nagixsc_conf2http.py
+++ b/nagixsc_conf2http.py
import BaseHTTPServer
import base64
-import md5
import os
import re
import subprocess
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
config = { 'ip': '',
'port': 15666,
}
class Conf2HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
- def http_error(code, output):
+ def http_error(self, code, output):
self.send_response(code)
self.send_header('Content-Type', 'text/plain')
self.end_headers()
# Check Basic Auth
try:
authdata = base64.b64decode(self.headers['Authorization'].split(' ')[1]).split(':')
- if not users[authdata[0]] == md5.md5(authdata[1]).hexdigest():
+ if not users[authdata[0]] == md5(authdata[1]).hexdigest():
raise Exception
except:
self.send_response(401)
configfile =''
if re.search('\.\.', configfile):
- http_error(500, 'Found ".." in config file name')
+ self.http_error(500, 'Found ".." in config file name')
return
if configfile and not re.search('^[a-zA-Z0-9-_\.]+$', configfile):
- http_error(500, 'Config file name contains invalid characters')
+ self.http_error(500, 'Config file name contains invalid characters')
return
if configfile:
output = cmd.communicate()[0].rstrip()
retcode = cmd.returncode
except OSError:
- http_error(500, 'Could not execute "%s"' % cmdline)
+ self.http_error(500, 'Could not execute "%s"' % cmdline)
return
if retcode == 0:
self.end_headers()
self.wfile.write(output)
else:
- http_error(500, output)
+ self.http_error(500, output)
return
diff --git a/nagixsc_http2nagios.py b/nagixsc_http2nagios.py
index 034213885c9e48bcbab4436aa7552b65bf0e7e8c..e0a639b3218cd6595624b13cbe46fb358ddf4052 100755 (executable)
--- a/nagixsc_http2nagios.py
+++ b/nagixsc_http2nagios.py
import BaseHTTPServer
import base64
import cgi
-import md5
import os
import re
import subprocess
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
config = { 'ip': '',
'port': 15667,
}
class HTTP2NagiosHandler(BaseHTTPServer.BaseHTTPRequestHandler):
- def http_error(code, output):
+ def http_error(self, code, output):
self.send_response(code)
self.send_header('Content-Type', 'text/plain')
self.end_headers()
# Check Basic Auth
try:
authdata = base64.b64decode(self.headers['Authorization'].split(' ')[1]).split(':')
- if not users[authdata[0]] == md5.md5(authdata[1]).hexdigest():
+ if not users[authdata[0]] == md5(authdata[1]).hexdigest():
raise Exception
except:
self.send_response(401)