/usr/lib/python2.7/dist-packages/laditools/controller.py is in python-laditools 1.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #!/usr/bin/python
# LADITools - Linux Audio Desktop Integration Tools
# Copyright (C) 2012 Alessio Treglia <quadrispro@ubuntu.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import dbus
import sys
class LadiController(object):
"""Wrap common routines used by D-Bus objects.
It is recommended to use one of the available implementations
instead of creating instances of this class.
"""
def __init__(self, dbus_type, service_name, obj_path, iface_name, args = None):
# Connect to the bus
self.bus = getattr(dbus, dbus_type)()
self.controller_obj = self.bus.get_object (service_name, obj_path)
self.controller_iface = dbus.Interface (self.controller_obj, iface_name)
def is_available (self):
"""Check if the service is available."""
try:
self.is_started ()
return True
except Exception, err:
sys.stderr.write(str(err) + '\n')
sys.stderr.flush()
return False
def is_started (self):
"""Check if the service is running."""
return self.controller_iface.is_started ()
def start(self):
"""Start the service."""
self.controller_iface.start()
def stop(self):
"""Stop the service."""
self.controller_iface.stop()
def kill(self):
"""Kill the service."""
self.controller_iface.exit()
|