Giter VIP home page Giter VIP logo

runner's Introduction

Run

Simple and easy-to-use runner for Python scripts

Usage

  • pip install Runner And then:

    Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
    [GCC 4.7.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from Runner import Run
    >>> result = Run.command("cat /etc/passwd")
    >>> result
    <Run->0 stdout='root:x:0:0:root:...' stderr='...'>
    (you see the strings are trimmed here just to be clean)
    >>> result.rc
    0
    >>> result.stdout
    'CONTENT OF MY /ETC/PASSWD FILE :)'
    >>> result.stderr
    ''
    >>> bool(result)
    True
    >>> newrun = result.rerun()
    >>> newrun  # Old one is preserved
    <Run->0 stdout='root:x:0:0:root:...' stderr='...'>
    >>> will_fail = Run.command("cat asdfasdf")
    >>> will_fail
    <Run->1 stdout='...' stderr='cat: asdfasdf: N...'>
    >>> bool(will_fail)
    False
    >>> will_fail.stderr
    'cat: asdfasdf: No such file or directory\n'
    >>> last_one = Run.bash("cat /etc/passwd | grep -E root")
    >>> bool(last_one)
    True
    >>> last_one.stdout
    'root:x:0:0:root:/root:/bin/bash\n'
    >>>
    

And that's it.

py.test extension:

If you install Runner-pytest package, you will be able to use the fixture named Run in py.test environment.

runner's People

Contributors

mfalesni avatar

runner's Issues

bool(result) does not appear correct in Python 3

The following code works as expected on Python 2.7.12 but not as expected on Python 3.6.8

With Python 2

Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Runner import Run
>>> x = Run.command("false")
>>> x.rc
1
>>> bool(x)
False
>>>

and Python 3

Python 3.6.8 (default, Dec 24 2018, 19:24:27) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from Runner import Run
>>> x = Run.command("false")
>>> x.rc
1
>>> bool(x)
True
>>>

I can see I could use AssertRC() in some of the cases I need, but in some use cases I need just the opposit of AssertRC(0) and I don't really care too much about the non-zero status just as long as it is non-zero - hence the desire to use bool().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.