LaunchAgents + python
Project description
Install
$ [sudo] pip install mac-agents
Classes
mac_agents.Agent - launchd.plist generator
| method | __doc__ |
|---|---|
create() |
create launchd.plist file and StandardOutPath, StandardErrorPath logs |
load() |
launchctl load plist file |
read() |
return a dictionary with plist file data |
rm() |
remove plist file (if exist) |
unload() |
launchctl unload plist file |
update(**kwargs) |
update plist file data |
write(data) |
write a dictionary to a plist file |
| @property | __doc__ |
|---|---|
Label |
path.to.file.py |
ProgramArguments |
['bash','-l','-c','python $script $plist'] |
StandardErrorPath |
~/Library/Logs/LaunchAgents/$Label/err.log |
StandardOutPath |
~/Library/Logs/LaunchAgents/$Label/out.log |
WorkingDirectory |
script file dirname |
path |
plist path - file.py.plist |
script |
script path - class module file |
Functions
| function | __doc__ |
|---|---|
mac_agents.agents(path='~/Library/LaunchAgents') |
return list with launchd.plist files for .py scripts |
mac_agents.create(path) |
create launchd.plist from python file and return path |
mac_agents.jobs() |
return list with launchctl jobs (pid, status, label) |
mac_agents.scripts(path='~/Library/LaunchAgents') |
return list with *.py files |
mac_agents.tag(path='~/Library/LaunchAgents') |
set Finder tags. red - status, orange - stderr, gray - unloaded |
CLI
| usage | __doc__ |
|---|---|
python -m mac_agents.create path ... |
generate launchd.plist from python file(s) |
python -m mac_agents.tag [path] |
set Finder tags. red - status, orange - stderr, gray - unloaded |
Examples
~/Library/LaunchAgents/file.py
import mac_agents
class Agent(mac_agents.Agent):
StartInterval = 5
def run(self):
pass
if __name__ == "__main__":
Agent().run()
>>> Agent().create().load()
>>> Agent().unload().rm()
$ cd ~/Library/LaunchAgents
$ find . -name "*.py" | xargs python -m mac_agents.create "$@"
$ find ~/Library/LaunchAgents -name "*.plist" | xargs launchctl load
$ launchctl list | grep .py$
$ find ~/Library/LaunchAgents -name "*.plist" | xargs launchctl unload
$ launchctl list | grep .py$ | awk '{print $3}' | xargs -I '{}' launchctl remove {}
$ find ~/Library/LaunchAgents -type f -name "*.py.plist" -exec rm {} +
Links
readme-md - README.md generator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mac-agents-2018.12.1.tar.gz
(4.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mac-agents-2018.12.1.tar.gz.
File metadata
- Download URL: mac-agents-2018.12.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11f2f46ab0988ed8395038f719fdf58f424390b2971fa4171b93167f774012f4
|
|
| MD5 |
3b60a8015f124fad285bff81ff42e319
|
|
| BLAKE2b-256 |
63d820bba9fc5349a8ea07ea292cd4a19b75f5ad7c2a79cc327e2f7b9f5f375b
|
File details
Details for the file mac_agents-2018.12.1-py2.py3-none-any.whl.
File metadata
- Download URL: mac_agents-2018.12.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c0b240dac7ffabad76dfd1d9e896f6bb4f1b82263782d551908b89a09c6ba43
|
|
| MD5 |
9da9684288071c1ec0fa89fe5f5d4dd2
|
|
| BLAKE2b-256 |
29f1fb914bd3c31732d2abee15871617535ecfed3a2f85fbf27726f32613faa1
|