Example #1
0
	def __init__(self, name, force_enable=False, **kwargs):
		ConfigReader.__init__(self, **kwargs)
		self.__name = name
		self.__filter = None
		self.__force_enable = force_enable
		self.__actions = list()
		self.__opts = None
Example #2
0
	def __init__(self, force_enable=False, **kwargs):
		"""
		Parameters
		----------
		force_enable : bool, optional
		  Passed to JailReader to force enable the jails.
		  It is for internal use
		"""
		ConfigReader.__init__(self, **kwargs)
		self.__jails = list()
		self.__force_enable = force_enable
Example #3
0
    def __readConfig(self):
        ''' Read the base config
        '''
        config_reader = ConfigReader(self.__log_config_url)
        config = config_reader.readConfig()
       
        self.__format = config.get("Output", "format", 1)
        self.__level = config.get("Level", "level")
        #self.__url = config.get("Url", "log_save_url")

        output_place_string = config.get("Output", "output_place")
        output_place_string.upper()
        self.__out_place = output_place_string.split(",")
        self.readConfigByFileType(config)
Example #4
0
def proceed_message(message_object):
    message_text = message_object['text']
    message_command = re.sub('^(.*?)[\\s@].*', '\\1', message_text, flags=re.S)
    if message_command[0] != '/' or message_command == '':
        raise ValueError
    message_command = message_command[1:]
    logger.info('Command: ' + message_command)
    config = ConfigReader(CONFIG_FILE_NAME)
    module_name = config.get_command_dict()[message_command]
    logger.info('Command found in config')
    module = getattr(__import__('modules.' + module_name), module_name)  # Black python magic
    logger.info('Module successfully imported')
    result = module.run(message_object)

    return result
Example #5
0
	def getOptions(self, section=None):
		"""Reads configuration for jail(s) and adds enabled jails to __jails
		"""
		opts = []
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)

		if section is None:
			sections = self.sections()
		else:
			sections = [ section ]

		# Get the options of all jails.
		parse_status = True
		for sec in sections:
			jail = JailReader(sec, basedir=self.getBaseDir(),
							  force_enable=self.__force_enable)
			jail.read()
			ret = jail.getOptions()
			if ret:
				if jail.isEnabled():
					# We only add enabled jails
					self.__jails.append(jail)
			else:
				logSys.error("Errors in jail %r. Skipping..." % sec)
				parse_status = False
		return parse_status
	def getOptions(self, section = None):
		opts = []
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)

		if section:
			# Get the options of a specific jail.
			jail = JailReader(section)
			jail.read()
			ret = jail.getOptions()
			if ret:
				if jail.isEnabled():
					# We only add enabled jails
					self.__jails.append(jail)
			else:
				logSys.error("Errors in jail '%s'. Skipping..." % section)
				return False
		else:
			# Get the options of all jails.
			for sec in self.sections():
				jail = JailReader(sec)
				jail.read()
				ret = jail.getOptions()
				if ret:
					if jail.isEnabled():
						# We only add enabled jails
						self.__jails.append(jail)
				else:
					logSys.error("Errors in jail '" + sec + "'. Skipping...")
					return False
		return True
Example #7
0
    def __init__(self, file, clientName, fileType):
        configreader = ConfigReader()
        config = configreader.readConfig()
        fileDelimiter = config.get(clientName, fileType + '.delimiter')
        self.fileTopOffset = int(config.get(clientName, fileType + '.topOffset'))
        self.fileLeftOffset = int(config.get(clientName, fileType + '.leftOffset'))

        try:
            with open(file, 'rb') as csvfile:
                file = csv.reader(csvfile.read().decode('utf-8-sig').encode('utf-8').splitlines(),
                                  delimiter=fileDelimiter, quotechar='"')
                self.data = []
                for line in file:
                    self.data.append(line)
        except Exception as error:
            exit(error)
Example #8
0
 def getOptions(self, pOpts):
     opts = [
         ["string", "timeregex", None],
         ["string", "timepattern", None],
         ["string", "ignoreregex", ""],
         ["string", "failregex", ""],
     ]
     self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
