launchd.plist模型
项目描述
安装
$ [sudo] pip install django-launchd
settings.py
INSTALLED_APPS = [
"django_launchd",
]
模型
模型 | __doc__ |
---|---|
django_launchd.models.Plist |
launchd.plist模型。字段:path |
django_launchd.models.Lock |
launchd.plist锁类。字段:plist (外键),key |
示例
init
import django_launchd
from django_launchd.models import Plist
files = django_launchd.files("~/Library/LaunchAgents")
for f in files:
Plist.objects.get_or_create(path=f)
Plist.objects.exclude(path__in=files).delete()
locks
for agent in filter(lambda a: a.exists, Plist.objects.all()):
if <condition>:
agent.lock("key")
else:
agent.unlock("key")
加载/卸载
for agent in filter(lambda a: a.exists, Plist.objects.all()):
if agent.locks:
agent.unload()
else:
agent.load()