Ejemplo n.º 1
0
 def __init__(self, db_handler):
     '''
     Args:
         db_handler: An object of Db.DbHandler
     '''
     FileSystemEventHandler.__init__(self)
     self._db_handler = db_handler
Ejemplo n.º 2
0
    def __init__(self):
        FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
        self.root = None
        self.currentdir = None		# The actual logdir that we're monitoring
        self.logfile = None
        self.observer = None
        self.observed = None		# a watchdog ObservedWatch, or None if polling
        self.thread = None
        self.event_queue = []		# For communicating journal entries back to main thread

        # On startup we might be:
        # 1) Looking at an old journal file because the game isn't running or the user has exited to the main menu.
        # 2) Looking at an empty journal (only 'Fileheader') because the user is at the main menu.
        # 3) In the middle of a 'live' game.
        # If 1 or 2 a LoadGame event will happen when the game goes live.
        # If 3 we need to inject a special 'StartUp' event since consumers won't see the LoadGame event.
        self.live = False

        self.game_was_running = False	# For generation the "ShutDown" event

        # Context for journal handling
        self.version = None
        self.is_beta = False
        self.mode = None
        self.group = None
        self.cmdr = None
        self.planet = None
        self.system = None
        self.station = None
        self.stationtype = None
        self.coordinates = None
        self.systemaddress = None
        self.started = None	# Timestamp of the LoadGame event

        # Cmdr state shared with EDSM and plugins
        self.state = {
            'Captain'      : None,	# On a crew
            'Cargo'        : defaultdict(int),
            'Credits'      : None,
            'FID'          : None,	# Frontier Cmdr ID
            'Horizons'     : None,	# Does this user have Horizons?
            'Loan'         : None,
            'Raw'          : defaultdict(int),
            'Manufactured' : defaultdict(int),
            'Encoded'      : defaultdict(int),
            'Engineers'    : {},
            'Rank'         : {},
            'Reputation'   : {},
            'Statistics'   : {},
            'Role'         : None,	# Crew role - None, Idle, FireCon, FighterCon
            'Friends'      : set(),	# Online friends
            'ShipID'       : None,
            'ShipIdent'    : None,
            'ShipName'     : None,
            'ShipType'     : None,
            'HullValue'    : None,
            'ModulesValue' : None,
            'Rebuy'        : None,
            'Modules'      : None,
        }
Ejemplo n.º 3
0
    def __init__(self):
        FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
        self.root = None
        self.currentdir = None		# The actual logdir that we're monitoring
        self.logfile = None
        self.observer = None
        self.observed = None		# a watchdog ObservedWatch, or None if polling
        self.thread = None
        self.event_queue = []		# For communicating journal entries back to main thread

        # Context for journal handling
        self.version = None
        self.is_beta = False
        self.mode = None
        self.group = None
        self.cmdr = None
        self.shipid = None
        self.shiptype = None
        self.shippaint = None
        self.body = None
        self.system = None
        self.station = None
        self.coordinates = None
        self.ranks = None
        self.credits = None
Ejemplo n.º 4
0
 def __init__(self, fun, publisher, pattern, attrs):
     """Initialize the processor."""
     FileSystemEventHandler.__init__(self)
     self.fun = fun
     self.publisher = publisher
     self.pattern = pattern
     self.attrs = attrs
