Latest version of Sparrow has brought a new feature for those who would like to write sparrow plugins using Python language.

Now you can declare a Python/Pip dependencies with the help of requirements.txt file:

$ cat requirements.txt http==0.02

Let’s create a simple plugin to make http requests using hackhttp python library.

$ cat story.py import hackhttp from outthentic import * url = config()['url'] hh = hackhttp.hackhttp() code, head, html, redirect_url, log = hh.http(url) print code $ touch story.check $ cat sparrow.json { "name" : "python-sparrow-plugin", "description": "test sparrow plugin for python", "version" : "0.0.4", "url" : "https://github.com/melezhik/python-sparrow-plugin" }

Now let’s upload the plugin to SparrowHub and give it a run:

$ sparrow plg upload sparrow.json file validated ... plugin python-sparrow-plugin version 0.000004 upload OK $ sparrow plg install python-sparrow-plugin upgrading public@python-sparrow-plugin from version 0.0.3 to version 0.000004 ... Download https://sparrowhub.org/plugins/python-sparrow-plugin-v0.000004.tar.gz --- 200 Downloading/unpacking hackhttp==1.0.4 (from -r requirements.txt (line 1)) Downloading hackhttp-1.0.4.tar.gz Running setup.py (path:/tmp/pip_build_melezhik/hackhttp/setup.py) egg_info for package hackhttp Installing collected packages: hackhttp Running setup.py install for hackhttp Successfully installed hackhttp Cleaning up... $ sparrow plg run python-sparrow-plugin --param url=http://example.com •[plg] python-sparrow-plugin at 2017-05-12 17:07:17 200 ok scenario succeeded STATUS SUCCEED

And finally if you prefer to get things done by Perl6/Sparrowdo use this piece of code as starting point:

$ cat sparrowfile my $url = 'http://example.com'; task-run "http get $url", 'python-sparrow-plugin', %( url => $url );