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

Class BatchProcess

web/pgadmin/misc/bgprocess/processes.py:132–909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130
131
132class BatchProcess:
133 def __init__(self, **kwargs):
134
135 self.id = self.desc = self.cmd = self.args = self.log_dir = \
136 self.stdout = self.stderr = self.stime = self.etime = \
137 self.ecode = self.manager_obj = None
138 self.env = dict()
139
140 if 'id' in kwargs:
141 self._retrieve_process(kwargs['id'])
142 else:
143 _cmd = kwargs['cmd']
144 # Get system's interpreter
145 if kwargs['cmd'] == 'python':
146 _cmd = self._get_python_interpreter()
147
148 self._create_process(
149 kwargs['desc'], _cmd, kwargs['args']
150 )
151
152 if 'manager_obj' in kwargs:
153 self.manager_obj = kwargs['manager_obj']
154
155 def _retrieve_process(self, _id):
156 p = Process.for_user(pid=_id).first()
157
158 if p is None:
159 raise LookupError(PROCESS_NOT_FOUND)
160
161 try:
162 tmp_desc = loads(bytes.fromhex(p.desc))
163 except Exception:
164 tmp_desc = loads(p.desc)
165
166 # ID
167 self.id = _id
168 # Description
169 self.desc = tmp_desc
170 # Status Acknowledged time
171 self.atime = p.acknowledge
172 # Command
173 self.cmd = p.command
174 # Arguments
175 self.args = p.arguments
176 # Log Directory
177 self.log_dir = p.logdir
178 # Standard ouput log file
179 self.stdout = os.path.join(p.logdir, 'out')
180 # Standard error log file
181 self.stderr = os.path.join(p.logdir, 'err')
182 # Start time
183 self.stime = p.start_time
184 # End time
185 self.etime = p.end_time
186 # Exit code
187 self.ecode = p.exit_code
188 # Process State
189 self.process_state = p.process_state

Callers 14

refresh_dataMethod · 0.90
create_restore_jobFunction · 0.90
runTestMethod · 0.90
create_maintenance_jobFunction · 0.90
runTestMethod · 0.90
runTestMethod · 0.90
create_import_export_jobFunction · 0.90
runTestMethod · 0.90
deploy_on_azureFunction · 0.90
deploy_on_googleFunction · 0.90
deploy_on_rdsFunction · 0.90

Calls

no outgoing calls

Tested by 4

runTestMethod · 0.72
runTestMethod · 0.72
runTestMethod · 0.72
runTestMethod · 0.72