Ejemplo n.º 5
0
    def __init__(self):
        FileSystemEventHandler.__init__(
            self)  # futureproofing - not need for current version of watchdog
        self.root = None
        self.currentdir = None  # The actual logdir that we're monitoring
        self.logfile = None
        self.observer = None
        self.observed = None  # a watchdog ObservedWatch, or None if polling
        self.thread = None
        self.event_queue = [
        ]  # For communicating journal entries back to main thread

        # On startup we might be:
        # 1) Looking at an old journal file because the game isn't running or the user has exited to the main menu.
        # 2) Looking at an empty journal (only 'Fileheader') because the user is at the main menu.
        # 3) In the middle of a 'live' game.
        # If 1 or 2 a LoadGame event will happen when the game goes live.
        # If 3 we need to inject a special 'StartUp' event since consumers won't see the LoadGame event.
        self.live = False

        self.game_was_running = False  # For generation the "ShutDown" event

        # Context for journal handling
        self.version = None
        self.is_beta = False
        self.mode = None
        self.group = None
        self.cmdr = None
        self.planet = None
        self.system = None
        self.station = None
        self.stationtype = None
        self.coordinates = None
        self.systemaddress = None
        self.started = None  # Timestamp of the LoadGame event
        self.missioncargo = {}  # For tracking cargo in wing missions

        # Cmdr state shared with EDSM and plugins
        self.state = {
            'Captain': None,  # On a crew
            'Cargo': defaultdict(int),
            'Credits': None,
            'Loan': None,
            'Raw': defaultdict(int),
            'Manufactured': defaultdict(int),
            'Encoded': defaultdict(int),
            'Rank': {},
            'Reputation': {},
            'Statistics': {},
            'Role': None,  # Crew role - None, Idle, FireCon, FighterCon
            'Friends': set(),  # Online friends
            'ShipID': None,
            'ShipIdent': None,
            'ShipName': None,
            'ShipType': None,
            'HullValue': None,
            'ModulesValue': None,
            'Rebuy': None,
            'Modules': None,
        }
Ejemplo n.º 6
0
 def __init__(self, library, path, xbmcif):
     FileSystemEventHandler.__init__(self)
     self.library = library
     self.path = path
     self.xbmcif = xbmcif
     self.supported_media = '|' + py2_decode(
         xbmc.getSupportedMedia(library)) + '|'
 def __init__(self, paths, forkloop, minimum_wait=2.0):
     FileSystemEventHandler.__init__(self)
     self.forkloop = forkloop
     self.observers = []
     self.paths = paths
     self.minimum_wait = minimum_wait
     self.last_event = time.time()
 def __init__(self, *args, **kwargs):
     self.rate = 4
     self.surface = pygame.Surface((1, 1))
     self.size = (0, 0)
     self.fade = False
     self.screensize = kwargs.pop("screensize")
     FileSystemEventHandler.__init__(self, *args, **kwargs)
Ejemplo n.º 9
0
 def __init__(self):
     """
     Constructor
     :return:
     """
     FileSystemEventHandler.__init__(self)
     self.app = app._get_current_object()
Ejemplo n.º 10
0
 def __init__(self, project_id, handler_type='project'):
     # Initialize.
     self.project_id = project_id
     FileSystemEventHandler.__init__(self)
     # Handler is a project file handler...
     if handler_type == 'project':
         log_msg = ('PROJECT_EVENT_HANDLER initialized for project '
                    'with ID {project_id}')
         self.actions = {
             'Created': self._on_created_project,
             'Deleted': self._on_deleted_project,
             'Modified': self._on_modified_project,
             'Moved': self._on_moved_project
         }
     # Handler is a project scanner handler.
     elif handler_type == 'scanner':
         log_msg = ('Project image scan handler initialized for project '
                    'with ID {project_id}')
         self.actions = {'Created': self._on_created_scanner}
     # Undefined handler type.
     else:
         raise NotImplementedError()
     # Populate the log_mgs with data and log.
     log_msg = log_msg.format(**self.__dict__)
     _logger().debug(log_msg)
 def __init__(self, paths, forkloop, minimum_wait=2.0):
     FileSystemEventHandler.__init__(self)
     self.forkloop = forkloop
     self.observers = []
     self.paths = paths
     self.minimum_wait = minimum_wait
     self.last_event = time.time()
Ejemplo n.º 12
0
 def __init__(self, path, mask, callbacks, pending_delay):
     FileSystemEventHandler.__init__(self)
     self._path = path
     self._mask = mask
     self._callbacks = callbacks
     self._pending_delay = pending_delay
     self._pending = set()
