Skip to content

Commit 16e3362

Browse files
committed
changed parameter name 'load' to 'query'. more examples in readme
1 parent e7fea91 commit 16e3362

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

README.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
python-launchd - pythonic interface for launchd
2-
================================================
2+
===============================================
33

44
.. image:: https://badge.fury.io/py/launchd.png
55
:target: http://badge.fury.io/py/launchd
@@ -37,20 +37,24 @@ Listing all launchd jobs:
3737
3838
3939
Detecting launchd runtime properties based on a label works by manually
40-
instantiating a LaunchdJob instance and loading its properties, either by
41-
specifying 'load' in the constructor or calling .refresh():
40+
instantiating a LaunchdJob instance and querying its properties, either by
41+
specifying 'query' in the constructor or calling .refresh():
4242

4343
.. code-block:: python
4444
45-
finder = launchd.LaunchdJob("com.apple.Finder", load=True)
46-
print(finder.pid)
45+
# PID of Finder
46+
print(launchd.LaunchdJob("com.apple.Finder", query=True).pid)
4747
48-
fubar = launchd.LaunchdJob("com.apple.Fubar")
49-
if fubar.exists():
50-
fubar.refresh()
48+
# Detecting if a job is defined
49+
if launchd.LaunchdJob("com.apple.Fubar").exists():
50+
print("OK")
5151
else:
5252
print("No such launchd job: %s" % fubar.label)
5353
54+
# arbitrary launchd property querying:
55+
print(launchd.LaunchdJob("com.apple.Finder").properties["OnDemand"])
56+
57+
5458
Find all plist filenames of currently running jobs:
5559

5660
.. code-block:: python

launchd/launchctl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
class LaunchdJob(object):
1111
'''
12-
Custom class that allows us to lazily load the properties
12+
Custom class that allows us to lazily query the properties
1313
of the LaunchdJob when accessed.
1414
'''
15-
def __init__(self, label, pid=None, laststatus=None, load=False):
15+
def __init__(self, label, pid=None, laststatus=None, query=False):
1616
'''
1717
Instantiate a LaunchdJob instance. Only the label is truly required.
1818
If no pid or laststatus are specified, they will be detected during
@@ -21,10 +21,10 @@ def __init__(self, label, pid=None, laststatus=None, load=False):
2121
:param label: required string job label
2222
:param pid: optional int, if known. Can be None.
2323
:param laststatus: optional int, if known. Can be None.
24-
:param load: boolean. Load job details from launchd during construction.
24+
:param query: boolean. Query job details from launchd during construction.
2525
'''
2626
self._label = label
27-
if load:
27+
if query:
2828
self.refresh()
2929
else:
3030
self._pid = pid

0 commit comments

Comments
 (0)