MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / status

Method status

web/pgadmin/misc/bgprocess/processes.py:578–645  ·  view source on GitHub ↗
(self, out=0, err=0)

Source from the content-addressed store, hash-verified

576 return True, {}
577
578 def status(self, out=0, err=0):
579 ctime = get_current_time(format='%y%m%d%H%M%S%f')
580
581 stdout = []
582 stderr = []
583 out_completed = err_completed = False
584 process_output = (out != -1 and err != -1)
585
586 j = Process.for_user(pid=self.id).first()
587 enc = sys.getdefaultencoding()
588 if enc == 'ascii':
589 enc = 'utf-8'
590
591 execution_time = None
592
593 if j is not None:
594 _, updated = BatchProcess.update_process_info(j)
595 if updated:
596 db.session.commit()
597 self.stime = j.start_time
598 self.etime = j.end_time
599 self.ecode = j.exit_code
600
601 if self.stime is not None:
602 stime = parser.parse(self.stime)
603 etime = parser.parse(self.etime or get_current_time())
604
605 execution_time = BatchProcess.total_seconds(etime - stime)
606
607 if process_output:
608 out, out_completed = self.read_log(
609 self.stdout, stdout, out, ctime, self.ecode, enc
610 )
611 err, err_completed = self.read_log(
612 self.stderr, stderr, err, ctime, self.ecode, enc
613 )
614 else:
615 out_completed = err_completed = False
616
617 if out == -1 or err == -1:
618 return {
619 'start_time': self.stime,
620 'exit_code': self.ecode,
621 'execution_time': execution_time,
622 'process_state': self.process_state
623 }
624
625 # Get the error message based on exit code.
626 if err_completed and self.ecode != 0 and self.ecode is not None:
627 err_msg = get_error_msg(self.cmd, self.ecode)
628 # This should be the last line as added 'Z' for sorting.
629 stderr.append(['Z', err_msg])
630
631 return {
632 'out': {
633 'pos': out,
634 'lines': stdout,
635 'done': out_completed

Callers 1

statusFunction · 0.95

Calls 8

read_logMethod · 0.95
get_error_msgFunction · 0.85
for_userMethod · 0.80
update_process_infoMethod · 0.80
total_secondsMethod · 0.80
appendMethod · 0.80
get_current_timeFunction · 0.70
firstMethod · 0.65

Tested by

no test coverage detected