This file is indexed.

/usr/lib/python2.7/dist-packages/pybit/models.py is in pybit-common 1.0.0-2.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
import jsonpickle
import time

#       Copyright 2012:
#
#       Nick Davidson <nicholas.davidson@gmail.com>,
#       Simon Haswell <maxcady78@hotmail.co.uk>,
#       Neil Williams <codehelp@debian.org>,
#       James Bennet <github@james-bennet.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 2 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, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

# TODO: Change DB methods and associated HTTP GEThandlers to work on these JSON objects, rather than returning the raw resultsets
# themselves, which are a pain to deserialise.

# new
class Model(object):
    def toJson(self):
        try:
            return jsonpickle.encode(self)
        except Exception as e:
            raise Exception('Error in toJson(): ' + str(e))
            return None
    def fromJson(self,jsonstring):
        try:
            self = jsonpickle.decode(jsonstring)
            return self
        except Exception as e:
            raise Exception('Error in fromJson(): ' + str(e))
            return None

class JobHistory(Model):
    def __init__(self,job_id,status,buildclient,time):
        self.job_id = job_id
        self.status = status
        self.buildclient = buildclient
        self.time = str(time) #????

class ClientMessage:
    failed = "Failed"
    building = "Building"
    done = "Done"
    blocked = "Blocked"
    waiting = "Waiting"
    cancelled = "Cancelled"

class Arch(Model):
    def __init__(self,arch_id,name):
        self.id = arch_id
        self.name = name

class BuildEnv(Model):
    def __init__(self,build_env_id,name):
        self.id = build_env_id
        self.name = name

class Dist(Model):
    def __init__(self,dist_id,name):
        self.id = dist_id
        self.name = name

class Format(Model):
    def __init__(self,format_id,name):
        self.id = format_id
        self.name = name

class Status(Model):
    def __init__(self,status_id,name):
        self.id = status_id
        self.name = name

class Suite(Model):
    def __init__(self,suite_id,name):
        self.id = suite_id
        self.name = name

class BuildD(Model):
    def __init__(self,buildd_id,name):
        self.id = buildd_id
        self.name = name

class Package(Model):
    def __init__(self,package_id,version,name):
        self.id = package_id
        self.version = version
        self.name = name

class Transport(Model) :
    def __init__(self,transport_id,method,uri,vcs_id):
        self.id = transport_id
        self.method = method
        self.uri = uri
        self.vcs_id = vcs_id

class PackageInstance(Model):
    def __init__(self, packageinstance_id, package, arch, build_env, suite, distribution, pkg_format, master) :
        self.id = packageinstance_id
        self.package = package
        self.arch = arch
        self.build_env = build_env
        self.suite = suite
        self.distribution = distribution
        self.format = pkg_format
        self.master = master
        
    def get_package_name(self):
        return self.package.name
    
    def get_package_version(self):
        return self.package.version
    
    def get_arch_name(self):
        return self.arch.name
    
    def get_buildenv_name(self):
        if self.build_env is None:
            return None
        return self.build_env.name

    def get_suite_name(self):
        return self.suite.name
    
    def get_distribution_name(self):
        return self.distribution.name
    
    def get_format_name(self):
        return self.format.name


class Job(Model):
    def __init__(self,job_id,packageinstance,buildclient):
        self.id = job_id
        self.packageinstance = packageinstance
        self.buildclient = buildclient


class SuiteArch(Model):
    def __init__(self,suitearch_id,suite,arch,master_weight=0):
        self.id = suitearch_id
        self.suite = suite
        self.arch = arch
        self.master_weight = master_weight

class BuildEnvSuiteArch(Model):
    def __init__(self,buildenv_suitearch_id,buildenv,suitearch):
        self.id = buildenv_suitearch_id
        self.buildenv = buildenv
        self.suitearch = suitearch

    def get_buildenv_name(self):
        if self.buildenv is None:
            return None
        return self.buildenv.name

    def get_suite_name(self):
        if (self.suitearch is None) or (self.suitearch.suite is None):
            return None
        return self.suitearch.suite.name

    def get_arch_name(self):
        if (self.suitearch is None) or (self.suitearch.arch is None):
            return None
        return self.suitearch.arch.name
    
    def get_master_weight(self):
        if (self.suitearch is None):
            return 0
        return self.suitearch.master_weight
    
class BuildRequest(Model):
    def __init__(self,job,transport,web_host):
        self.job = job
        self.transport = transport
        self.web_host = web_host
        self.timestamp = None

    def stamp_request (self) :
        self.timestamp = int(time.time())

    def get_buildstamp (self) :
        return self.timestamp

    def get_suite(self):
        return self.job.packageinstance.suite.name

    def get_buildenv(self):
        if self.job.packageinstance.build_env is None:
            return None
        return self.job.packageinstance.build_env.name

    def get_package(self):
        return self.job.packageinstance.package.name

    def get_version(self):
        return self.job.packageinstance.package.version

    def get_arch(self):
        return self.job.packageinstance.arch.name

    def get_job_id(self):
        return self.job.id

    def get_dist(self):
        return self.job.packageinstance.distribution.name

    def get_format(self):
        return self.job.packageinstance.format.name


class AMQPConnection(object):
    def __init__(self, client_name, host, userid, password, vhost, insist=False):
        self.client_name = client_name
        self.host = host
        self.userid = userid
        self.password = password
        self.vhost = vhost
        self.insist = insist
    def as_dict(self):
        return  dict( host=self.host, userid=self.userid, password=self.password,
            virtual_host=self.vhost, insist= False )
    def __repr__(self):
        return "host: %s user id:%s password:%s vhost:%s insist: %s" % (
            self.host, self.userid, self.password, self.vhost, self.insist)



class CommandRequest(Model):
    def __init__(self,job,web_host):
        self.job = job
        self.web_host = web_host
    def get_job_id(self):
        return self.job.id

class CancelRequest(CommandRequest):
    def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)

class StatusRequest(CommandRequest):
    def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)

class TaskComplete(Model):
    def __init__(self, message, success = True):
        self.success = success
        self.message = message

def checkValue(value,container):
    if value in container and container[value] is not None and container[value] is not "":
        return True
    else:
        return False

class Blacklist(Model):
    def __init__(self,blacklist_id,field,regex):
        self.id = blacklist_id
        self.field = field
        self.regex = regex