Ejemplo n.º 13
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)
     super().__init__()
     self.locked_groups = []
     try:
         pass
         self.load_state()
         self.displaygen()
     except:
         self.display = ""
         self.groups = []
         self.monitors = {}
         monitors = command("bspc query -M --names").strip().split("\n")
         for monitor in monitors:
             self.monitors[monitor] = []
             workspaces = command("bspc query -D -m " + monitor +
                                  " --names").strip().split("\n")
             command("bspc desktop -f " + workspaces[0])
             self.groups.append(Group())
             self.activegroup = self.groups[-1]
             self.activegroup.workspaces = [
                 workspace for workspace in workspaces
             ]
     try:
         command("rm {}*".format(config["command_folder"]))
     except:
         pass
     self.displaygen()
Ejemplo n.º 14
0
 def __init__(self, file_path, window):
     FileSystemEventHandler.__init__(self)
     self.file_path = os.path.normpath(file_path)
     self.last_position = 0
     self.signal = None
     self.signal = window.new_window
     self.ProcessCommands()
Ejemplo n.º 15
0
 def __init__(self, path, mask, callbacks, pending_delay):
     FileSystemEventHandler.__init__(self)
     self._path = path
     self._mask = mask
     self._callbacks = callbacks
     self._pending_delay = pending_delay
     self._pending = set()
Ejemplo n.º 16
0
    def __init__(self, monitor_dir, config):
        FileSystemEventHandler.__init__(self)

        self.monitor_dir = monitor_dir
        if not config: config = {}

        self.scan_interval = config.get('scan_interval', 3) # If no updates in 3 seconds (or user specified option in config file) process file
Ejemplo n.º 17
0
 def __init__(self, file_path, host="192.168.1.25", port=1234):
     FileSystemEventHandler.__init__(self)
     self.file_path = file_path
     self._host = host
     self._port = port
     self._regex = re.compile(r"^(?P<artist>.*) - (?P<title>.*)$")
     self._last_sent = time.time()
Ejemplo n.º 18
0
    def __init__(self, holder, configfile, *args, **kwargs):
        FileSystemEventHandler.__init__(self, *args, **kwargs)
        self._file = None
        self._filename = ""
        self._where = 0
        self._satellite = ""
        self._orbital = None
        cfg = ConfigParser()
        cfg.read(configfile)
        self._coords = cfg.get("local_reception", "coordinates").split(" ")
        self._coords = [float(self._coords[0]),
                        float(self._coords[1]),
                        float(self._coords[2])]
        self._station = cfg.get("local_reception", "station")
        logger.debug("Station " + self._station +
                     " located at: " + str(self._coords))
        try:
            self._tle_files = cfg.get("local_reception", "tle_files")
        except NoOptionError:
            self._tle_files = None

        self._file_pattern = cfg.get("local_reception", "file_pattern")
        
        self.scanlines = holder

        self._warn = True
Ejemplo n.º 19
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
     self.root = None
     self.currentdir = None		# The actual logdir that we're monitoring
     self.observer = None
     self.observed = None		# a watchdog ObservedWatch, or None if polling
     self.status = {}		# Current status for communicating status back to main thread
Ejemplo n.º 20
0
    def __init__(self, holder, configfile, *args, **kwargs):
        FileSystemEventHandler.__init__(self, *args, **kwargs)
        self._file = None
        self._filename = ""
        self._where = 0
        self._satellite = ""
        self._orbital = None
        cfg = ConfigParser()
        cfg.read(configfile)
        self._coords = cfg.get("local_reception", "coordinates").split(" ")
        self._coords = [
            float(self._coords[0]),
            float(self._coords[1]),
            float(self._coords[2])
        ]
        self._station = cfg.get("local_reception", "station")
        logger.debug("Station " + self._station + " located at: " +
                     str(self._coords))
        try:
            self._tle_files = cfg.get("local_reception", "tle_files")
        except NoOptionError:
            self._tle_files = None

        self._file_pattern = cfg.get("local_reception", "file_pattern")

        self.scanlines = holder

        self._warn = True
