Exemplo n.º 1
0
    def setUp(self):
        global_data = GlobalData()

        # Initialize logging.
        logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                            datefmt='%m/%d/%Y %H:%M:%S',
                            level=logging.WARNING)
        global_data.logger = logging.getLogger("graph")

        # Open database.
        db_location = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "database.db")
        global_data.storage = Sqlite(db_location, global_data, read_only=True)

        # Read necessary configurations.
        config_location = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "config.xml")
        configRoot = xml.etree.ElementTree.parse(config_location).getroot()
        configure_profiles(configRoot, global_data)
        configure_alert_levels(configRoot, global_data)

        self.alert_levels = {}
        for alert_level in global_data.alertLevels:
            self.alert_levels[alert_level.level] = alert_level
        self.nodes, self.alerts, self.sensors = get_objects_from_db(
            global_data)
Exemplo n.º 2
0
        # Shutdown has to be done via another thread. Otherwise a
        # deadlock will occur.
        _thread.start_new_thread(shutdown_server, (server, ))
        _thread.start_new_thread(shutdown_server, (unixserver, ))

    if db_cleaner:
        db_cleaner.shutdown()


if __name__ == "__main__":

    # Register sigterm handler to gracefully shutdown the server.
    signal.signal(signal.SIGTERM, sigterm_handler)

    # Generate object of the global needed data.
    global_data = GlobalData()

    file_name = os.path.basename(__file__)

    # Parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            global_data.config_file).getroot()

        global_data.logdir = make_path(
            str(configRoot.find("general").find("log").attrib["dir"]))

        # parse chosen log level
        temp_loglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 3
0
from lib import ServerCommunication, ConnectionWatchdog, Receiver
from lib import SMTPAlert
from lib import ScreenUpdater
from lib import Console
from lib import UpdateChecker
from lib import GlobalData
import logging
import time
import socket
import random
import xml.etree.ElementTree

if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = str(configRoot.find("general").find("log").attrib["file"])

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
Exemplo n.º 4
0
                      "--force",
                      dest="force",
                      action="store_true",
                      help="Do not check the version. Just update all files.",
                      default=False)
    (options, args) = parser.parse_args()

    if options.update is False:
        print "Use --help to get all available options."
        sys.exit(0)

    protocolUpdate = False
    configUpdate = False

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)
    instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

    try:
        # parse config file
        configRoot = xml.etree.ElementTree.parse(
            instanceLocation + "/config/config.xml").getroot()

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
        if tempLoglevel == "DEBUG":
            loglevel = logging.DEBUG
Exemplo n.º 5
0
	elif ruleElement.type == "second":

		logString = ("%s second " % spaceString
			+ "(start=%d, " % ruleElement.element.start
			+ "end=%d)") % ruleElement.element.end
		logging.info("[%s]: %s" % (fileName, logString))

	else:
		raise ValueError("Rule has invalid type: '%s'." % ruleElement.type)


if __name__ == '__main__':

	# generate object of the global needed data
	globalData = GlobalData()

	fileName = os.path.basename(__file__)

	# parse config file, get logfile configurations
	# and initialize logging
	try:
		configRoot = xml.etree.ElementTree.parse(
			globalData.configFile).getroot()

		logfile = str(configRoot.find("general").find("log").attrib["file"])

		# parse chosen log level
		tempLoglevel = str(
			configRoot.find("general").find("log").attrib["level"])
		tempLoglevel = tempLoglevel.upper()
Exemplo n.º 6
0
# Function creates a path location for the given user input.
def makePath(inputLocation):
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 7
0
# twitter: https://twitter.com/sqall01
# blog: https://h4des.org
# github: https://github.com/sqall01
#
# Licensed under the GNU Affero General Public License, version 3.

from lib import GlobalData
import xml.etree.ElementTree
import MySQLdb
import bcrypt
import sys

new_username = "******"
new_password = "******"

global_data = GlobalData()