Example #9
0
    def __readConfig(self):
        ''' Read the base config
        '''
        config_reader = ConfigReader(self.__log_config_url)
        config = config_reader.readConfig()
       
        self.__format = config.get("Output", "format", raw=True)
        self.__level = config.get("Level", "level")
        self.__url = config.get("Url", "log_save_url")

        output_place_string = config.get("Output", "output_place")
        output_place_string.upper()
        self.__out_place = output_place_string.split(",")
        # if output_place=CONSOLE, FILE, ROTATINGFILE
        # then self.__out_place would be ['CONSOLE', ' FILE', ' ROTATINGFILE']
        # in this case, items in self.__out_place should be stripped of blank spaces
        self.__out_place = [output.strip() for output in self.__out_place]
        self.readConfigByFileType(config)
Example #10
0
	def getOptions(self, pOpts):
		opts = [["string", "actionstart", ""],
				["string", "actionstop", ""],
				["string", "actioncheck", ""],
				["string", "actionban", ""],
				["string", "actionunban", ""]]
		self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
		
		if self.has_section("Init"):
			for opt in self.options("Init"):
				if not self.__cInfo.has_key(opt):
					self.__cInfo[opt] = self.get("Init", opt)
Example #11
0
	def getOptions(self):
		opts = [["bool", "enabled", "false"],
				["string", "logpath", "/var/log/messages"],
				["string", "backend", "auto"],
				["int", "maxretry", 3],
				["int", "findtime", 600],
				["int", "bantime", 600],
				["string", "usedns", "warn"],
				["string", "failregex", None],
				["string", "ignoreregex", None],
				["string", "ignorecommand", None],
				["string", "ignoreip", None],
				["string", "filter", ""],
				["string", "action", ""]]
		self.__opts = ConfigReader.getOptions(self, self.__name, opts)
		if not self.__opts:
			return False
		
		if self.isEnabled():
			# Read filter
			if self.__opts["filter"]:
				self.__filter = FilterReader(self.__opts["filter"], self.__name,
											 basedir=self.getBaseDir())
				ret = self.__filter.read()
				if ret:
					self.__filter.getOptions(self.__opts)
				else:
					logSys.error("Unable to read the filter")
					return False
			else:
				self.__filter = None
				logSys.warn("No filter set for jail %s" % self.__name)
		
			# Read action
			for act in self.__opts["action"].split('\n'):
				try:
					if not act:			  # skip empty actions
						continue
					splitAct = JailReader.splitAction(act)
					action = ActionReader(splitAct, self.__name, basedir=self.getBaseDir())
					ret = action.read()
					if ret:
						action.getOptions(self.__opts)
						self.__actions.append(action)
					else:
						raise AttributeError("Unable to read action")
				except Exception, e:
					logSys.error("Error in action definition " + act)
					logSys.debug("Caught exception: %s" % (e,))
					return False
			if not len(self.__actions):
				logSys.warn("No actions were defined for %s" % self.__name)
Example #12
0
	def getOptions(self):
		opts = []
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)
		for sec in self.sections():
			jail = JailReader(sec)
			jail.read()
			ret = jail.getOptions()
			if ret:
				if jail.isEnabled():
					
					self.__jails.append(jail)
			else:
				logSys.error("Errors in jail '" + sec + "'. Skipping...")
				return False
		return True
Example #13
0
    def getOptions(self):
        opts = [["bool", "enabled", "false"],
                ["string", "logpath", "/var/log/messages"],
                ["string", "backend", "auto"], ["int", "maxretry", 3],
                ["int", "findtime", 600], ["int", "bantime", 600],
                ["string", "usedns", "warn"], ["string", "failregex", None],
                ["string", "ignoreregex", None], ["string", "ignoreip", None],
                ["string", "filter", ""], ["string", "action", ""]]
        self.__opts = ConfigReader.getOptions(self, self.__name, opts)

        if self.isEnabled():
            # Read filter
            self.__filter = FilterReader(self.__opts["filter"],
                                         self.__name,
                                         basedir=self.getBaseDir())
            ret = self.__filter.read()
            if ret:
                self.__filter.getOptions(self.__opts)
            else:
                logSys.error("Unable to read the filter")
                return False

            # Read action
            for act in self.__opts["action"].split('\n'):
                try:
                    if not act:  # skip empty actions
                        continue
                    splitAct = JailReader.splitAction(act)
                    action = ActionReader(splitAct,
                                          self.__name,
                                          basedir=self.getBaseDir())
                    ret = action.read()
                    if ret:
                        action.getOptions(self.__opts)
                        self.__actions.append(action)
                    else:
                        raise AttributeError("Unable to read action")
                except Exception, e:
                    logSys.error("Error in action definition " + act)
                    logSys.debug("Caught exception: %s" % (e, ))
                    return False
            if not len(self.__actions):
                logSys.warn("No actions were defined for %s" % self.__name)