Ejemplo n.º 21
0
 def __init__(self, name, queue):
     FileSystemEventHandler.__init__(self)
     self.name = name
     self.queue = queue
     self.set = set()
     self.num = 0
     self.no = 0
Ejemplo n.º 22
0
    def __init__(self, parent, *args, **kwargs):
        QtCore.QObject.__init__(self, parent)
        FileSystemEventHandler.__init__(self, *args, **kwargs)
        Tester.__init__(self)

        self.parent = parent

        self.signfilelistupdate.connect(self.parent.updateWatchdogFileList)
Ejemplo n.º 23
0
    def __init__(self, filepath):  # type: (str)
        warn("Attribute currentConfig will be replaced with property"
               "current_config. Use current_config instead.")

        FileSystemEventHandler.__init__(self)

        self.filepath = filepath
        self.current_config = None
Ejemplo n.º 24
0
 def __init__(self, origin, watch_path, event_func):
     FileSystemEventHandler.__init__(self)
     self.origin = origin
     self.watch_path = watch_path
     self.event_func = event_func
     self.observer = Observer()
     self.watch = None
     self.mutex = threading.Lock()
Ejemplo n.º 25
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)
     logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] [%(name)s] %(message)s")
     self._logger = logging.getLogger(self.__class__.__name__)
     self._create_pid_file(os.path.dirname(__file__))
     self._register_signal()
     self.__last_modify_timestamp = time.time()
     self.__observer = Observer()
Ejemplo n.º 26
0
 def __init__(self, bucket, rootkey=None,
              sizetrigger=8*1024*1024, timetrigger=5):
     _FileSystemEventHandler.__init__(self)
     self._bucket = bucket
     self._rootkey = rootkey
     self._sizetrigger = int(sizetrigger)
     self._timetrigger = int(timetrigger)
     self._files = {}
Ejemplo n.º 27
0
 def __init__(self, args, names, tax, class_number):
     FileSystemEventHandler.__init__(self)
     self.tax = tax
     self.names = names
     self.class_number = class_number
     self.queue = []
     self.nr_dirs = 0
     self.species = {}
     self.args = args
	def __init__(self):
		self.watcher_pid_file = os.path.join(MONITOR_ROOT, "watcher.pid.txt")
		self.watcher_log_file = os.path.join(MONITOR_ROOT, "watcher.log.txt")

		self.annex_observer = Observer()
		self.netcat_queue = []
		self.cleanup_upload_lock = False

		FileSystemEventHandler.__init__(self)
    def __init__(self):
        self.watcher_pid_file = os.path.join(MONITOR_ROOT, "watcher.pid.txt")
        self.watcher_log_file = os.path.join(MONITOR_ROOT, "watcher.log.txt")

        self.annex_observer = Observer()
        self.netcat_queue = []
        self.cleanup_upload_lock = False

        FileSystemEventHandler.__init__(self)
Ejemplo n.º 30
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
     self.root = None
     self.logdir = self._logdir()
     self.logfile = None
     self.observer = None
     self.thread = None
     self.callback = None
     self.last_event = None	# for communicating the Jump event
