MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / Message

Class Message

web/pgadmin/tools/maintenance/__init__.py:52–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51
52class Message(IProcessDesc):
53 def __init__(self, _sid, _data, _query):
54 self.sid = _sid
55 self.data = _data
56 self.query = _query
57
58 def get_server_name(self):
59 s = get_server(self.sid)
60
61 if s is None:
62 return _("Not available")
63
64 from pgadmin.utils.driver import get_driver
65 driver = get_driver(PG_DEFAULT_DRIVER)
66 manager = driver.connection_manager(self.sid)
67
68 host = manager.local_bind_host if manager.use_ssh_tunnel else s.host
69 port = manager.local_bind_port if manager.use_ssh_tunnel else s.port
70
71 return "{0} ({1}:{2})".format(s.name, host, port)
72
73 def get_object_msg(self):
74 msg = _("on database '{0}'").format(self.data['database'])
75 if 'primary_key' in self.data or 'unique_constraint' in self.data:
76 msg = _("on constraint '{0}/{1}/{2}/{3}'").format(
77 self.data['database'], self.data['schema'], self.data['table'],
78 self.data['primary_key'] if 'primary_key' in self.data else
79 self.data['unique_constraint'])
80 elif 'index' in self.data:
81 msg = _("on index '{0}/{1}/{2}/{3}'").format(
82 self.data['database'], self.data['schema'],
83 self.data['table'], self.data['index'])
84 elif 'table' in self.data:
85 msg = _("on table '{0}/{1}/{2}'").format(
86 self.data['database'], self.data['schema'], self.data['table'])
87 elif 'schema' in self.data:
88 msg = _("on schema '{0}/{1}'").format(self.data['database'],
89 self.data['schema'])
90 return msg
91
92 @property
93 def message(self):
94 op = _('VACUUM')
95 if self.data['op'] == "ANALYZE":
96 op = _('ANALYZE')
97 elif self.data['op'] == "REINDEX" and 'schema' not in self.data:
98 op = _('REINDEX')
99 elif self.data['op'] == "REINDEX" and 'schema' in self.data:
100 if 'primary_key' in self.data or 'unique_constraint' in self.data\
101 or 'index' in self.data:
102 op = _('REINDEX INDEX')
103 elif 'table' in self.data:
104 op = _('REINDEX TABLE')
105 else:
106 op = _('REINDEX SCHEMA')
107 elif self.data['op'] == "CLUSTER":
108 op = _('CLUSTER')
109

Callers 3

runTestMethod · 0.90
runTestMethod · 0.90
create_maintenance_jobFunction · 0.70

Calls

no outgoing calls

Tested by 2

runTestMethod · 0.72
runTestMethod · 0.72