Skip to main content

pythonic interface for OS X launchd

Project description

https://badge.fury.io/py/launchd.png https://pypip.in/d/launchd/badge.png

launchd is a pythonic interface to interact with OS X’s launchd. It provides access to basic querying and interaction with launchd. It is implemented using the Objective C ServiceManagement framework as well as the launchd command line utility. Therefore, this python package can only be used on OS X

The python objective C bridge contains some special types. This package strips off all non built-in type information and returns pure python data.

Examples

The relevant import statement is:

import launchd

Listing all launchd jobs:

for job in launchd.jobs():
    print(job.label, job.pid, job.status, job.properties, job.plistfilename)

Find the pid and laststatus of a job:

>>> launchd.LaunchdJob("com.apple.Finder").pid
278

>>> launchd.LaunchdJob("com.apple.Finder").laststatus
0

>>> launchd.LaunchdJob("com.example.fubar").pid
Traceback (most recent call last):
  File "launchd/launchctl.py", line 78, in refresh
    raise ValueError("job '%s' does not exist" % self.label)
ValueError: job 'com.example.fubar' does not exist

Detect if a job exists:

>>> launchd.LaunchdJob("com.example.fubar").exists()
False

launchd job properties (these come directly from launchd and NOT the .plist files):

>>> launchd.LaunchdJob("com.apple.Finder").properties
{'OnDemand': 1, 'PID': 278, 'PerJobMachServices': {'com.apple.coredrag': 0,
'com.apple.axserver': 0, 'com.apple.CFPasteboardClient': 0,
'com.apple.tsm.portname': 0}, 'LimitLoadToSessionType': 'Aqua',
'Program': '/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder',
'TimeOut': 30, 'LastExitStatus': 0, 'Label': 'com.apple.Finder',
'MachServices': {'com.apple.finder.ServiceProvider': 10}}

>>> launchd.LaunchdJob("com.apple.Finder").properties["OnDemand"]
1

Find all plist filenames of currently running jobs:

for job in launchd.jobs():
   if job.pid is None or job.plistfilename is None:
      continue
   print(job.plistfilename)

Job properties of a given job (this uses the actual .plist file):

>>> launchd.plist.read("com.apple.kextd")
{'ProgramArguments': ['/usr/libexec/kextd'], 'KeepAlive': {'SuccessfulExit': False},
'POSIXSpawnType': 'Interactive', 'MachServices': {'com.apple.KernelExtensionServer':
{'HostSpecialPort': 15}}, 'Label': 'com.apple.kextd'}

Installation

$ pip install launchd

or, if you want to work using the source tarball:

$ python setup.py install

Requirements

  • OS X >= 10.6

  • Python 2.7, 3.2 or 3.3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

launchd-0.1.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distributions

launchd-0.1.1-py33-none-any.whl (11.5 kB view details)

Uploaded Python 3.3

launchd-0.1.1-py32-none-any.whl (12.2 kB view details)

Uploaded Python 3.2

launchd-0.1.1-py27-none-any.whl (11.5 kB view details)

Uploaded Python 2.7

launchd-0.1.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file launchd-0.1.1.tar.gz.

File metadata

  • Download URL: launchd-0.1.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for launchd-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8adf0f8598ba41561578bc7f9333e74eff181ef7527dd27d0b7a2979215bc23e
MD5 cc3b413525f2450f1706204fc430a6ed
BLAKE2b-256 131c95621590729211927d715552950f13f225c5a93a07bdc720c1b0fa6ac3cd

See more details on using hashes here.

File details

Details for the file launchd-0.1.1-py33-none-any.whl.

File metadata

File hashes

Hashes for launchd-0.1.1-py33-none-any.whl
Algorithm Hash digest
SHA256 2e7e45dc386e0b3f7763275fdc6f4178b3c80d407ad9878ec03620e731405cd1
MD5 35c3c1f04eaceefc18cac2f5b9c35e4b
BLAKE2b-256 19f58277628c0d288108d8977f6f405eab4b662dd97e8925fad756f837a464e0

See more details on using hashes here.

File details

Details for the file launchd-0.1.1-py32-none-any.whl.

File metadata

File hashes

Hashes for launchd-0.1.1-py32-none-any.whl
Algorithm Hash digest
SHA256 ffc4bd0ee5070fa4c37cb4941c37be7fd1697bf1faec1497913a14cd9d2848eb
MD5 a7c531150200024c5c3783781d1b9acf
BLAKE2b-256 98e890765fee912d1af1d7b12571835ee7704c9bfeef5be2f11afd6e89b9b5f9

See more details on using hashes here.

File details

Details for the file launchd-0.1.1-py27-none-any.whl.

File metadata

File hashes

Hashes for launchd-0.1.1-py27-none-any.whl
Algorithm Hash digest
SHA256 673d5692558472ef07d535d9d8d4256eddc944fbf9b6d0e0bfff6dcd5fe946bc
MD5 c1d42b910bb1afbdcddd17a640ac35cd
BLAKE2b-256 cff3e4ec2205b4450fa1fa15628d7c72f1048e5415f299b872a4fb4c7a357487

See more details on using hashes here.

File details

Details for the file launchd-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for launchd-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 96bb25962b06a92c7e718c1db1485b5ff5c99384ed73764757ae8d63f7e78cc3
MD5 7f489e8b9cf3ce9e011cdcfe6033dfca
BLAKE2b-256 055fa793e4434beb5ee3c08cb436aaa0377e06ddde4bc2e218d4dfac58c3bb19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page