mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-04 14:07:25 +00:00
(re-)structure code - use include-files now
- move gobals and other stuff to includes - extract code from boswatch.py to include-files bugfix in BosMon-plugin
This commit is contained in:
parent
c296af22b0
commit
e67a357d8e
15 changed files with 243 additions and 196 deletions
|
|
@ -2,12 +2,14 @@
|
|||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging # Global logger
|
||||
import globals # Global variables
|
||||
|
||||
import httplib #for the HTTP request
|
||||
import urllib #for the HTTP request with parameters
|
||||
import base64 #for the HTTP request with User/Password
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
|
||||
def run(typ,freq,data):
|
||||
try:
|
||||
#ConfigParser
|
||||
|
|
@ -38,9 +40,13 @@ def run(typ,freq,data):
|
|||
headers['Content-type'] = "application/x-www-form-urlencoded"
|
||||
headers['Accept'] = "text/plain"
|
||||
if globals.config.get("BosMon", "bosmon_user"):
|
||||
logging.debug(" Gesicherte Verbindung ")
|
||||
headers['Authorization'] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(globals.config.get("BosMon", "bosmon_user"), globals.config.get("BosMon", "bosmon_password"))))
|
||||
logging.debug(" Open HTTPConnection ")
|
||||
httprequest = httplib.HTTPConnection(globals.config.get("BosMon", "bosmon_server"), globals.config.get("BosMon", "bosmon_port"))
|
||||
httprequest.request("POST", "/telegramin/"+bosmon_channel+"/input.xml", params, headers)
|
||||
logging.debug(" Start Request ")
|
||||
httprequest.request("POST", "/telegramin/"+globals.config.get("BosMon", "bosmon_channel")+"/input.xml", params, headers)
|
||||
logging.debug(" Get Response: ")
|
||||
httpresponse = httprequest.getresponse()
|
||||
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
|
||||
logging.debug("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason))
|
||||
|
|
@ -53,4 +59,4 @@ def run(typ,freq,data):
|
|||
########## User Plugin CODE ##########
|
||||
|
||||
except:
|
||||
logging.exception("")
|
||||
logging.exception("")
|
||||
|
|
@ -2,10 +2,13 @@
|
|||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging # Global logger
|
||||
import globals # Global variables
|
||||
|
||||
import mysql
|
||||
import mysql.connector
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
|
||||
def run(typ,freq,data):
|
||||
try:
|
||||
#ConfigParser
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging # Global logger
|
||||
import globals # Global variables
|
||||
|
||||
#########
|
||||
# USAGE
|
||||
#
|
||||
|
|
@ -23,8 +20,12 @@ import globals # Global variables
|
|||
# usable Loglevels debug|info|warning|error|exception|critical
|
||||
# if you use .exception in Try:Exception: Construct, it logs the Python EX.message too
|
||||
|
||||
import logging # Global logger
|
||||
import httplib #for the HTTP request
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
|
||||
def run(typ,freq,data):
|
||||
try:
|
||||
#ConfigParser
|
||||
|
|
@ -68,4 +69,4 @@ def run(typ,freq,data):
|
|||
########## User Plugin CODE ##########
|
||||
|
||||
except:
|
||||
logging.exception("unknown error")
|
||||
logging.exception("unknown error")
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging # Global logger
|
||||
import globals # Global variables
|
||||
|
||||
#########
|
||||
# USAGE
|
||||
#
|
||||
|
|
@ -23,6 +20,11 @@ import globals # Global variables
|
|||
# usable Loglevels debug|info|warning|error|exception|critical
|
||||
# if you use .exception in Try:Exception: Construct, it logs the Python EX.message too
|
||||
|
||||
import logging # Global logger
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
|
||||
def run(typ,freq,data):
|
||||
try:
|
||||
#ConfigParser
|
||||
|
|
@ -45,4 +47,4 @@ def run(typ,freq,data):
|
|||
########## User Plugin CODE ##########
|
||||
|
||||
except:
|
||||
logging.exception("unknown error")
|
||||
logging.exception("unknown error")
|
||||
Loading…
Add table
Add a link
Reference in a new issue