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

Class BackupMessage

web/pgadmin/tools/backup/__init__.py:83–199  ·  view source on GitHub ↗

BackupMessage(IProcessDesc) Defines the message shown for the backup operation.

Source from the content-addressed store, hash-verified

81
82
83class BackupMessage(IProcessDesc):
84 """
85 BackupMessage(IProcessDesc)
86
87 Defines the message shown for the backup operation.
88 """
89
90 def __init__(self, _type, _sid, _bfile, *_args, **_kwargs):
91 self.backup_type = _type
92 self.sid = _sid
93 self.bfile = _bfile
94 self.database = _kwargs['database'] if 'database' in _kwargs else None
95 self.cmd = ''
96 self.args_str = "{0} ({1}:{2})"
97 self.arg_list = None
98
99 def cmd_arg(x):
100 if x:
101 x = x.replace('\\', '\\\\')
102 x = x.replace('"', '\\"')
103 x = x.replace('""', '\\"')
104 return ' "' + x + '"'
105 return ''
106
107 for arg in _args:
108 if arg and len(arg) >= 2 and arg.startswith('--'):
109 self.cmd += ' ' + arg
110 else:
111 self.cmd += cmd_arg(arg)
112
113 def get_server_name(self):
114 args = self.arg_list
115 s = get_server(self.sid)
116
117 if s is None:
118 return gettext("Not available")
119
120 host, port = None, None
121
122 if args and isinstance(args, list):
123 def get_arg(val):
124 if val in args and args.index(val) + 1 < len(args):
125 return args[args.index(val) + 1]
126 return None
127 host, port = get_arg('--host'), get_arg('--port')
128 else:
129 from pgadmin.utils.driver import get_driver
130 driver = get_driver(PG_DEFAULT_DRIVER)
131 manager = driver.connection_manager(self.sid)
132
133 host = manager.local_bind_host if manager.use_ssh_tunnel \
134 else s.host
135 port = manager.local_bind_port if manager.use_ssh_tunnel \
136 else s.port
137
138 return "{0} ({1})".format(
139 s.name,
140 ': '.join(map(str, filter(None, [

Callers 3

runTestMethod · 0.90
runTestMethod · 0.90

Calls

no outgoing calls

Tested by 2

runTestMethod · 0.72
runTestMethod · 0.72