• Home
  • About
  • Blog Archives
  • Contact Me
  • FAQ
  • The Big 101
Subscribe: Posts | Comments | E-mail

jonobacon@home

Posted on January 8, 2010 - by jono

Acire: Delivering A World Of Python Snippets

Acire

A few weeks back I blogged about my new program Acire: a simple little tool that provides a library of Python examples called snippets that outline how to do specific taks. With each snippet you can browse the code, run it and otherwise learn how it works in order to help you get to grips with writing your own programs as quickly and easily as possible.

I wrote Acire to augment Quickly in lowering the bar for Opportunistic Programmers to get involved in writing applications. For more on opportunistic programmers see my article Unchaining the Opportunistic Programmer.

So core ethos in my mind behind Acire is:

Provide a regularly, automatically updating diverse range of Python examples, all available within Acire, which allows you to browse, view, run and learn from them.

Meeting this goal is broken into two parts: providing the viewer (Acire) and providing the library of examples (Python Snippets).

The Acire code is now available at http://www.launchpad.net/acire. If you want to give it a shot, make sure you have python-vte installed from your distribution and also install the python-snippets PPA (see below) and then run:

bzr branch lp:acire

Then run:

cd acire
quickly run

UPDATE: A PPA of the first Acire 0.1 release is now available. Just run these commands to install it:

sudo add-apt-repository ppa:acire-team/acire-releases
sudo apt-get update
sudo apt-get install acire

Thanks to Nathan Handler for setting this up!

Acire will show you your library of snippets and you can click on each one and click the Execute button to run it:

Let’s now discuss the snippets. I created a new Launchpad project at http://www.launchpad.net/python-snippets which is intended to provide a library of snippets. I will be encouraging the community to provide snippets for this library (see below), and I have deliberately kept the library as a seperate project from Acire which is useful for getting the library without getting Acire and also if someone wants to write an alternative to Acire (such as a KDE port).

My friend and yours Nathan Handler has created a daily PPA of the library for Karmic and you can install it by just adding these commands:

sudo add-apt-repository ppa:python-snippets-drivers/python-snippets-daily
sudo apt-get update
sudo apt-get install python-snippets

Once you have done this, the latest Python Snippets library will be delivered right to your computer and ready for browsing, learning, and playing with right from within Acire!

We Need Your Snippets!

So right now we have an awesome app for viewing with and playing with snippets, and a means of delivering them to hungry hackers, but what we now need is more snippets. Adding a snippet is as simple as following these steps.

Step 1: Grab the library

Just run:

bzr branch lp:python-snippets

Step 2: Create your snippet

A snippet should demonstrate a specific feature in a given module or in the Python language. This could include showing how to use a specific widget, a feature of that widget, or another function.

python-snippets is divided into sub-directories which outlines the theme of the snippets. You should pick the most appropriate directory to put your snippet it, and add it there. If a suitable directory does not exist already, create it and add it there.

Step 3: Add metadata

The way Acire pulls out the snippets is by detecting some specific metadata additions to comments at the top of the file You should now add the following meta data as comments to the top of the file:

# [SNIPPET_NAME: A Short Name For The Snippet]
# [SNIPPET_CATEGORIES: Category]  <-- see CATEGORIES file for existing categories
# [SNIPPET_DESCRIPTION: A single line description of the snippet]
# [SNIPPET_AUTHOR: Your Name <your@emailaddress.com>]
# [SNIPPET_LICENSE: An Open Source license (from the LICENSES file)]

Here is an example:

# [SNIPPET_NAME: Playing a Pipeline]
# [SNIPPET_CATEGORIES: GStreamer]
# [SNIPPET_DESCRIPTION: Construct and play a pipeline]
# [SNIPPET_AUTHOR: Jono Bacon <jono@ubuntu.com>]
# [SNIPPET_LICENSE: GPL]

You now need to add your file to your branch with:

bzr add your-snippet.py

Step 4: Propose it for merging

With your new snippet ready, it is time to propose it for inclusion in the main python-snippets library.

First, commit your changes to your local branch with:

bzr commit

Now push it to your own branch on Launchpad:

bzr push lp:~<your launchpad username>/python-snippets/<name of your branch>

As an example:

bzr push lp:~jonobacon/python-snippets/gstreamer-snippets

Now go to https://code.launchpad.net/python-snippets and you should see your branch listed there. Click on it and when the branch page information page loads click on the Propose for merging link. Add a short description of what you examples do in the Initial Comment box and then click the Propose Merge button.