Example #14
0
 def _load_configuration(self):
     """ Try and load configuration based on the predefined precendence """
     self.config_reader = ConfigReader(self._config_path)
     self.credentials_reader = CredentialsReader(
         self._get_credentials_path())
     self.metadata_reader = MetadataReader(self._metadata_server)
     self._load_credentials()
     self._load_region()
     self._load_hostname()
     self._load_proxy_server_name()
     self._load_proxy_server_port()
     self._set_endpoint()
     self._set_ec2_endpoint()
     self._load_autoscaling_group()
     self.debug = self.config_reader.debug
     self.pass_through = self.config_reader.pass_through
     self.push_asg = self.config_reader.push_asg
     self.push_constant = self.config_reader.push_constant
     self.constant_dimension_value = self.config_reader.constant_dimension_value
     self._check_configuration_integrity()
Example #15
0
	def getOptions(self):
		opts = [["bool", "enabled", "false"],
				["string", "logpath", "/var/log/messages"],
				["string", "backend", "auto"],
				["int", "maxretry", 3],
				["int", "findtime", 600],
				["int", "bantime", 600],
				["string", "usedns", "warn"],
				["string", "failregex", None],
				["string", "ignoreregex", None],
				["string", "ignoreip", None],
				["string", "filter", ""],
				["string", "action", ""]]
		self.__opts = ConfigReader.getOptions(self, self.__name, opts)
		
		if self.isEnabled():
			# Read filter
			self.__filter = FilterReader(self.__opts["filter"], self.__name,
										 basedir=self.getBaseDir())
			ret = self.__filter.read()
			if ret:
				self.__filter.getOptions(self.__opts)
			else:
				logSys.error("Unable to read the filter")
				return False
			
			# Read action
			for act in self.__opts["action"].split('\n'):
				try:
					splitAct = JailReader.splitAction(act)
					action = ActionReader(splitAct, self.__name, basedir=self.getBaseDir())
					ret = action.read()
					if ret:
						action.getOptions(self.__opts)
						self.__actions.append(action)
					else:
						raise AttributeError("Unable to read action")
				except Exception, e:
					logSys.error("Error in action definition " + act)
					logSys.debug(e)
					return False
Example #16
0
 def __init__(self, config_file):
     if path.exists(config_file) and path.isfile(config_file):
         conf = ConfigReader(config_file)
         self.output = conf.get("output")
         self.output_file = conf.get("output_file")
         self.level = conf.get("level")
         self.__log_levels = {
             "debug": 10,
             "info": 20,
             "warning": 30,
             "error": 40,
             "critical": 50,
         }
         self.message_format = conf.get("message_format")
         self.date_format = conf.get("date_format")
         self.formatter = Formatter(self.level, self.message_format,
                                    self.date_format)
     else:
         raise IOError("Can't find configuration file.")
Example #17
0
	def getOptions(self):
		opts = [["bool", "enabled", "false"],
				["string", "logpath", "/var/log/messages"],
				["string", "backend", "auto"],
				["int", "maxretry", 3],
				["int", "findtime", 600],
				["int", "bantime", 600],
				["string", "failregex", None],
				["string", "ignoreregex", None],
				["string", "ignoreip", None],
				["string", "filter", ""],
				["string", "action", ""]]
		self.__opts = ConfigReader.getOptions(self, self.__name, opts)
		
		if self.isEnabled():
			# Read filter
			self.__filter = FilterReader(self.__opts["filter"], self.__name)
			ret = self.__filter.read()
			if ret:
				self.__filter.getOptions(self.__opts)
			else:
				logSys.error("Unable to read the filter")
				return False
			
			# Read action
			for act in self.__opts["action"].split('\n'):
				try:
					splitAct = JailReader.splitAction(act)
					action = ActionReader(splitAct, self.__name)
					ret = action.read()
					if ret:
						action.getOptions(self.__opts)
						self.__actions.append(action)
					else:
						raise AttributeError("Unable to read action")
				except Exception, e:
					logSys.error("Error in action definition " + act)
					logSys.debug(e)
					return False
