Skip to main content
Help us improve Python packaging – donate today!

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

Release history Release notifications

This version
History Node

0.1.1

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
launchd-0.1.1-py27-none-any.whl (11.5 kB) Copy SHA256 hash SHA256 Wheel 2.7 Jun 19, 2014
launchd-0.1.1-py32-none-any.whl (12.2 kB) Copy SHA256 hash SHA256 Wheel 3.2 Jun 19, 2014
launchd-0.1.1-py33-none-any.whl (11.5 kB) Copy SHA256 hash SHA256 Wheel 3.3 Jun 19, 2014
launchd-0.1.1-py3-none-any.whl (11.5 kB) Copy SHA256 hash SHA256 Wheel 3.4 Jun 19, 2014
launchd-0.1.1.tar.gz (8.3 kB) Copy SHA256 hash SHA256 Source None Nov 7, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page