Ejemplo n.º 31
0
    def __init__(self):
        FileSystemEventHandler.__init__(
            self)  # futureproofing - not need for current version of watchdog
        self.root = None
        self.currentdir = None  # The actual logdir that we're monitoring
        self.logfile = None
        self.observer = None
        self.observed = None  # a watchdog ObservedWatch, or None if polling
        self.thread = None
        self.event_queue = [
        ]  # For communicating journal entries back to main thread

        # On startup we might be:
        # 1) Looking at an old journal file because the game isn't running or the user has exited to the main menu.
        # 2) Looking at an empty journal (only 'Fileheader') because the user is at the main menu.
        # 3) In the middle of a 'live' game.
        # If 1 or 2 a LoadGame event will happen when the game goes live.
        # If 3 we need to inject a special 'StartUp' event since consumers won't see the LoadGame event.
        self.live = False

        # Context for journal handling
        self.version = None
        self.is_beta = False
        self.mode = None
        self.group = None
        self.cmdr = None
        self.captain = None  # On a crew
        self.role = None  # Crew role - None, FireCon, FighterCon
        self.body = None
        self.system = None
        self.station = None
        self.coordinates = None
        self.state = {}  # Initialized in Fileheader

        # Cmdr state shared with EDSM and plugins
        self.state = {
            'Cargo': defaultdict(int),
            'Credits': None,
            'Loan': None,
            'Raw': defaultdict(int),
            'Manufactured': defaultdict(int),
            'Encoded': defaultdict(int),
            'PaintJob': None,
            'Rank': {
                'Combat': None,
                'Trade': None,
                'Explore': None,
                'Empire': None,
                'Federation': None,
                'CQC': None
            },
            'ShipID': None,
            'ShipIdent': None,
            'ShipName': None,
            'ShipType': None,
            'Missions': dict(),
        }
Ejemplo n.º 32
0
 def __init__(self, sender, relpath, onchange):
     self.sender = sender
     self.relpath = relpath
     self.onchange = onchange
     self.stop_requested = threading.Event()
     self.stopped = threading.Event()
     threading.Thread.__init__(self)
     FileSystemEventHandler.__init__(self)
     FsListener.__init__(self)
     self.uid = str(uuid.uuid4())
Ejemplo n.º 33
0
    def __init__(self, config, prompter: Prompter):
        FileSystemEventHandler.__init__(self)
        threading.Thread.__init__(self, daemon=True)

        self.config = config
        self.prompter = prompter
        self.observer = Observer()
        self.has_path = False
        self.event_buffer = EventBuffer()
        self._callback = None
Ejemplo n.º 34
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
     self.root = None
     self.logdir = self._logdir()
     self.logfile = None
     self.logging_enabled = self._logging_enabled
     self._restart_required = False
     self.observer = None
     self.thread = None
     self.last_event = None	# for communicating the Jump event
Ejemplo n.º 35
0
        def __init__(self, collectors, terminator, decoder, patterns, observer_class_name):
            FileSystemEventHandler.__init__(self)
            FileTrigger.__init__(self, collectors, terminator, decoder)
            self.input_dirs = []
            for pattern in patterns:
                self.input_dirs.append(os.path.dirname(pattern))
            self.patterns = patterns

            self.new_file = Event()
            self.observer = self.cases.get(observer_class_name, Observer)()
Ejemplo n.º 36
0
        def __init__(self, patterns, observer_class_name="Observer"):
            FileSystemEventHandler.__init__(self)
            self.input_dirs = []
            for pattern in patterns:
                self.input_dirs.append(os.path.dirname(pattern))
                LOG.debug("watching " + str(os.path.dirname(pattern)))
            self.patterns = patterns

            self.new_file = Event()
            self.observer = self.cases.get(observer_class_name, Observer)()
Ejemplo n.º 37
0
        def __init__(self, patterns, observer_class_name="Observer"):
            FileSystemEventHandler.__init__(self)
            self.input_dirs = []
            for pattern in patterns:
                self.input_dirs.append(os.path.dirname(pattern))
                LOG.debug("watching " + str(os.path.dirname(pattern)))
            self.patterns = patterns

            self.new_file = Event()
            self.observer = self.cases.get(observer_class_name, Observer)()
Ejemplo n.º 38
0
 def __init__(self):
     FileSystemEventHandler.__init__(
         self)  # futureproofing - not need for current version of watchdog
     self.root = None
     self.currentdir = None  # The actual logdir that we're monitoring
     self.observer = None
     self.observed = None  # a watchdog ObservedWatch, or None if polling
     self.seen = []  # interactions that we've already processed
     self.interaction_queue = [
     ]  # For communicating interactions back to main thread