Example #18
0
 def __init__(self, config_file):
     if path.exists(config_file) and path.isfile(config_file):
         conf = ConfigReader(config_file)
         self.output = conf.get("output")
         self.output_file = conf.get("output_file")
         self.level = conf.get("level")
         self.__log_levels = {
             "debug": 10,
             "info": 20,
             "warning": 30,
             "error": 40,
             "critical": 50,
             }
         self.message_format = conf.get("message_format")
         self.date_format = conf.get("date_format")
         self.formatter = Formatter(
             self.level, self.message_format, self.date_format)
     else:
         raise IOError("Can't find configuration file.")
Example #19
0
	def setBaseDir(folderName):
		ConfigReader.setBaseDir(folderName)
Example #20
0
	def read(self):
		return ConfigReader.read(self, "filter.d/" + self.__file)
	def read(self):
		ConfigReader.read(self, "jail")
Example #22
0
	def getOptions(self, pOpts):
		opts = [["string", "ignoreregex", ""],
				["string", "failregex", "failmodel", ""]]
		self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
Example #23
0
 def read(self):
     return ConfigReader.read(self, "jail")
Example #24
0
	def read(self):
		ConfigReader.read(self, "fail2ban")
Example #25
0
from daterelate.daterelate import relate
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as conditions
from selenium.webdriver.support import ui
from configreader import ConfigReader

os.environ['DISPLAY'] = ':0'  # Set the display if set to run as cronjob

HOMEPAGE = 'http://myaccount.telkom.co.ke'
TODAY = datetime.now()

config = ConfigReader('defaults.ini')
TITLE = config.get('notificationtitle', default='Telkom Balance')
NUMBER = config.get('number', section='credentials', default='')
PASSWD = config.get('pass', section='credentials', default='')
s = os.path.join(os.path.expanduser('~'), 'bin')
driver_path = config.get('driverspath', default=s)
chrome_driver_name = config.get('chromedrivername',
                                section='Chrome',
                                default='chromedriver')
firefox_driver_name = config.get('firefoxdrivername',
                                 section='Firefox',
                                 default='geckodriver')
headless = config.get('headless', default=True)

chrome_options = ChromeOptions()
firefox_options = FirefoxOptions()
Example #26
0
	def read(self):
		return ConfigReader.read(self, "action.d/" + self.__file)
Example #27
0
from configreader import ConfigReader

config = ConfigReader("../../res/test.cfg")

print config.get("name")
print config.get_string("name")
print config.get_int("some_int")
print config.get_float("some_float")
print config.get_long("some_long")
print config.get_boolean("some_bool")