try:
    configRoot = xml.etree.ElementTree.parse(global_data.config_file).getroot()

    global_data.mysql_host = str(
        configRoot.find("storage").find("mysql").attrib["server"])
    global_data.mysql_port = int(
        configRoot.find("storage").find("mysql").attrib["port"])
    global_data.mysql_database = str(
        configRoot.find("storage").find("mysql").attrib["database"])
    global_data.mysql_username = str(
        configRoot.find("storage").find("mysql").attrib["username"])
    global_data.mysql_password = str(
        configRoot.find("storage").find("mysql").attrib["password"])
Exemplo n.º 8
0
# Function creates a path location for the given user input.
def makePath(inputLocation):
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 9
0
	elif ruleElement.type == "second":

		logString = ("%s second " % spaceString
			+ "(start=%d, " % ruleElement.element.start
			+ "end=%d)") % ruleElement.element.end
		logging.info("[%s]: %s" % (fileName, logString))

	else:
		raise ValueError("Rule has invalid type: '%s'." % ruleElement.type)


if __name__ == '__main__':

	# generate object of the global needed data
	globalData = GlobalData()

	fileName = os.path.basename(__file__)

	# parse config file, get logfile configurations
	# and initialize logging
	try:
		configRoot = xml.etree.ElementTree.parse(
			globalData.configFile).getroot()

		globalData.logdir = makePath(str(configRoot.find("general").find(
			"log").attrib["dir"]))

		# parse chosen log level
		tempLoglevel = str(
			configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 10
0
            + "(Optional)",
        default=False)
    parser.add_option_group(optGroup)

    (options, args) = parser.parse_args()

    showHelp = (options.add
        or options.delete
        or options.modify
        or options.list)
    if showHelp is False:
        print("Use --help to get all available options.")
        sys.exit(0)

    # Generate object of the global needed data.
    globalData = GlobalData()

    fileName = os.path.basename(__file__)
    instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

    validNodeTypes = ["sensor", "manager", "alert"]

    # Parse config file.
    try:
        configRoot = xml.etree.ElementTree.parse(instanceLocation +
                "/config/config.xml").getroot()

        # Parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
Exemplo n.º 11
0
        action="store_true",
        help=
        "Do not ask me for confirmation. I know what I am doing. (Optional)",
        default=False)
    parser.add_option_group(optGroup)

    (options, args) = parser.parse_args()

    showHelp = (options.add or options.delete or options.modify
                or options.list)
    if showHelp is False:
        print("Use --help to get all available options.")
        sys.exit(0)

    # Generate object of the global needed data.
    globalData = GlobalData()

    fileName = os.path.basename(__file__)
    instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

    validNodeTypes = ["sensor", "manager", "alert"]

    # Parse config file.
    try:
        configRoot = xml.etree.ElementTree.parse(
            instanceLocation + "/config/config.xml").getroot()

        # Parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
Exemplo n.º 12
0
from lib import Mysql
from lib import SMTPAlert
from lib import UpdateChecker
from lib import GlobalData
import logging
import time
import socket
import random
import threading
import stat
import xml.etree.ElementTree

if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = str(configRoot.find("general").find("log").attrib["file"])

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
Exemplo n.º 13
0
		default=False)
	parser.add_option("-f", "--force", dest="force", action="store_true",
		help="Do not check the version. Just update all files.",
		default=False)
	(options, args) = parser.parse_args()

	if options.update is False:
		print "Use --help to get all available options."
		sys.exit(0)


	protocolUpdate = False
	configUpdate = False

	# generate object of the global needed data
	globalData = GlobalData()

	fileName = os.path.basename(__file__)
	instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

	try:
		# parse config file
		configRoot = xml.etree.ElementTree.parse(instanceLocation +
			"/config/config.xml").getroot()

		# parse chosen log level
		tempLoglevel = str(
			configRoot.find("general").find("log").attrib["level"])
		tempLoglevel = tempLoglevel.upper()
		if tempLoglevel == "DEBUG":
			loglevel = logging.DEBUG