We will then review the merge and if it looks good, add it to python-snippets and it will be delivered to Acire users in the next daily package upload. :-)

I am really keen to see snippets on pretty much everything and if you want to help, a great place to start is converting the Quickly snippets page over to real, runnable snippets for python-snippets. Let’s roll!



This entry was posted on Friday, January 8th, 2010 at 11:00 pm and is filed under Acire. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

22 Comments

We'd love to hear yours!



  1. Visit My Website

    January 8, 2010

    Permalink

    Ronan said:

    Fabulous news.

    Acire works like a charm, and the python-snippets looks great.

    Reply


    • Visit My Website

      January 9, 2010

      Permalink

      jono said:

      I am really pleased it works for you, Ronan! You are my first user!

      Do submit a few snippets if you get time. :-)

      Reply


  2. Visit My Website

    January 9, 2010

    Permalink

    Linus said:

    I love the idea of a python snippet repository, but I don’t really get why an offline client would be any more suited than a website for something like that. Could you elaborate a little on that point?

    Reply


    • Visit My Website

      January 9, 2010

      Permalink

      jono said:

      A few reasons:

      • Firstly, and most honestly, I just prefer desktop apps. :-)
      • Secondly, it is much easier to run it if it is a desktop app – the code is there, click one button and the snippet loads.
      • Thirdly, there are future opportunities for hooking into other development frameworks. :-)
      Reply


  3. Visit My Website

    January 9, 2010

    Permalink

    Roger Clark said:

    I agree with Linus. I’m not sure if this is the most convenient way to implement this particular idea. A site just seems to make way more sense: there could be a social aspect (commenting and such), you could actually link people to these snippets (because you’d have a URL), and you could take advantage of search engines.

    Reply


  4. Visit My Website

    January 9, 2010

    Permalink

    Shane Fagan said:

    Jono you should ask Rick on the desktop team he has a load of nice snippets from the code party at the UDS. There are lots to do everything from translations, opening web pages to a lot more advanced stuff.

    Reply


  5. Visit My Website

    January 9, 2010

    Permalink

    Russ Brown said:

    Having just played with acire, I can give you a couple more reasons for doing it on the desktop:

    1. Disconnected access (e.g. on a train).
    2. It actually runs the snippets for you, allowing you to see the results without having to mess about downloading things etc.

    Of course, that’s not to say that the same snippet repository couldn’t be used to drive a web site as well: I think that’s part of Jono’s point to keeping the snippets in a different place to the acire application.

    I think this is quite interesting personally. :)

    Reply


    • Visit My Website

      January 9, 2010

      Permalink

      jono said:

      Indeed, I would love someone to write a web app that pulls the bzr branch with the snippets and renders the code on a website. :-)

      Reply


      • Visit My Website

        January 12, 2010

        Permalink

        Scott Ferguson said:

        A web app frontend would be a pretty sweet idea…I’ll give it a look. I’m mostly a git guy so I’ll have to poke around with ways to get bzr interfaced via Python (which I doubt is at all hard).

        Reply


  6. Visit My Website

    January 9, 2010

    Permalink

    hemanth.hm said:

    Really appreciate the application, here are few inputs i would like to give:

    1.Would be very easy if there is a option to open a new tab where in we can write our snippets, debug it and then submit it to the bzr from with acire.

    2.An option to search few python code snippets sties.

    3.All snippets view in acire like the GtkSourceView i.e colored code.

    Reply


  7. Visit My Website

    January 9, 2010

    Permalink

    Spencer Dupre said:

    Looks great! You’ve hit the nail on the head: this is what I need to get into python more. Hope the snippet library grows.

    Reply


  8. Visit My Website

    January 9, 2010

    Permalink

    Jeremy Bicha said:

    Jono & Nathan, thanks for putting this together. Have you seriously though about how copyright is going to work for this though? Is GPL3+ the best license for this? That prevents someone from using these snippets in GPL2+ apps (for instance KDE is intentionally GPL2+). I think perhaps the snippets should be public domain…as some of the basic ones may not really be copyrightable as they’re obvious. Of course, others are more complex.

    Reply


    • Visit My Website

      January 9, 2010

      Permalink

      Ronan said:

      Everybody, correct me if I’m wrong, but the [SNIPPET_LICENSE] tag is here for this, isn’t it? Acire may use GPL3, as long as each snippet has a defined license, we can use the snippet under its own terms.

      However, giving formal licensing to python-snippets as a whole would be complicated since each individual snippet could differ.

      Reply


  9. Visit My Website

    January 9, 2010

    Permalink

    seifsallam said:

    This is amazing, and definitely will help

    Reply


  10. Visit My Website

    January 9, 2010

    Permalink

    hb said:

    This sounds like a great idea. I just wonder if the organisation in subdirectories is the best way to go. I guess a tagging mechanism would be better suited and less limiting. But maybe you already thought of that, and that’s what the CATEGORIES metadata is for?

    Reply


  11. Visit My Website

    January 9, 2010

    Permalink

    Dan Fish said:

    This is a good resource. A few dependency issues crop up which may throw those new to python – maybe some way of checking/alerting for installed/required python bindings may be a future feature.

    Reply


  12. Visit My Website

    January 10, 2010

    Permalink

    incon said:

    A linux SnippetsApp clone? http://www.snippetsapp.com/

    Reply


  13. Visit My Website

    January 10, 2010

    Permalink

    oldslag said:

    Cool idea, however breaks the typical look for examples use-pattern, i.e. go to websearch engine and then open the first link that looks vaguely like it could be relevant.

    Examples that are in this repository will be hidden, if I understand this correctly, and you will have to remember to also consult this. This will likely not happen.

    Reply


  14. Visit My Website

    January 10, 2010

    Permalink

    Bastian Kennel said:

    The main argument for me to put this on the desktop is that I can launch the example code with one click and this way immediately see what the result is. Even better, I can make small adjustments in the example. Unfortunately, they currently have no result in the execution, but perhaps this can be fixed.

    Reply


  15. Visit My Website

    January 11, 2010

    Permalink

    Bill said:

    I definitely see myself using this.

    Thanks for the great tool (and thanks for not making it a web-exclusive app!)

    Reply


  16. Visit My Website

    January 11, 2010

    Permalink

    Stu said:

    Hey I would suggest that by default the snippet licences should be at least as permissive as the python license http://www.python.org/psf/license/ . I don’t care what the licence is for the program but I would hesitate to even look at the snippets if I was not able to use them in my own (commercial) code.

    I would even suggest that you should turn down merge requests for snippets with more restrictive licensing unless there was a very good reason. Activestate http://code.activestate.com/ requires an MIT license for example.

    Reply