print config.get_boolean("some_int")
print config.get_boolean("some_nonexistent_property")
Example #28
0
class InputReceiver():
    def __init__(self):
        self.oP = OutPipe("InputReceiver", 0)
        self.cR = ConfigReader(GAME_PATH + "controls")
        self.sE = ScriptExecuter()
        self.eI = EngineInterface(objectMode=False)
        self.keyboard = self.eI.getKeyboard()
        self.mouse = self.eI.getMouse()
        self.tH = TypingHandler(self.keyboard)
        self.pairs = {}
        self.responses = {}
        self.oldKeyboard = self.keyboard.events
        self.oldMouse = self.mouse.events

        self.sE.addContext("Input", self)
        self.sE.execute(INPUT_PATH + "csp")
        self.sE.execute(INPUT_PATH + "input")

        self.keyEvents = []

        self.readControls()

        self.locked = False
        self.xsens = 50
        self.ysens = 50
        self.inverted = 0
        self.predict = False

        self.recent = {}

        self.oP("Initialized.")

    def addEvent(self, event):
        if not event in self.recent.keys():
            self.keyEvents.append(["INPUT", "COMMAND", event])

            if not type(event) == type(tuple()):
                self.recent[event] = time.time()

            if self.predict:
                self.callClientSidePrediction(event)

    def callClientSidePrediction(self, event):
        if not type(event) == type(tuple()):
            if hasattr(self, "csp_" + event):
                getattr(self, "csp_" + event)()
        else:
            if hasattr(self, "csp_look"):
                getattr(self, "csp_look")(event)

    def readControls(self):
        keys = self.cR.getAllOptions("CONTROLS")

        for key in keys:
            keyString = self.cR.get("CONTROLS", key)
            keyCode = self.eI.getKeyCode(keyString)
            try:
                self.pairs[keyCode] = getattr(self, key)
                self.oP("Read in key response %s successfully." % key)
            except:
                self.oP("Failed to read in key response %s successfully." %
                        key)

    def checkControls(self):
        for keyCode in self.pairs.keys():
            if keyCode in self.keyboard.events and not self.locked:
                if self.keyboard.events[keyCode] == self.eI.l.KX_INPUT_ACTIVE:
                    self.callCommand("KEYBOARD", keyCode)
                elif self.keyboard.events[
                        keyCode] == self.eI.l.KX_INPUT_JUST_ACTIVATED:
                    self.callCommand("KEYBOARD", keyCode)
                elif self.keyboard.events[
                        keyCode] == self.eI.l.KX_INPUT_JUST_RELEASED:
                    self.callCommand("KEYBOARD", keyCode)

            elif keyCode in self.mouse.events:
                if self.mouse.events[keyCode] == self.eI.l.KX_INPUT_ACTIVE:
                    self.callCommand("MOUSE", keyCode)
                elif self.mouse.events[
                        keyCode] == self.eI.l.KX_INPUT_JUST_ACTIVATED:
                    self.callCommand("MOUSE", keyCode)
                elif self.mouse.events[
                        keyCode] == self.eI.l.KX_INPUT_JUST_RELEASED:
                    self.callCommand("MOUSE", keyCode)

        self.oldKeyboard = self.keyboard.events
        self.oldMouse = self.mouse.events

        #Handle the "recent" spam blocker
        keys = self.recent.keys()
        for key in keys:
            if abs(self.recent[key] - time.time()) > 0.1:
                del self.recent[key]
                break

        if self.locked:
            self.tH.process()

    def callCommand(self, mode, keyCode):
        if mode == "KEYBOARD":
            state = self.getState(self.keyboard.events[keyCode],
                                  self.oldKeyboard[keyCode])
        elif mode == "MOUSE":
            state = self.getState(self.mouse.events[keyCode],
                                  self.oldMouse[keyCode])

        consumed = False

        if state == "DEACTIVATE" and keyCode in [
                self.eI.e.LEFTMOUSE, self.eI.e.RIGHTMOUSE
        ]:
            consumed = self.checkInterfaceClick(keyCode, self.mouse.position)

        if not consumed and not keyCode in [
                self.eI.e.MOUSEX, self.eI.e.MOUSEY
        ]:
            self.pairs[keyCode](state)
        elif keyCode in [self.eI.e.MOUSEX, self.eI.e.MOUSEY]:
            pos = self.mouse.position
            self.pairs[keyCode](pos)

    def checkInterfaceClick(self, keyCode, pos):
        return self.eI.getGlobal("client").inputClick(keyCode, pos)

    def getState(self, newstate, oldstate):
        if newstate == self.eI.l.KX_INPUT_ACTIVE:
            if oldstate == self.eI.l.KX_INPUT_ACTIVE:
                return "ACTIVE"
            elif oldstate == self.eI.l.KX_INPUT_NONE:
                return "ACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_ACTIVATED:
                return "ACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_RELEASED:
                return "ACTIVATE"

        if newstate == self.eI.l.KX_INPUT_NONE:
            if oldstate == self.eI.l.KX_INPUT_ACTIVE:
                return "DEACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_NONE:
                return "INACTIVE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_ACTIVATED:
                return "DEACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_RELEASED:
                return "DEACTIVATE"

        if newstate == self.eI.l.KX_INPUT_JUST_ACTIVATED:
            if oldstate == self.eI.l.KX_INPUT_ACTIVE:
                return "ACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_NONE:
                return "ACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_ACTIVATED:
                return "ACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_RELEASED:
                return "ACTIVATE"

        if newstate == self.eI.l.KX_INPUT_JUST_RELEASED:
            if oldstate == self.eI.l.KX_INPUT_ACTIVE:
                return "DEACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_NONE:
                return "DEACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_ACTIVATED:
                return "DEACTIVATE"
            elif oldstate == self.eI.l.KX_INPUT_JUST_RELEASED:
                return "DEACTIVATE"
Example #29
0
	def __init__(self, action, name):
		ConfigReader.__init__(self)
		self.__file = action[0]
		self.__cInfo = action[1]
		self.__name = name
 def __init__(self, fileName, name):
     ConfigReader.__init__(self)
     self.__file = fileName
     self.__name = name
Example #31
0
	def __init__(self, name):
		ConfigReader.__init__(self)
		self.__name = name
		self.__filter = None
		self.__actions = list()
Example #32
0
from configreader import ConfigReader
import getpass
import psycopg2
from prettytable import PrettyTable
from prettytable import from_db_cursor

def get_script_path():
    return os.path.dirname(os.path.realpath(sys.argv[0]))

configfile = '/etc/pgsnapman/pgsnapman.config'  
if not os.path.exists(configfile):
  configfile = home = expanduser("~") + '/.pgsnapman.config'
  print configfile
if not os.path.exists(configfile):
  configfile =  get_script_path() + '/../bin/pgsnapman.config'
config = ConfigReader(configfile)
PGSCHOST=config.getval('PGSCHOST')
PGSCPORT=config.getval('PGSCPORT')
PGSCUSER=config.getval('PGSCUSER')
PGSCDB=config.getval('PGSCDB')
PGSCPASSWORD=config.getval('PGSCPASSWORD')

print('')
print('+-----------------------------+')
print('|  pgsnapman script uploader  |')
print('+-----------------------------+')
print('')
print('Verifying database connection...')
if PGSCPASSWORD == '':
  PGSCPASSWORD=getpass.getpass('password: ')
try:
Example #33
0
 def __init__(self, fileName, name, **kwargs):
     ConfigReader.__init__(self, **kwargs)
     self.__file = fileName
     self.__name = name
Example #34
0
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, DateType, \
    StringType, TimestampType, DecimalType, IntegerType
from configreader import ConfigReader
from parsers import parse_line

spark = SparkSession.builder.getOrCreate()
spark.sparkContext.addPyFile("parsers.py")

from azure.storage.blob import BlobServiceClient

reader = ConfigReader("config.cfg", "azure-storage")
config = reader.get_config()

# Get Azure storage info from config
storage_acct_name = config["account_name"]
storage_acct_access_key = config["access_key"]
storage_container = config["container_name"]
mount_root = config["mount_root"]

# Set Spark Azure storage account and key
storage_acct_key_str = f"fs.azure.account.key.{storage_acct_name}.blob.core.windows.net"
spark.conf.set(storage_acct_key_str, storage_acct_access_key)

# Set base Spark filepath for container
container_base_path = f"​wasbs://{storage_container}@{storage_acct_name}.blob.core.windows.net"
mount_base_path = f"{mount_root}/{storage_container}"

# Set up container client
blob_service_client = BlobServiceClient(account_url=f"https://{storage_acct_name}.blob.core.windows.net", \
    credential=storage_acct_access_key)
Example #35
0
 def getOptions(self, pOpts):
     opts = [["string", "ignoreregex", ""], ["string", "failregex", ""]]
     self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
Example #36
0
 def read(self):
     return ConfigReader.read(self, os.path.join("filter.d", self.__file))
Example #37
0
	def getOptions(self):
		opts = [["int", "loglevel", 1],
				["string", "logtarget", "STDERR"]]
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)
Example #38
0
 def read(self):
     ConfigReader.read(self, "jail")
Example #39
0
 def read(self):
     ConfigReader.read(self, "fail2ban")
Example #40
0
 def __init__(self, fileName, name, **kwargs):
     ConfigReader.__init__(self, **kwargs)
     # Defer initialization to the set Methods
     self.__file = self.__name = self.__opts = None
     self.setFile(fileName)
     self.setName(name)
