Python return code
31 Python code examples are found related to "
return code".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: downloads.py From tartube with GNU General Public License v3.0 | 6 votes |
def set_return_code(self, code): """Called by self.do_download(), .create_child_process(), .extract_stdout_status() and .stop(). Based on YoutubeDLDownloader._set_returncode(). After the child process has terminated with an error of some kind, sets a new value for self.return_code, but only if the new return code is higher in the hierarchy of return codes than the current value. Args: code (int): A return code in the range 0-5 """ if DEBUG_FUNC_FLAG: utils.debug_time('dld 3912 set_return_code') if code >= self.return_code: self.return_code = code
Example 2
Source File: build_tools.py From arnold-usd with Apache License 2.0 | 6 votes |
def process_return_code(retcode): ''' translates a process return code (as obtained by os.system or subprocess) into a status string ''' if retcode == 0: status = 'OK' else: if system.is_windows: if retcode < 0: status = 'CRASHED' else: status = 'FAILED' else: # When a signal "N" is raised, the process can # return with status "128 + N" or "-N" if retcode > 128 or retcode < 0: status = 'CRASHED' else: status = 'FAILED' return status ## Searches for file in the system path. Returns a list of directories containing file
Example 3
Source File: build_tools.py From sitoa with Apache License 2.0 | 6 votes |
def process_return_code(retcode): if retcode == 0: status = 'OK' else: if system.os() == 'windows': if retcode < 0: status = 'CRASHED' else: status = 'FAILED' else: if retcode > 128: status = 'CRASHED' else: status = 'FAILED' return status # returns the softimage version
Example 4
Source File: sut_code_measure_dot_coverage_file.py From iust_deep_fuzz with MIT License | 6 votes |
def pass_rate_by_check_return_code(): passed_pdfs = 0 total_pdfs = 0 for filename in os.listdir(pdf_corpus_config['corpus_merged']): cmd = iu_config['sut_path'] + iu_config['sut_arguments'] + pdf_corpus_config['corpus_merged'] + filename # cmd = 'D:/afl/mupdf/platform/win32/Release/mutool.exe clean -difa D:/iust_pdf_corpus/corpus_merged/pdftc_mozilla_0333.pdf' print(cmd) x = subprocess.run(cmd, shell=True) # print(x.stderr) # print(20*'---') # print(x.returncode) total_pdfs += 1 if x.returncode == 0: passed_pdfs += 1 # input() print('passed_pdfs: %s out of %s' % (passed_pdfs, total_pdfs)) print('pass_rate percentage:', (100 * passed_pdfs)/total_pdfs)
Example 5
Source File: paasta_metastatus_steps.py From paasta with Apache License 2.0 | 6 votes |
def check_metastatus_return_code_with_flags( context, flags, expected_return_code, expected_output ): # We don't want to invoke the "paasta metastatus" wrapper because by # default it will check every cluster. This is also the way sensu invokes # this check. cmd = "python -m paasta_tools.paasta_metastatus%s" % flags print("Running cmd %s" % (cmd)) exit_code, output = _run(cmd) # we don't care about the colouring here, so remove any ansi escape sequences escaped_output = remove_ansi_escape_sequences(output) print(f"Got exitcode {exit_code} with output:\n{output}") print() assert exit_code == int(expected_return_code) assert expected_output in escaped_output
Example 6
Source File: CommandHelper.py From stonix with GNU General Public License v2.0 | 5 votes |
def getReturnCode(self): """Get return code for last executed command :returns: self.returncode :rtype: int @author: ekkehard j. koch """ return self.returncode
Example 7
Source File: cat_client.py From tencentcloud-cli with Apache License 2.0 | 5 votes |
def doGetReturnCodeInfo(argv, arglist): g_param = parse_global_arg(argv) if "help" in argv: show_help("GetReturnCodeInfo", g_param[OptionsDefine.Version]) return param = { "TaskId": Utils.try_to_json(argv, "--TaskId"), "BeginTime": argv.get("--BeginTime"), "EndTime": argv.get("--EndTime"), "Province": argv.get("--Province"), } cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey]) http_profile = HttpProfile( reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]), reqMethod="POST", endpoint=g_param[OptionsDefine.Endpoint] ) profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256") mod = CLIENT_MAP[g_param[OptionsDefine.Version]] client = mod.CatClient(cred, g_param[OptionsDefine.Region], profile) client._sdkVersion += ("_CLI_" + __version__) models = MODELS_MAP[g_param[OptionsDefine.Version]] model = models.GetReturnCodeInfoRequest() model.from_json_string(json.dumps(param)) rsp = client.GetReturnCodeInfo(model) result = rsp.to_json_string() jsonobj = None try: jsonobj = json.loads(result) except TypeError as e: jsonobj = json.loads(result.decode('utf-8')) # python3.3 FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
Example 8
Source File: cat_client.py From tencentcloud-cli with Apache License 2.0 | 5 votes |
def doGetReturnCodeHistory(argv, arglist): g_param = parse_global_arg(argv) if "help" in argv: show_help("GetReturnCodeHistory", g_param[OptionsDefine.Version]) return param = { "TaskId": Utils.try_to_json(argv, "--TaskId"), "BeginTime": argv.get("--BeginTime"), "EndTime": argv.get("--EndTime"), "Province": argv.get("--Province"), } cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey]) http_profile = HttpProfile( reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]), reqMethod="POST", endpoint=g_param[OptionsDefine.Endpoint] ) profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256") mod = CLIENT_MAP[g_param[OptionsDefine.Version]] client = mod.CatClient(cred, g_param[OptionsDefine.Region], profile) client._sdkVersion += ("_CLI_" + __version__) models = MODELS_MAP[g_param[OptionsDefine.Version]] model = models.GetReturnCodeHistoryRequest() model.from_json_string(json.dumps(param)) rsp = client.GetReturnCodeHistory(model) result = rsp.to_json_string() jsonobj = None try: jsonobj = json.loads(result) except TypeError as e: jsonobj = json.loads(result.decode('utf-8')) # python3.3 FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
Example 9
Source File: cat_client.py From tencentcloud-sdk-python with Apache License 2.0 | 5 votes |
def GetReturnCodeHistory(self, request): """查询拨测任务的历史返回码信息 :param request: Request instance for GetReturnCodeHistory. :type request: :class:`tencentcloud.cat.v20180409.models.GetReturnCodeHistoryRequest` :rtype: :class:`tencentcloud.cat.v20180409.models.GetReturnCodeHistoryResponse` """ try: params = request._serialize() body = self.call("GetReturnCodeHistory", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.GetReturnCodeHistoryResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
Example 10
Source File: cat_client.py From tencentcloud-sdk-python with Apache License 2.0 | 5 votes |
def GetReturnCodeInfo(self, request): """查询拨测任务的返回码统计信息 :param request: Request instance for GetReturnCodeInfo. :type request: :class:`tencentcloud.cat.v20180409.models.GetReturnCodeInfoRequest` :rtype: :class:`tencentcloud.cat.v20180409.models.GetReturnCodeInfoResponse` """ try: params = request._serialize() body = self.call("GetReturnCodeInfo", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.GetReturnCodeInfoResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
Example 11
Source File: ts3lib.py From pyTSon_plugins with GNU General Public License v3.0 | 5 votes |
def createReturnCode(maxLen=128): """ Creates a returnCode which can be passed to the other functions and will be passed to the event onServerErrorEvent. @param maxLen: length of the buffer, passed to the clientlib to store the path to, default value is 256 @type maxLen: int @return: the created returnCode @rtype: string """ return ""
Example 12
Source File: chromium_step.py From sanitizers with Apache License 2.0 | 5 votes |
def handleReturnCode(self, return_code): # Treat all non-zero return codes as failure. # We could have a special return code for warnings/exceptions, however, # this might conflict with some existing use of a return code. # Besides, applications can always intercept return codes and emit # STEP_* tags. if return_code == 0: self.fixupLast() if self.honor_zero_return_code: self.annotate_status = builder.SUCCESS else: self.annotate_status = builder.FAILURE self.fixupLast(builder.FAILURE)
Example 13
Source File: tools.py From pccold with MIT License | 5 votes |
def returnCodeObserver(self): logging.info('returnCodeObserver') returncode=self.shell.wait() global pidpool del pidpool[str(self.shell.pid)] self.sleepkiller.stop() logging.info('save quit pid='+str(self.shell.pid)+' return code='+str(returncode)) if returncode!=-9 and not self.isstoped: time.sleep(60) logging.info('start main from return code observer') ReturnCodeObserverThread.main()
Example 14
Source File: install.py From FACT_core with GNU General Public License v3.0 | 5 votes |
def run_shell_command_raise_on_return_code(command: str, error: str, add_output_on_error=False) -> str: # pylint: disable=invalid-name output, return_code = execute_shell_command_get_return_code(command) if return_code != 0: if add_output_on_error: error = '{}\n{}'.format(error, output) raise InstallationError(error) return output
Example 15
Source File: frontend.py From FACT_core with GNU General Public License v3.0 | 5 votes |
def execute_commands_and_raise_on_return_code(commands, error=None): # pylint: disable=invalid-name for command in commands: bad_return = error if error else 'execute {}'.format(command) output, return_code = execute_shell_command_get_return_code(command) if return_code != 0: raise InstallationError('Failed to {}\n{}'.format(bad_return, output))
Example 16
Source File: delegator.py From habu with BSD 3-Clause "New" or "Revised" License | 5 votes |
def return_code(self): # Support for pexpect's functionality. if self._uses_pexpect: return self.subprocess.exitstatus # Standard subprocess method. return self.subprocess.returncode
Example 17
Source File: upload.py From personfinder with Apache License 2.0 | 5 votes |
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True, env=os.environ): """Executes a command and returns the output from stdout and the return code. Args: command: Command to execute. print_output: If True, the output is printed to stdout. If False, both stdout and stderr are ignored. universal_newlines: Use universal_newlines flag (default: True). Returns: Tuple (output, return code) """ logging.info("Running %s", command) p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=use_shell, universal_newlines=universal_newlines, env=env) if print_output: output_array = [] while True: line = p.stdout.readline() if not line: break print(line.strip("\n")) output_array.append(line) output = "".join(output_array) else: output = p.stdout.read() p.wait() errout = p.stderr.read() if print_output and errout: print(errout, file=sys.stderr) p.stdout.close() p.stderr.close() return output, p.returncode
Example 18
Source File: exception.py From skcom with MIT License | 5 votes |
def get_return_code(self): """ TODO """ return self.return_code
Example 19
Source File: utils.py From cumulus with Apache License 2.0 | 5 votes |
def check_ansible_return_code(returncode, cluster, girder_token): if returncode != 0: check_status(requests.patch('%s/clusters/%s' % (cumulus.config.girder.baseUrl, cluster['_id']), headers={'Girder-Token': girder_token}, json={'status': 'error'}))
Example 20
Source File: validate_steps.py From paasta with Apache License 2.0 | 5 votes |
def see_expected_return_code(context, code): print(context.output) print(context.return_code) print() assert context.return_code == code
Example 21
Source File: paasta_metastatus_steps.py From paasta with Apache License 2.0 | 5 votes |
def check_metastatus_return_code_no_flags( context, expected_return_code, expected_output ): check_metastatus_return_code_with_flags( context=context, flags="", expected_return_code=expected_return_code, expected_output=expected_output, )
Example 22
Source File: validitygenerator.py From OpenXR-SDK-Source with Apache License 2.0 | 5 votes |
def makeReturnCodeList(self, attrib, cmd, name): """Return a list of possible return codes for a function. attrib is either 'successcodes' or 'errorcodes'. """ return_lines = [] RETURN_CODE_FORMAT = '* ename:{}' codes_attr = cmd.get(attrib) if codes_attr: codes = self.findRequiredEnums(codes_attr.split(',')) if codes: return_lines.extend((RETURN_CODE_FORMAT.format(code) for code in codes)) applicable_ext_codes = (ext_code for ext_code in self.registry.commandextensionsuccesses if ext_code.command == name) for ext_code in applicable_ext_codes: line = RETURN_CODE_FORMAT.format(ext_code.value) if ext_code.extension: line += ' [only if {} is enabled]'.format( self.conventions.formatExtension(ext_code.extension)) return_lines.append(line) if return_lines: return '\n'.join(return_lines) return None
Example 23
Source File: __init__.py From pulsar with Apache License 2.0 | 5 votes |
def return_code(self, job_id): """ Return integer indicating return code of specified execution or PULSAR_UNKNOWN_RETURN_CODE. """
Example 24
Source File: upload.py From training_results_v0.5 with Apache License 2.0 | 5 votes |
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True): """Executes a command and returns the output from stdout and the return code. Args: command: Command to execute. print_output: If True, the output is printed to stdout. If False, both stdout and stderr are ignored. universal_newlines: Use universal_newlines flag (default: True). Returns: Tuple (output, return code) """ logging.info("Running %s", command) p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=use_shell, universal_newlines=universal_newlines) if print_output: output_array = [] while True: line = p.stdout.readline() if not line: break print line.strip("\n") output_array.append(line) output = "".join(output_array) else: output = p.stdout.read() p.wait() errout = p.stderr.read() if print_output and errout: print >>sys.stderr, errout p.stdout.close() p.stderr.close() return output, p.returncode
Example 25
Source File: cgroup_task_runner.py From airflow with Apache License 2.0 | 5 votes |
def return_code(self): return_code = self.process.poll() # TODO(plypaul) Monitoring the control file in the cgroup fs is better than # checking the return code here. The PR to use this is here: # https://github.com/plypaul/airflow/blob/e144e4d41996300ffa93947f136eab7785b114ed/airflow/contrib/task_runner/cgroup_task_runner.py#L43 # but there were some issues installing the python butter package and # libseccomp-dev on some hosts for some reason. # I wasn't able to track down the root cause of the package install failures, but # we might want to revisit that approach at some other point. if return_code == 137: self.log.error("Task failed with return code of 137. This may indicate " "that it was killed due to excessive memory usage. " "Please consider optimizing your task or using the " "resources argument to reserve more memory for your task") return return_code
Example 26
Source File: _ode.py From lambda-packs with MIT License | 5 votes |
def get_return_code(self): """Extracts the return code for the integration to enable better control if the integration fails.""" try: self._integrator except AttributeError: self.set_integrator('') return self._integrator.istate
Example 27
Source File: _counter.py From sqlitebiter with MIT License | 5 votes |
def get_return_code(self) -> int: if self.__success_count > 0: return ExitCode.SUCCESS if self.__fail_count > 0: return ExitCode.FAILED_CONVERT return ExitCode.NO_INPUT