This file is indexed.

/usr/share/pyshared/JobsAdmin/remote.py is in jobs-admin 0.8.0-0ubuntu4.

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
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This file is part of jobs-admin.
# Copyright 2010 Jacob Peddicord <jpeddicord@ubuntu.com>
#
# jobs-admin 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.
#
# jobs-admin 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 jobs-admin.  If not, see <http://www.gnu.org/licenses/>.

from dbus import SystemBus, Interface, PROPERTIES_IFACE
from JobsAdmin.overrides import is_protected, alt_description
from JobsAdmin.util import LANG, retry


class RemoteJobService:
    
    def __init__(self):
        self.jobs = {}
        self._connect()
        
    def _connect(self):
        self.bus = SystemBus()
        self.jobservice = Interface(self.bus.get_object(
                'com.ubuntu.JobService', '/com/ubuntu/JobService'),
                'com.ubuntu.JobService')
    
    def get_all_jobs(self, protect=True):
        self.jobs = {}
        def call(): return self.jobservice.GetAllJobs()
        alljobs = retry(self._connect, call)
        for job, path in alljobs:
            protected = is_protected(job)
            if not protect or not protected:
                self.jobs[job] = RemoteJob(job, path)
                self.jobs[job].protected = protected
        return self.jobs
    
class RemoteJob:
    """
    A proxy object for a single job. DBus properties are accessible via
    regular Python properties.
    """
    
    def __init__(self, name, path):
        self.name = name
        self.path = path
        self.props = {}
        self.protected = False
        self._connect()
        
    def _connect(self):
        self.bus = SystemBus()
        self.obj = self.bus.get_object('com.ubuntu.JobService', self.path)
        self.interface = Interface(self.obj, 'com.ubuntu.JobService.Job')
    
    def __getattr__(self, name):
        if not self.props:
            def call():
                self.props = self.obj.GetAll('com.ubuntu.JobService.Job',
                        dbus_interface=PROPERTIES_IFACE)
            retry(self._connect, call)
        # override description
        if name == 'description':
            alt = alt_description(self.name)
            if alt:
                return alt
        return self.props[name]
    
    def start(self, reply_handler=None, error_handler=None):
        def call(): self.interface.Start(timeout=500,
                reply_handler=reply_handler, error_handler=error_handler)
        retry(self._connect, call)
        self.props = {} # states may change
    
    def stop(self, reply_handler=None, error_handler=None):
        def call(): self.interface.Stop(timeout=500,
                reply_handler=reply_handler, error_handler=error_handler)
        retry(self._connect, call)
        self.props = {}
    
    def enable(self, reply_handler=None, error_handler=None):
        def call(): self.interface.SetAutomatic(True, timeout=500,
                reply_handler=reply_handler, error_handler=error_handler)
        retry(self._connect, call)
        self.props = {}
    
    def disable(self, reply_handler=None, error_handler=None):
        def call(): self.interface.SetAutomatic(False, timeout=500,
                reply_handler=reply_handler, error_handler=error_handler)
        retry(self._connect, call)
        self.props = {}
    
    def get_settings(self, reply_handler=None, error_handler=None):
        if '_settings' in self.props:
            return self.props['_settings']
        def call():
            self.props['_settings'] = self.interface.GetSettings(LANG,
                timeout=500,
                reply_handler=reply_handler, error_handler=error_handler)
            return self.props['_settings']
        return retry(self._connect, call)
        
    def set_settings(self, settings, reply_handler=None, error_handler=None):
        def call(): self.interface.SetSettings(settings, timeout=500,
                reply_handler=reply_handler, error_handler=error_handler)
        retry(self._connect, call)
        self.props = {}