Ejemplo n.º 39
0
 def __init__(self, send_path, receive_uri, secret_key):
     FileSystemEventHandler.__init__(self)
     self.send_path = send_path.rstrip('/')
     result = urlparse(receive_uri)
     self.server = '%s://%s' % (result.scheme, result.netloc)
     if 'Windows' in platform.system():
         self.receive_path = result.path.strip('/')
     else:
         self.receive_path = result.path.rstrip('/')
     self.secret_key = secret_key
Ejemplo n.º 40
0
 def __init__(self, filename: str, callback: Callable[[], Any]):
     if watchdog is None:
         raise RuntimeError('watchdog module is not available')
     MaybeFileSystemEventHandler.__init__(self)
     BaseObserver.__init__(self, filename, callback)
     # NOTE (@NiklasRosenstein): Using os.path.realpath() (which is used in BaseObserver()) is important
     #   because of https://github.com/gorakhargosh/watchdog/issues/821.
     self._observer = Observer()
     self._observer.schedule(self,
                             path=os.path.dirname(self.filename),
                             recursive=False)
Ejemplo n.º 41
0
 def __init__(self, dirname, record_source, loglevel):
     FileSystemEventHandler.__init__(self)
     self.dirname = dirname
     if not os.path.isdir(self.dirname + constants.TMP_FOLDER): 
         os.mkdir(self.dirname + constants.TMP_FOLDER)
     self.changes = {}
     self.just_changed = {}
     self.valid = re.compile(r'^(\./)?([^/]+/)*(?!\.)[^/]*[^~]$') #PE test this, should work
     #self.valid = re.compile(r'^(.+/)*[^\./][^/~]*$')
     self.record_source = record_source
     self.loglevel = loglevel
Ejemplo n.º 42
0
    def __init__(self, exit, input_directory, output_directory, output_directory_tmp, loop=None, **kwargs):
        self._exit = exit
        self._loop = loop
        self._input_directory = input_directory
        self._output_directory = (output_directory_tmp, output_directory)

        logging.info('From directory is ' + input_directory)
        logging.info('To directory is ' + output_directory)

        AIOEventHandler.__init__(self, loop)
        FileSystemEventHandler.__init__(self, **kwargs)
Ejemplo n.º 43
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
     self.root = None
     self.logdir = self._logdir()	# E:D client's default Logs directory, or None if not found
     self.currentdir = None		# The actual logdir that we're monitoring
     self.logfile = None
     self.observer = None
     self.observed = None
     self.thread = None
     self.callbacks = { 'Jump': None, 'Dock': None }
     self.last_event = None	# for communicating the Jump event
Ejemplo n.º 44
0
    def __init__(self, patterns, observer_class_name="Observer"):
        """Init the processor."""
        FileSystemEventHandler.__init__(self)
        self.input_dirs = []
        for pattern in patterns:
            self.input_dirs.append(os.path.dirname(pattern))
            logger.debug("watching %s", str(os.path.dirname(pattern)))
        self.patterns = patterns

        self.new_file = Event()
        self.observer = self.cases.get(observer_class_name, Observer)()