Exemplo n.º 14
0
        "--force",
        dest="force",
        action="store_true",
        help="Do not check the version or dependencies. Just update all files.",
        default=False)
    (options, args) = parser.parse_args()

    if options.update is False:
        print "Use --help to get all available options."
        sys.exit(0)

    protocolUpdate = False
    configUpdate = False

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)
    instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

    try:
        # parse config file
        configRoot = xml.etree.ElementTree.parse(
            instanceLocation + "/config/config.xml").getroot()

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
        if tempLoglevel == "DEBUG":
            loglevel = logging.DEBUG
Exemplo n.º 15
0
from lib import SMTPAlert
from lib import ScreenUpdater
from lib import Console
from lib import UpdateChecker
from lib import GlobalData
import logging
import time
import socket
import random
import xml.etree.ElementTree


if __name__ == '__main__':

	# generate object of the global needed data
	globalData = GlobalData()

	fileName = os.path.basename(__file__)

	# parse config file, get logfile configurations
	# and initialize logging
	try:
		configRoot = xml.etree.ElementTree.parse(
			globalData.configFile).getroot()

		logfile = str(configRoot.find("general").find("log").attrib["file"])

		# parse chosen log level
		tempLoglevel = str(
			configRoot.find("general").find("log").attrib["level"])
		tempLoglevel = tempLoglevel.upper()
Exemplo n.º 16
0
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    print(asciiLogo)

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 17
0
	elif ruleElement.type == "second":

		logString = ("%s second " % spaceString
			+ "(start=%d, " % ruleElement.element.start
			+ "end=%d)") % ruleElement.element.end
		logging.info("[%s]: %s" % (fileName, logString))

	else:
		raise ValueError("Rule has invalid type: '%s'." % ruleElement.type)


