Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Add property for dbus unit path and add get_service* Manager helper m… #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
python-systemd
==============
python-systemd-dbus
===================

python-systemd python wrapper for `systemd`_ system and session manager dbus
python-systemd-dbus python wrapper for `systemd`_ system and session manager dbus
interfaces.

.. systemd: http://www.freedesktop.org/wiki/Software/systemd
Expand All @@ -12,16 +12,16 @@ Basic usage
Import and create a `manager`:

```
>>> from systemd.manager import Manager
>>> from systemd_dbus.manager import Manager
>>> manager = Manager()
```

List all units:

```
>>> for unit in manager.list_units():
... print unit.properties.Id
... print unit.properties.Description
... print(unit.properties.Id)
... print(unit.properties.Description)
...
nfs-server.service
LSB: Kernel NFS server support
Expand All @@ -43,21 +43,21 @@ Get an unit:
`crond` is running:

```
>>> print unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState
>>> print(unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState)
loaded active running
```

Let's stop `crond`:

```
>>> unit.stop('fail')
<systemd.job.Job object at 0x7fa57ba03a90>
<systemd_dbus.job.Job object at 0x7fa57ba03a90>
```

Is crond running? why I stop it!!:

```
>>> print unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState
>>> print(unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState)
loaded active running
```

Expand All @@ -73,21 +73,21 @@ KeyboardInterrupt
Now Unit properties is updated!:

```
>>> print unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState
>>> print(unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState)
loaded inactive dead
```

Let's start `crond`:

```
>>> unit.start('fail')
<systemd.job.Job object at 0x7fa57ba03950>
<systemd_dbus.job.Job object at 0x7fa57ba03950>
```

Remember we want o loop!:

```
>>> print unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState
>>> print(unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState)
loaded inactive dead
```

Expand All @@ -102,6 +102,6 @@ KeyboardInterrupt
Updated!:

```
>>> print unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState
>>> print(unit.properties.LoadState, unit.properties.ActiveState, unit.properties.SubState)
loaded active running
```
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TODO
====

This is todo file for python-systemd.
This is todo file for python-systemd-dbus.

CODE
====
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from distutils.core import setup
import os

from systemd import get_version
from systemd_dbus import get_version


# Compile the list of packages available, because distutils doesn't have
Expand All @@ -11,7 +11,7 @@
if root_dir:
os.chdir(root_dir)

for dirpath, dirnames, filenames in os.walk('systemd'):
for dirpath, dirnames, filenames in os.walk('systemd_dbus'):
# Ignore dirnames that start with '.'
for i, dirname in enumerate(dirnames):
if dirname.startswith('.'): del dirnames[i]
Expand All @@ -26,20 +26,20 @@
data_files.append(os.path.join(prefix, f))


setup(name='python-systemd',
setup(name='python-systemd-dbus',
version=get_version().replace(' ', '-'),
description='Systemd interfaces wrapper',
author='Wiliam Souza',
author_email='[email protected]',
url='',
download_url='',
package_dir={'systemd': 'systemd'},
package_dir={'systemd_dbus': 'systemd_dbus'},
packages=packages,
package_data={'systemd': data_files},
package_data={'systemd_dbus': data_files},
classifiers=['Development Status :: 1 - Planning',
'Intended Audience :: Developers',
'License :: ',
'Operating System :: POSIX :: Linux',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Topic :: Libraries :: Python Modules',]
)
Expand Down
12 changes: 0 additions & 12 deletions systemd/__init__.py

This file was deleted.

5 changes: 5 additions & 0 deletions systemd_dbus/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VERSION = (0, 1)

def get_version():
version = '%s.%s' % (VERSION[0], VERSION[1])
return version
10 changes: 5 additions & 5 deletions systemd/automount.py → systemd_dbus/automount.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Copyright (c) 2010 Mandriva
#
# This file is part of python-systemd.
# This file is part of python-systemd-dbus.
#
# python-systemd is free software; you can redistribute it and/or modify
# python-systemd-dbus is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# python-systemd is distributed in the hope that it will be useful,
# python-systemd-dbus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
Expand All @@ -21,8 +21,8 @@
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

from systemd.property import Property
from systemd.exceptions import SystemdError
from systemd_dbus.property import Property
from systemd_dbus.exceptions import SystemdError

class Automount(object):
"""Abstraction class to org.freedesktop.systemd1.Automount interface"""
Expand Down
10 changes: 5 additions & 5 deletions systemd/device.py → systemd_dbus/device.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Copyright (c) 2010 Mandriva
#
# This file is part of python-systemd.
# This file is part of python-systemd-dbus.
#
# python-systemd is free software; you can redistribute it and/or modify
# python-systemd-dbus is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# python-systemd is distributed in the hope that it will be useful,
# python-systemd-dbus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
Expand All @@ -21,8 +21,8 @@
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

from systemd.property import Property
from systemd.exceptions import SystemdError
from systemd_dbus.property import Property
from systemd_dbus.exceptions import SystemdError

class Device(object):
"""Abstraction class to org.freedesktop.systemd1.Device interface"""
Expand Down
6 changes: 3 additions & 3 deletions systemd/exceptions.py → systemd_dbus/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Copyright (c) 2010 Mandriva
#
# This file is part of python-systemd.
# This file is part of python-systemd-dbus.
#
# python-systemd is free software; you can redistribute it and/or modify
# python-systemd-dbus is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# python-systemd is distributed in the hope that it will be useful,
# python-systemd-dbus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
Expand Down
12 changes: 6 additions & 6 deletions systemd/job.py → systemd_dbus/job.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Copyright (c) 2010 Mandriva
#
# This file is part of python-systemd.
# This file is part of python-systemd-dbus.
#
# python-systemd is free software; you can redistribute it and/or modify
# python-systemd-dbus is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# python-systemd is distributed in the hope that it will be useful,
# python-systemd-dbus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
Expand All @@ -21,8 +21,8 @@
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

from systemd.property import Property
from systemd.exceptions import SystemdError
from systemd_dbus.property import Property
from systemd_dbus.exceptions import SystemdError

class Job(object):
"""Abstraction class to org.freedesktop.systemd1.Job interface"""
Expand Down Expand Up @@ -61,5 +61,5 @@ def __properties(self):
def cancel(self):
try:
self.__interface.Cancel()
except dbus.exceptions.DBusException, error:
except dbus.exceptions.DBusException as error:
raise SystemdError(error)
Loading