This file is indexed.

/usr/share/emma/emmalib/mysql_table.py is in emma 0.6-5.

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
# -*- coding: utf-8 -*-
# emma
#
# Copyright (C) 2006 Florian Schmidt (flo@fastflo.de)
#
# 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 Library 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 St, Fifth Floor, Boston, MA  02110-1301 USA

import sys, time

class mysql_table:
	def __init__(self, db, props, props_description):
		self.handle = db.handle
		self.host = db.host
		self.db = db
		self.props = props
		self.props_dict = dict(zip(props_description, props))
		self.name = props[0]
		self.fields = {}
		self.field_order = []
		self.expanded = False
		self.last_field_read = 0
		self.create_table = ""
		self.describe_headers = []
		
	def __getstate__(self):
		d = dict(self.__dict__)
		for i in ["handle"]:
			del d[i]
		#print "table will pickle:", d
		return d
	
	def __getitem__(self, what):
		try:
			return self.props_dict[what]
		except:
			pass
		print "property", what, "not found in table props:", self.props_dict
		
	def refresh(self, refresh_props=True):
		self.db.host.select_database(self.db)
		
		if refresh_props:
			self.host.query("show table status like '%s'" % self.name)
			result = self.handle.store_result()
			rows = result.fetch_row(0)
			self.props = rows[0]
			self.props_dict = dict(zip(map(lambda v: v[0], result.describe()), rows[0]))
			self.name = self.props[0]
		
		self.host.query("describe `%s`" % self.name)
		result = self.handle.store_result()
		self.describe_headers = []
		for h in result.describe():
			self.describe_headers.append(h[0])
		self.fields = {}
		self.field_order = []
		for row in result.fetch_row(0):
			self.field_order.append(row[0])
			self.fields[row[0]] = row
		self.last_field_read = time.time()
		return

	def __str__(self):
		output = ""
		for h, p in zip(self.db.status_headers, self.props):
			output += "\t%-25.25s: %s\n" % (h, p)
		return output
		
	def get_create_table(self):
		if not self.create_table:
			self.db.host.select_database(self.db)
			self.host.query("show create table `%s`" % self.name)
			print "create with:", self.handle
			result = self.handle.store_result()
			if not result:
				print "can't get create table for %s at %s and %s" % (self.name, self, self.handle)
				return ""
			result = result.fetch_row(0)
			self.create_table = result[0][1]
		return self.create_table