This file is indexed.

/usr/lib/python2.7/dist-packages/pysearpc/client.py is in python-searpc 3.0.8-1.

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
115
116
117
118
119
120
121
122
import json
from common import SearpcError

def _fret_int(ret_str):
    try:
        dicts = json.loads(ret_str)
    except:
        raise SearpcError('Invalid response format')

    if dicts.has_key('err_code'):
        raise SearpcError(dicts['err_msg'])

    if dicts.has_key('ret'):
        return dicts['ret']
    else:
        raise SearpcError('Invalid response format')

def _fret_string(ret_str):
    try:
        dicts = json.loads(ret_str)
    except:
        raise SearpcError('Invalid response format')

    if dicts.has_key('err_code'):
        raise SearpcError(dicts['err_msg'])

    if dicts.has_key('ret'):
        return dicts['ret']
    else:
        raise SearpcError('Invalid response format')

class _SearpcObj(object):
    '''A compact class to emulate gobject.GObject
    '''
    def __init__(self, dicts):
        new_dict = {}
        for key in dicts:
            value = dicts[key]
            # replace hyphen with with underline
            new_key = key.replace('-', '_')
            new_dict[new_key] = value
        # For compatibility with old usage peer.props.name
        self.props = self
        self._dict = new_dict

    def __getattr__(self, key):
        try:
            return self._dict[key]
        except:
            return None

class SearpcObjEncoder(json.JSONEncoder):
    def default(self, obj):
        if not isinstance(obj, _SearpcObj):
            return super(SearpcObjEncoder, self).default(obj)
        return obj._dict

def _fret_obj(ret_str):
    try:
        dicts = json.loads(ret_str)
    except:
        raise SearpcError('Invalid response format')

    if dicts.has_key('err_code'):
        raise SearpcError(dicts['err_msg'])

    if dicts['ret']:
        return _SearpcObj(dicts['ret'])
    else:
        return None

def _fret_objlist(ret_str):
    try:
        dicts = json.loads(ret_str)
    except:
        raise SearpcError('Invalid response format')

    if dicts.has_key('err_code'):
        raise SearpcError(dicts['err_msg'])

    l = []
    if dicts['ret']:
        for elt in dicts['ret']:
            l.append(_SearpcObj(elt))

    return l


def searpc_func(ret_type, param_types):

    def decorate(func):
        if ret_type == "void":
            fret = None
        elif ret_type == "object":
            fret = _fret_obj
        elif ret_type == "objlist":
            fret = _fret_objlist
        elif ret_type == "int":
            fret = _fret_int
        elif ret_type == "int64":
            fret = _fret_int
        elif ret_type == "string":
            fret = _fret_string
        else:
            raise SearpcError('Invial return type')

        def newfunc(self, *args):
            array = [func.__name__] + list(args)
            fcall_str = json.dumps(array)
            ret_str = self.call_remote_func_sync(fcall_str)
            if fret:
                return fret(ret_str)

        return newfunc

    return decorate


class SearpcClient(object):

    def call_remote_func_sync(self, fcall_str):
        raise NotImplementedError()