Leave a Reply


Here's your chance to speak.

Click here to cancel reply.

  1. Name (required)

    Mail (required)

    Website

    Message

  • Ad Ad Ad Ad
  • Prepare For Awesome

  • Recent Articles

    • Fixing Ubuntu Software Center Descriptions
    • Red Hat, Canonical and GNOME Contributions
    • Ubuntu Global Jam: Start Your Engines!
    • Awesome GUADEC Espresso and Coffee Bar
    • Team Reporting
    • The Five Horsemen
    • Community Leadership Summit 2010 This Weekend!
    • Ahmed Kamal Joins The Horsemen
    • Severed Fifth Update
    • Rocking The LoCo Council
  • Recent Comments

    • Inge Wallin on Red Hat, Canonical and GNOME Contributions
    • Anon on Red Hat, Canonical and GNOME Contributions
    • Greg on Red Hat, Canonical and GNOME Contributions
    • Jim on Red Hat, Canonical and GNOME Contributions
    • Adam Williamson on Red Hat, Canonical and GNOME Contributions
    • Eddward on Red Hat, Canonical and GNOME Contributions
    • HunterA3 on Red Hat, Canonical and GNOME Contributions
    • ScottK on Fixing Ubuntu Software Center Descriptions
    • Contribuciones a GNOME – Red Hat 16%, Canonical 1% | Ubunlog on Red Hat, Canonical and GNOME Contributions
    • ah on Red Hat, Canonical and GNOME Contributions
  • Flickr Photos

  •  

    January 2010
    M T W T F S S
    « Dec   Feb »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • jb@h Rockstars This Year

    • ethana2 (30)
    • Zac (17)
    • nixternal (16)
    • Tom (12)
    • Bruno Girin (11)
    • James Duncan (11)
    • Adam Williamson (10)
    • Anon (10)
    • Brandon Tomlinson (10)
    • Jef Spaleta (10)
© 2008 jonobacon@home - At home with Jono Bacon, Community Manager and Author