pysyslimit.utils

ExecuteException

class pysyslimit.utils.ExecuteException(return_code, stdout, stderr)[source]
Overview:

Error when the command line execute failed.

__init__(return_code, stdout, stderr)[source]
Overview:

Constructor of class pysyslimit.utils.ExecuteException.

Arguments:
  • return_code: Return code.

  • stdout: Stdout content.

  • stderr: Stderr content.

property message
Overview:

Message of this command.

property return_code
Overview:

Return code of this command.

property stderr
Overview:

Stderr content of this command.

property stdout
Overview:

Stdout content of this command.

property title
Overview:

Title of this command.

cmd_execute

pysyslimit.utils.cmd_execute(args, env=None, encoding=None)[source]
Overview:

Execute one command line.

Arguments:
  • args: Command line arguments.

  • env: Environment variables.

  • encoding: Encoding format.

Returns:
  • tuple: A tuple which is like (return_code, stdout, stderr).

Examples::
>>> from pysyslimit.utils import cmd_execute
>>> cmd_execute(['echo', '233'])
(0, '233\n', '')

execute_process

pysyslimit.utils.execute_process(args, env=None, encoding=None, cls=None)[source]
Overview:

Execute process, raise exception when return code is not 0.

Arguments:
  • args: Command line arguments.

  • env: Environment variables.

  • encoding: Encoding format.

  • cls: Class of exception.

Returns:
  • tuple: A tuple which is like (return_code, stdout, stderr).

Examples::
>>> from pysyslimit.utils import execute_process
>>> execute_process(['echo', '233'])
(0, '233\n', '')