Ejemplo n.º 45
0
  def __init__(self, options):

    # print options

    # Store the command line args
    self.options = options
    self.channel = Channel.objects.get(slug=self.options['channel_name'])

    # Init ourselves some redis
    pool = redis.ConnectionPool(host='localhost', port=6379, db=self.channel.redis_db)
    r = redis.Redis(connection_pool=pool)
    self.pipe = r.pipeline()
    self.redis_index = 0

    # If the overwrite flag is set, flush the redis db, 
    # set the channel line count to 0, and set the date
    # context to the channel start date, else grab the latest
    # date from the scores
    if self.options['overwrite']:
      r.flushdb()
      self.channel.set_line_count(0)
      self.date = self.channel.start_date
    else:
      self.date = self.channel.get_latest_date()

    # Define the nick handling members
    self.nicks = dict()
    nick_regex_string = '[a-zA-Z0-9_-\{\}\^\`\|]+'
    self.nick_regex_strings = [
      '<(?P<nick>%s)>' % nick_regex_string,
      'Action: (?P<nick>%s) ' % nick_regex_string,
      'Nick change: (?P<nick>%s) ' % nick_regex_string,
      'Topic changed on [#&][[a-zA-Z0-9]+ by (?P<nick>%s)\!' % nick_regex_string,
      '%s kicked from [#&][[a-zA-Z0-9]+ by (?P<nick>%s)' % (nick_regex_string, nick_regex_string),
      '(?P<nick>%s) \(.*\) [left|joined]' % nick_regex_string,
      '[#&][[a-zA-Z0-9]+: mode change \'.*\' by (?P<nick>%s)\!' % nick_regex_string
    ]

    #Grab a list of files in the target directory, sort and stick in a deque for optimized access (lists are slow)
    self.dir = deque()
    for f in sorted(filter(lambda x: self.options['filter_string'] in x, os.listdir(self.options['path']))):
      self.dir.append('%s%s' % (self.options['path'], f))

    # Open the first file in the queue
    self.file = open(self.dir.popleft(), 'r')

    # Set the initial file position
    self.where = self.file.tell()

    # Run the initial feed of the logs
    self.ReadLog()
    FileSystemEventHandler.__init__(self)
    def __init__(self, cfg_path=None, sharing_path=None):
        FileSystemEventHandler.__init__(self)
        # Just Initialize variable the Daemon.start() do the other things
        self.daemon_state = 'down'  # TODO implement the daemon state (disconnected, connected, syncronizing, ready...)
        self.running = 0
        self.client_snapshot = {}  # EXAMPLE {'<filepath1>: ['<timestamp>', '<md5>', '<filepath2>: ...}
        self.local_dir_state = {}  # EXAMPLE {'last_timestamp': '<timestamp>', 'global_md5': '<md5>'}
        self.listener_socket = None
        self.observer = None
        self.cfg = self._load_cfg(cfg_path, sharing_path)
        self.password = self._load_pass()
        self._init_sharing_path(sharing_path)

        self.conn_mng = ConnectionManager(self.cfg)
Ejemplo n.º 47
0
    def __init__(self, monitor_dir, config, archive=False, initial_scan=False,
                 archive_suffix="_orig.pdf"):
        FileSystemEventHandler.__init__(self)

        self.monitor_dir = monitor_dir
        self.archive_suffix = archive_suffix
        self.archive = archive

        if not config: config = {}

        # Scan initial folder
        if initial_scan:
            self.scan_folder()

        self.scan_interval = config.get('scan_interval', 3) # If no updates in 3 seconds (or user specified option in config file) process file
Ejemplo n.º 48
0
    def __init__(self, paper_filename, publish_url, paper_id):
        FileSystemEventHandler.__init__(self)  # super init

        self.paper_filename = paper_filename
        self.is_pdf = paper_filename.endswith('pdf')

        self.publish_url = publish_url
        self.paper_id = paper_id

        self.reset_stats()

        logging.info(
            "Creating a GamificationHandler with paper: " + paper_filename +
            " publish_url: " + publish_url +
            " and paper id: " + paper_id
        )
Ejemplo n.º 49
0
  def __init__(self):
    # Grab a list of files in the target directory, sort and stick in a deque for optimized access (lists are slow)
    self.dir = deque()
    for f in sorted(filter(lambda x: args.filter_string in x, os.listdir(args.path))):
      self.dir.append('%s%s' % (args.path, f))

    # Open the first file in the queue
    self.file = open(self.dir.popleft(), 'r')

    # Init ourselves some redis
    self.r = redis.Redis(host='localhost', port=6379, db=args.db_index)
    self.redis_index = 0

    # Set the initial file position
    self.where = self.file.tell()

    # Run the initial feed of the logs
    self.ReadLog()
    FileSystemEventHandler.__init__(self)
