change directory into main-dev-dir

This commit is contained in:
Schrolli 2015-05-20 13:29:16 +02:00
parent 1cfb705ad5
commit 76ec264046
19 changed files with 196 additions and 717 deletions

57
plugins/BosMon/BosMon.py Normal file
View file

@ -0,0 +1,57 @@
#!/usr/bin/python
# -*- 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
def run(typ,freq,data):
try:
#ConfigParser
logging.debug("reading config file")
try:
config = dict(globals.config.items("BosMon"))
for key,val in config.items():
logging.debug(" - %s = %s", key, val)
except:
logging.exception("cannot read config file")
if typ == "FMS":
logging.warning("FMS not implemented")
elif typ == "ZVEI":
logging.warning("ZVEI not implemented")
elif typ == "POC":
logging.debug("Start POC to BosMon")
try:
#Defined data structure:
# data["ric"]
# data["function"]
# data["msg"]
#BosMon-Telegramin expected "a-d" as RIC-sub/function
data["function"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["function"], 'message':data["msg"]})
logging.debug(" - Params: %s", params)
headers = {}
headers['Content-type'] = "application/x-www-form-urlencoded"
headers['Accept'] = "text/plain"
if bosmon_user:
headers['Authorization'] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(config["bosmon_user"], config["bosmon_password"])))
httprequest = httplib.HTTPConnection(config["bosmon_server"], config["bosmon_port"])
httprequest.request("POST", "/telegramin/"+bosmon_channel+"/input.xml", params, headers)
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))
else:
logging.warning("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason))
except:
logging.error("POC to BosMon failed")
else:
logging.warning("undefined typ '%s'", typ)
except:
logging.exception("")

31
plugins/MySQL/MySQL.py Normal file
View file

@ -0,0 +1,31 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
def run(typ,freq,data):
try:
#ConfigParser
logging.debug("reading config file")
try:
config = dict(globals.config.items("MySQL"))
for key,val in config.items():
logging.debug(" - %s = %s", key, val)
except:
logging.exception("cannot read config file")
if typ == "FMS":
#logging.debug("FMS: %s Status: %s Dir: %s", data["fms"], data["status"], data["direction"])
logging.debug("FMS")
elif typ == "ZVEI":
#logging.debug("ZVEI: %s", data["zvei"])
logging.debug("ZVEI")
elif typ == "POC":
#logging.debug("POC: %s/%s - %s", data["ric"], data["function"], data["msg"])
logging.debug("POC")
else:
logging.warning(typ + " not supportet")
except:
logging.exception("unknown error")

31
plugins/interface.txt Normal file
View file

@ -0,0 +1,31 @@
Übergabe an Plugin:
typ = [FMS|ZVEI|POC]
freq = [FREQ(Hz)]
data = {"KEY1":"VALUE1","KEY2":"VALUE2"} als Python Dict
Follgende Daten sind bei der jeweiligen Alarm-Art enthalten:
ZVEI:
- zvei
FMS:
- fms
- status
- direction
- tki
POCSAG:
- ric
- function
- msg
Es stehen folgende globale Objecte zur Verfügung:
1.) import logging # Global logger
logging - Object
2.) import globals # Global variables
config - Object (typ: ConfigParser, stellt config.ini bereit)

9
plugins/none/none.py Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
def run(typ,freq,data):
logging.info("Nothing to do")

9
plugins/not/not.py Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
def run(typ,freq,data):
logging.info("Nothing to do")

View file

@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
def run(typ,freq,data):
try:
#ConfigParser
#config Data in config["OPTION"]
logging.debug("reading config file")
try:
config = dict(globals.config.items("template"))
for key,val in config.items():
logging.debug(" - %s = %s", key, val)
except:
logging.exception("cannot read config file")
if typ == "FMS":
logging.debug("FMS: %s Status: %s Dir: %s TKI: %s", data["fms"], data["status"], data["direction"], data["tki"])
elif typ == "ZVEI":
logging.debug("ZVEI: %s", data["zvei"])
elif typ == "POC":
logging.debug("POC: %s-%s - %s", data["ric"], data["function"], data["msg"])
else:
logging.warning(typ + " not supportet")
except:
logging.exception("unknown error")