Example #41
0
 def __init__(self, name, force_enable=False, **kwargs):
     ConfigReader.__init__(self, **kwargs)
     self.__name = name
     self.__filter = None
     self.__force_enable = force_enable
     self.__actions = list()
Example #42
0
 def getOptions(self):
     opts = [["int", "loglevel", 1], ["string", "logtarget", "STDERR"]]
     self.__opts = ConfigReader.getOptions(self, "Definition", opts)
Example #43
0
	def __init__(self, fileName, name):
		ConfigReader.__init__(self)
		self.__file = fileName
		self.__name = name
Example #44
0
	def __init__(self, name):
		ConfigReader.__init__(self)
		self.__name = name
		self.__filter = None
		self.__actions = list()
	def __init__(self):
		ConfigReader.__init__(self)
		self.__jails = list()
Example #46
0
from cellgrid import CellGrid
from cell import Cell
from coord import Coord
from configreader import ConfigReader
import route
import json
import datetime
config = ConfigReader("settings.conf")
api_key = config.apikey
grid = CellGrid(Coord(39.0095, -77.16796),
                Coord(38.8044, -76.89331),
                grid_width=5,
                grid_height=5)
with open('gridfeaturecounts.json', 'r') as featurecounts_per_cell:
    javascript_analysis_results_json = featurecounts_per_cell.read().replace(
        '\n', '')

grid.load_javascript_analysis_json(javascript_analysis_results_json)
grid.generate_scaled_scores_zero_to_one()
print(grid.to_geojson())
Example #47
0
 def __init__(self, **kwargs):
     ConfigReader.__init__(self, **kwargs)
Example #48
0
	def __init__(self, action, name):
		ConfigReader.__init__(self)
		self.__file = action[0]
		self.__cInfo = action[1]
		self.__name = name
Example #49
0
	def getBaseDir():
		return ConfigReader.getBaseDir()
Example #50
0
	def read(self):
		return ConfigReader.read(self, "action.d/" + self.__file)
Example #51
0
 def read(self):
     return ConfigReader.read(self, "filter.d/" + self.__file)
Example #52
0
 def getEarlyOptions(self):
     opts = [["string", "socket", "/var/run/fail2ban/fail2ban.sock"],
             ["string", "pidfile", "/var/run/fail2ban/fail2ban.pid"]]
     return ConfigReader.getOptions(self, "Definition", opts)
Example #53
0
	def __init__(self):
		ConfigReader.__init__(self)
Example #54
0
	def setBaseDir(folderName):
		ConfigReader.setBaseDir(folderName)
Example #55
0
	def getEarlyOptions(self):
		opts = [["string", "socket", "/tmp/fail2ban.sock"],
				["string", "pidfile", "/var/run/fail2ban/fail2ban.pid"]]
		return ConfigReader.getOptions(self, "Definition", opts)
Example #56
0
	def getBaseDir():
		return ConfigReader.getBaseDir()
Example #57
0
 def __init__(self):
     ConfigReader.__init__(self)
     self.__jails = list()
Example #58
0
                for pattern in sortDict.keys():
                    if re.search(pattern, filename):
                        logging.info(" Regex matched: " + pattern + " with Filename: " +  filename)
                        src = folder_to_track + "/" + filename
                        to = sortDict.get(pattern) + "/" + filename
                        try:
                            os.rename(src, to)
                            logging.info(" Moved " + src + " to " + to) 
                        except FileNotFoundError as Identifier:
                            logging.warning(Identifier)
                            logging.warning(" Please look at your destination path and whether the path exists. ")
                                 

# Config      
StartLogging()      
config = ConfigReader()
sortDict = config.getParams()
folder_to_track = config.getTrackFolder()

# Handling
eventHandler = DownloadFileHandler()
observer = Observer()
observer.schedule(eventHandler, folder_to_track, recursive =True)
observer.start()

try:
    while True:
        time.sleep(10)
        logging.info(" Running, timestamp: [" + str(time.asctime()) + "]")
except KeyboardInterrupt:
    observer.stop()
Example #59
0
 def __init__(self):
     configreader = ConfigReader()
     self.config = configreader.readConfig()
Example #60
0
	def read(self):
		return ConfigReader.read(self, "jail")