Ejemplo n.º 50
0
    def __init__(self):
        FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
        self.root = None
        self.logdir = self._logdir()
        self.logfile = None
        self.logging_enabled = self._logging_enabled
        self._restart_required = False
        self.thread = None
        self.last_event = None	# for communicating the Jump event

        if self.logdir:
            # Set up a watchog observer. This is low overhead so is left running irrespective of whether monitoring is desired.
            observer = Observer()
            observer.daemon = True
            observer.schedule(self, self.logdir)
            observer.start()
            atexit.register(observer.stop)

            # Latest pre-existing logfile - e.g. if E:D is already running. Assumes logs sort alphabetically.
            logfiles = sorted([x for x in listdir(self.logdir) if x.startswith('netLog.')])
            self.logfile = logfiles and join(self.logdir, logfiles[-1]) or None
Ejemplo n.º 51
0
    def __init__(self):
        FileSystemEventHandler.__init__(self)	# futureproofing - not need for current version of watchdog
        self.root = None
        self.currentdir = None		# The actual logdir that we're monitoring
        self.logfile = None
        self.observer = None
        self.observed = None		# a watchdog ObservedWatch, or None if polling
        self.thread = None
        self.event_queue = []		# For communicating journal entries back to main thread

        # Context for journal handling
        self.version = None
        self.is_beta = False
        self.mode = None
        self.cmdr = None
        self.shipid = None
        self.system = None
        self.station = None
        self.coordinates = None
        self.ranks = None
        self.credits = None
Ejemplo n.º 52
0
	def __init__(self, paper_filename, publish_url, paper_id):

		FileSystemEventHandler.__init__(self)

		self.paper_filename = paper_filename
		self.publish_url = publish_url
		self.paper_id = paper_id

		logging.info("Creating a GamificationHandler with paper: " +
			paper_filename +
			" publish_url: " +
			publish_url +
			" and paper id: " +
			paper_id
		)

		self.stats = {}
		self.words = {}
		self.paragraphs = []
		self.num_words = 0
		self.total_word_len = 0
Ejemplo n.º 53
0
 def __init__(self, wake_cb, only_cwd):
     self.wake_cb = wake_cb
     FileSystemEventHandler.__init__(self)
     self.observer = Observer()
     if only_cwd:
         self.observePythonDirs(os.getcwd())
     else:
         for importer, name, ispkg in pkgutil.iter_modules():
             if ispkg and '/lib/' not in importer.path:
                 self.observePythonDirs(importer.path)
     try:
         self.observer.start()
     except OSError as e:
         # clearer error for linux
         if "inotify watch limit reached" in e:
             print e
             print "you should increase the inotify quotas"
             print
             print "   sudo sysctl fs.inotify.max_user_watches=100000"
             print "   sudo sh -c 'echo fs.inotify.max_user_watches=100000>>/etc/sysctl.conf'"
             sys.exit(1)
         else:
             raise
Ejemplo n.º 54
0
 def __init__(self, dest_dir = "/", remove_base=None):
   FileSystemEventHandler.__init__(self)
   self.dest_dir = dest_dir
   self.remove_base = remove_base
Ejemplo n.º 55
0
 def __init__(self, dbWorker):
     FileSystemEventHandler.__init__(self)
     self.__changedFiles = set()
     self.__dbWorker = dbWorker
Ejemplo n.º 56
0
 def __init__(self):
     FileSystemEventHandler.__init__(self)
     self.cache_context()
Ejemplo n.º 57
0
 def __init__(self, scriptfile='', scriptargfile=''):
     FileSystemEventHandler.__init__(self)
     self.scriptfile = scriptfile
     self.scriptargfile = scriptargfile