diff options
author | Thomas Kluyver <takowl@gmail.com> | 2015-02-26 18:05:35 -0800 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2015-02-26 18:05:35 -0800 |
commit | 41006b799203884ad339c1f2126ca80207f03442 (patch) | |
tree | d7ea7351bec603d24c7682f6a4e8b301554997a7 /pexpect | |
parent | 369c2956a89e9e245ed4a52b329d478658ab2d4c (diff) | |
download | pexpect-git-41006b799203884ad339c1f2126ca80207f03442.tar.gz |
Deprecate runu function
Diffstat (limited to 'pexpect')
-rw-r--r-- | pexpect/__init__.py | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/pexpect/__init__.py b/pexpect/__init__.py index c906e89..9b80c1d 100644 --- a/pexpect/__init__.py +++ b/pexpect/__init__.py @@ -77,7 +77,7 @@ __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'spawnu', 'run', 'runu 'which', 'split_command_line', '__version__', '__revision__'] def run(command, timeout=30, withexitstatus=False, events=None, - extra_args=None, logfile=None, cwd=None, env=None): + extra_args=None, logfile=None, cwd=None, env=None, **kwargs): ''' This function runs the given command; waits for it to finish; then @@ -159,29 +159,16 @@ def run(command, timeout=30, withexitstatus=False, events=None, sent to the child. 'extra_args' is not used by directly run(). It provides a way to pass data to a callback function through run() through the locals dictionary passed to a callback. - ''' - return _run(command, timeout=timeout, withexitstatus=withexitstatus, - events=events, extra_args=extra_args, logfile=logfile, cwd=cwd, - env=env, _spawn=spawn) -def runu(command, timeout=30, withexitstatus=False, events=None, - extra_args=None, logfile=None, cwd=None, env=None, **kwargs): - """This offers the same interface as :func:`run`, but using unicode. - - Like :class:`spawnu`, you can pass ``encoding`` and ``errors`` parameters, - which will be used for both input and output. - """ - return _run(command, timeout=timeout, withexitstatus=withexitstatus, - events=events, extra_args=extra_args, logfile=logfile, cwd=cwd, - env=env, _spawn=spawnu, **kwargs) - -def _run(command, timeout, withexitstatus, events, extra_args, logfile, cwd, - env, _spawn, **kwargs): + Like :class:`spawn`, passing *encoding* will make it work with unicode + instead of bytes. You can pass *codec_errors* to control how errors in + encoding and decoding are handled. + ''' if timeout == -1: - child = _spawn(command, maxread=2000, logfile=logfile, cwd=cwd, env=env, + child = spawn(command, maxread=2000, logfile=logfile, cwd=cwd, env=env, **kwargs) else: - child = _spawn(command, timeout=timeout, maxread=2000, logfile=logfile, + child = spawn(command, timeout=timeout, maxread=2000, logfile=logfile, cwd=cwd, env=env, **kwargs) if isinstance(events, list): patterns= [x for x,y in events] @@ -229,4 +216,12 @@ def _run(command, timeout, withexitstatus, events, extra_args, logfile, cwd, else: return child_result +def runu(command, timeout=30, withexitstatus=False, events=None, + extra_args=None, logfile=None, cwd=None, env=None, **kwargs): + """Deprecated: pass encoding to run() instead. + """ + return run(command, timeout=timeout, withexitstatus=withexitstatus, + events=events, extra_args=extra_args, logfile=logfile, cwd=cwd, + env=env, _spawn=spawnu, **kwargs) + # vim: set shiftround expandtab tabstop=4 shiftwidth=4 ft=python autoindent : |