Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9794b89b5a
|
||
|
|
8445ca7cb4
|
||
|
|
75241f60f4
|
||
|
|
99724905be
|
||
|
|
34ac9cd596
|
||
|
|
5b589cc999
|
@@ -73,7 +73,8 @@ task_sched = TaskScheduler(
|
|||||||
### ShellScheduler
|
### ShellScheduler
|
||||||
Schedule a shell command *cmd*. Replace **{maskname}**, **{pathname}** and **{src_pathname}** in *cmd* with the actual values of occuring events. This scheduler is based on TaskScheduler and has the same optional arguments.
|
Schedule a shell command *cmd*. Replace **{maskname}**, **{pathname}** and **{src_pathname}** in *cmd* with the actual values of occuring events. This scheduler is based on TaskScheduler and has the same optional arguments.
|
||||||
```python
|
```python
|
||||||
# Please note that **{src_pathname}** is only present for IN_MOVED_TO events and only in the case where the IN_MOVED_FROM events are watched too.
|
# Please note that **{src_pathname}** is only present for IN_MOVED_TO events and only
|
||||||
|
# in the case where the IN_MOVED_FROM events are watched too.
|
||||||
# If it is not present, the command line argument will be an empty string.
|
# If it is not present, the command line argument will be an empty string.
|
||||||
shell_sched = ShellScheduler(
|
shell_sched = ShellScheduler(
|
||||||
cmd="/usr/local/bin/task.sh {maskname} {pathname} {src_pathname}")
|
cmd="/usr/local/bin/task.sh {maskname} {pathname} {src_pathname}")
|
||||||
@@ -129,7 +130,7 @@ event_map = {
|
|||||||
"IN_Q_OVERFLOW": None,
|
"IN_Q_OVERFLOW": None,
|
||||||
"IN_UNMOUNT": Cancel(task_sched)}
|
"IN_UNMOUNT": Cancel(task_sched)}
|
||||||
|
|
||||||
# It is possible to instantiate an event map with a default scheduler set for every event,
|
# It is possible to instantiate an event map with a default scheduler set for every event
|
||||||
event_map = EventMap(default_sched=task_sched)
|
event_map = EventMap(default_sched=task_sched)
|
||||||
```
|
```
|
||||||
The following events are available:
|
The following events are available:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ from pyinotify import ProcessEvent
|
|||||||
from pyinotifyd._install import install, uninstall
|
from pyinotifyd._install import install, uninstall
|
||||||
from pyinotifyd.scheduler import TaskScheduler, Cancel
|
from pyinotifyd.scheduler import TaskScheduler, Cancel
|
||||||
|
|
||||||
__version__ = "0.0.4"
|
__version__ = "0.0.5"
|
||||||
|
|
||||||
|
|
||||||
def setLoglevel(loglevel, logname=None):
|
def setLoglevel(loglevel, logname=None):
|
||||||
@@ -436,15 +436,14 @@ def main():
|
|||||||
ch.setFormatter(formatter)
|
ch.setFormatter(formatter)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
for signame in ["SIGINT", "SIGTERM"]:
|
|
||||||
loop.add_signal_handler(
|
loop.add_signal_handler(
|
||||||
getattr(signal, signame),
|
signal.SIGTERM, lambda: loop.create_task(
|
||||||
lambda: loop.create_task(
|
daemon.shutdown("SIGTERM")))
|
||||||
daemon.shutdown(signame)))
|
|
||||||
|
|
||||||
loop.add_signal_handler(
|
loop.add_signal_handler(
|
||||||
getattr(signal, "SIGHUP"),
|
signal.SIGINT, lambda: loop.create_task(
|
||||||
lambda: loop.create_task(
|
daemon.shutdown("SIGINT")))
|
||||||
|
loop.add_signal_handler(
|
||||||
|
signal.SIGHUP, lambda: loop.create_task(
|
||||||
daemon.reload("SIGHUP", args.config, args.debug)))
|
daemon.reload("SIGHUP", args.config, args.debug)))
|
||||||
|
|
||||||
daemon.start()
|
daemon.start()
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from inspect import iscoroutinefunction
|
from inspect import iscoroutinefunction
|
||||||
from shlex import quote as shell_quote
|
from shlex import quote as shell_quote
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@@ -46,11 +45,11 @@ class SchedulerLogger(logging.LoggerAdapter):
|
|||||||
|
|
||||||
class TaskScheduler:
|
class TaskScheduler:
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class TaskState:
|
class TaskState:
|
||||||
id: str = str(uuid4())
|
def __init__(self, id=None, task=None, cancelable=True):
|
||||||
task: asyncio.Task = None
|
self.id = id or str(uuid4())
|
||||||
cancelable: bool = True
|
self.task = task
|
||||||
|
self.cancelable = cancelable
|
||||||
|
|
||||||
def __init__(self, job, files=True, dirs=False, delay=0, logname="sched",
|
def __init__(self, job, files=True, dirs=False, delay=0, logname="sched",
|
||||||
loop=None):
|
loop=None):
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ setup(name = "pyinotifyd",
|
|||||||
# 3 - Alpha
|
# 3 - Alpha
|
||||||
# 4 - Beta
|
# 4 - Beta
|
||||||
# 5 - Production/Stable
|
# 5 - Production/Stable
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 4 - Beta",
|
||||||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
|
|||||||
Reference in New Issue
Block a user