Created
September 18, 2012 17:00
-
-
Save itsderek23/3744312 to your computer and use it in GitHub Desktop.
Scout running Python Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $scout test py.rb | |
| == This plugin doesn't have option metadata. | |
| == You haven't provided any options for running this plugin. | |
| == Output: | |
| {:server_name=>nil, | |
| :errors=>[], | |
| :reports=> | |
| [{:created_at=>"2012-09-18 17:00:05", | |
| :fields=>{:random=>7.0}, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Py < Scout::Plugin | |
| def build_report | |
| code=<<END_OF_CODE | |
| from random import randint | |
| print randint(2,9) | |
| END_OF_CODE | |
| analysis = open("| python 2>&1", "r+") do |py| | |
| py.puts(code) | |
| py.close_write | |
| py.read | |
| end | |
| report :random => analysis.to_f | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment