当前位置: 首页>>代码示例>>Python>>正文


Python events.FileSystemEventHandler类代码示例

本文整理汇总了Python中watchdog.events.FileSystemEventHandler的典型用法代码示例。如果您正苦于以下问题:Python FileSystemEventHandler类的具体用法?Python FileSystemEventHandler怎么用?Python FileSystemEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileSystemEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    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,
        }
开发者ID:Marginal,项目名称:EDMarketConnector,代码行数:60,代码来源:monitor.py

示例2: __init__

 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()
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:7,代码来源:inotify.py

示例3: watch_note

def watch_note(note, handle_func):
    """watch a single note for changes,
    call `handle_func` on change"""
    ob = Observer()
    handler = FileSystemEventHandler()
    note_filename = path.basename(note)

    def handle_event(event):
        _, filename = path.split(event.src_path)
        if note_filename == filename or \
                path.normpath(event.src_path) == path.normpath(util.assets_dir(note)):
            print('compiling...')
            handle_func(note)
            print('done')
    handler.on_any_event = handle_event

    print('watching "{0}"...'.format(note_filename))
    ob.schedule(handler, path.dirname(note), recursive=True)
    ob.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print('stopping...')
        ob.stop()
    ob.join()
开发者ID:frnsys,项目名称:nom,代码行数:27,代码来源:watch.py

示例4: __init__

    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
开发者ID:BenBBear,项目名称:pypdfocr,代码行数:7,代码来源:pypdfocr_watcher.py

示例5: __init__

    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
开发者ID:pytroll,项目名称:trollcast,代码行数:26,代码来源:oldserver.py

示例6: watch_note

def watch_note(note, handle_func):
    """watch a single note for changes,
    call `handle_func` on change"""
    ob = Observer()
    handler = FileSystemEventHandler()

    def handle_event(event):
        """update the note only if:
            - the note itself is changed
            - a referenced asset is changed
        """
        _, filename = os.path.split(event.src_path)

        # get all absolute paths of referenced images
        images = []
        for img_path in note.images:
            if not os.path.isabs(img_path):
                img_path = os.path.join(note.dir, img_path)
            images.append(img_path)

        if note.filename == filename or event.src_path in images:
            handle_func(note)
    handler.on_any_event = handle_event

    print('watching {0}...'.format(note.title))
    ob.schedule(handler, note.dir, recursive=True)
    ob.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print('stopping...')
        ob.stop()
    ob.join()
开发者ID:frnsys,项目名称:preach,代码行数:35,代码来源:watch.py

示例7: __init__

 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
开发者ID:Marginal,项目名称:EDMarketConnector,代码行数:7,代码来源:dashboard.py

示例8: __init__

 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)
开发者ID:chr15m,项目名称:rss-image-fetcher,代码行数:7,代码来源:show-image-fullscreen.py

示例9: __init__

 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()
开发者ID:prakharjoshi,项目名称:plone.app.robotframework,代码行数:7,代码来源:reload.py

示例10: __init__

 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)
开发者ID:diwa-aalto,项目名称:diwacs,代码行数:25,代码来源:handlers.py

示例11: __init__

 def __init__(self):
     """
     Constructor
     :return:
     """
     FileSystemEventHandler.__init__(self)
     self.app = app._get_current_object()
开发者ID:olavgg,项目名称:py-sth,代码行数:7,代码来源:fs_watcher.py

示例12: __init__

	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)
开发者ID:unveillance,项目名称:UnveillanceInterface,代码行数:9,代码来源:uv_annex_watcher.py

示例13: __init__

 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
开发者ID:andreaspada,项目名称:EDMarketConnector,代码行数:9,代码来源:monitor.py

示例14: on_modified

 def on_modified(self, event):
     '''
     @summary:
     ファイル更新時イベント
     ファイルのときはインデックス更新
     ディレクトリのときはファイルが追加されたときとかそういうイベントなので、無視
     '''
     if not event.is_directory:
         self.refresh_file(event.src_path)
     FileSystemEventHandler.on_created(self, event)
开发者ID:bluele,项目名称:pystol,代码行数:10,代码来源:observer.py

示例15: __init__

        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)()
开发者ID:tparker-usgs,项目名称:trollduction,代码行数:10,代码来源:trigger.py


注:本文中的watchdog.events.FileSystemEventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。