if __name__ == '__main__':

	# generate object of the global needed data
	globalData = GlobalData()

	fileName = os.path.basename(__file__)

	# parse config file, get logfile configurations
	# and initialize logging
	try:
		configRoot = xml.etree.ElementTree.parse(
			globalData.configFile).getroot()

		globalData.logdir = makePath(str(configRoot.find("general").find(
			"log").attrib["dir"]))

		# parse chosen log level
		tempLoglevel = str(
			configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 18
0
            pos = i
            break
        if pos == -1:
            return os.environ["HOME"]
        return os.path.join(os.environ["HOME"], input_location[pos:])
    # Assume we have a given relative path.
    return os.path.join(os.path.dirname(os.path.abspath(__file__)),
                        input_location)


if __name__ == '__main__':

    print(asciiLogo)

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = make_path(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 19
0
# Function creates a path location for the given user input.
def makePath(inputLocation):
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 20
0
# Function creates a path location for the given user input.
def makePath(inputLocation):
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 21
0
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    fileName = os.path.basename(__file__)
    instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

    # generate object of the global needed data
    globalData = GlobalData()

    try:
        # parse config file
        configRoot = xml.etree.ElementTree.parse(
            instanceLocation + "/config/config.xml").getroot()

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
        if tempLoglevel == "DEBUG":
            loglevel = logging.DEBUG
        elif tempLoglevel == "INFO":
            loglevel = logging.INFO
        elif tempLoglevel == "WARNING":
Exemplo n.º 22
0
# Function creates a path location for the given user input.
def makePath(inputLocation):
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 23
0
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    print(asciiLogo)

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 24
0
# Function creates a path location for the given user input.
def makePath(inputLocation):
    # Do nothing if the given location is an absolute path.
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = makePath(
            str(configRoot.find("general").find("log").attrib["file"]))

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
Exemplo n.º 25
0
from lib import ServerSession, ThreadedTCPServer
from lib import VersionInformerSensor
from lib import SensorAlertExecuter
from lib import ManagerUpdateExecuter
from lib import OptionExecuter
from lib import GlobalData
from lib import SurveyExecuter
from lib import parse_config
import time
import threading
import random

if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # Parse config.
    if not parse_config(globalData):
        sys.exit(1)

    globalData.logger.info("[%s]: Parsing configuration succeeded." % fileName)

    random.seed()

    # start the thread that handles all sensor alerts
    globalData.logger.info("[%s] Starting sensor alert manage thread." %
                           fileName)
    globalData.sensorAlertExecuter = SensorAlertExecuter(globalData)
Exemplo n.º 26
0
from lib import ServerCommunication, ConnectionWatchdog
from lib import SMTPAlert
from lib import LightningmapSensor, LightningmapDataCollector, SensorExecuter
from lib import UpdateChecker
from lib import GlobalData
import logging
import time
import socket
import random
import xml.etree.ElementTree


if __name__ == '__main__':

	# generate object of the global needed data
	globalData = GlobalData()

	fileName = os.path.basename(__file__)

	# parse config file, get logfile configurations
	# and initialize logging
	try:
		configRoot = xml.etree.ElementTree.parse(
			globalData.configFile).getroot()

		logfile = str(configRoot.find("general").find("log").attrib["file"])

		# parse chosen log level
		tempLoglevel = str(
			configRoot.find("general").find("log").attrib["level"])
		tempLoglevel = tempLoglevel.upper()
Exemplo n.º 27
0
    target_format = "raw"
    if do_png:
        target_format = "png"
        if target_location[-4:] != ".png":
            target_location += ".png"
    else:
        if target_location[-4:] != ".dot":
            target_location += ".dot"
    try:
        with open(target_location, 'w') as fp:
            pass
    except Exception:
        print("Not able to write '%s'." % target_location)
        sys.exit(1)

    global_data = GlobalData()

    # Initialize logging.
    logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                        datefmt='%m/%d/%Y %H:%M:%S',
                        level=logging.WARNING)
    global_data.logger = logging.getLogger("graph")

    global_data.storage = Sqlite(global_data.storageBackendSqliteFile,
                                 global_data,
                                 read_only=True)

    # Read necessary configurations.
    configRoot = xml.etree.ElementTree.parse(global_data.configFile).getroot()
    configure_alert_levels(configRoot, global_data)
Exemplo n.º 28
0
import os
from lib import ServerCommunication, ConnectionWatchdog
from lib import SMTPAlert
from lib import LightningmapSensor, LightningmapDataCollector, SensorExecuter
from lib import UpdateChecker
from lib import GlobalData
import logging
import time
import socket
import random
import xml.etree.ElementTree

if __name__ == '__main__':

    # generate object of the global needed data
    globalData = GlobalData()

    fileName = os.path.basename(__file__)

    # parse config file, get logfile configurations
    # and initialize logging
    try:
        configRoot = xml.etree.ElementTree.parse(
            globalData.configFile).getroot()

        logfile = str(configRoot.find("general").find("log").attrib["file"])

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
Exemplo n.º 29
0
    if inputLocation[0] == "/":
        return inputLocation
    # Replace ~ with the home directory.
    elif inputLocation[0] == "~":
        return os.environ["HOME"] + inputLocation[1:]
    # Assume we have a given relative path.
    return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation


if __name__ == '__main__':

    fileName = os.path.basename(__file__)
    instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"

    # generate object of the global needed data
    globalData = GlobalData()

    try:
        # parse config file
        configRoot = xml.etree.ElementTree.parse(instanceLocation +
            "/config/config.xml").getroot()

        # parse chosen log level
        tempLoglevel = str(
            configRoot.find("general").find("log").attrib["level"])
        tempLoglevel = tempLoglevel.upper()
        if tempLoglevel == "DEBUG":
            loglevel = logging.DEBUG
        elif tempLoglevel == "INFO":
            loglevel = logging.INFO
        elif tempLoglevel == "WARNING":