Alexis' loghttp://blog.notmyidea.org2011-12-06T00:00:00+01:00Introducing cornice2011-12-06T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-06:/introducing-cornice.html/<p>Wow, already my third working day at mozilla. Since Monday, I've been working with Tarek Ziadé, on a pyramid REST-ish toolkit named <a class="reference external" href="https://github.com/mozilla-services/cornice">cornice</a>.</p> <p>Its goal is to take all the hard bits appart from you when implementing a web service, so you can focus on what's important. Cornice provides you facilities for validation of any kind.</p> <p>The goal is to simplify your work, but we don't want to reinvent the wheel, so it is easily pluggable with validations frameworks, such as Collander.</p> <div class="section" id="handling-errors-and-validation"> <h2>Handling errors and validation</h2> <p>We have changed the way errors are handled. Here is how it works:</p> <div class="highlight"><pre><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;service&quot;</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s">&quot;/service&quot;</span><span class="p">)</span> <span class="k">def</span> <span class="nf">is_awesome</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> <span class="k">if</span> <span class="ow">not</span> <span class="s">&#39;awesome&#39;</span> <span class="ow">in</span> <span class="n">request</span><span class="o">.</span><span class="n">GET</span><span class="p">:</span> <span class="n">request</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;body&#39;</span><span class="p">,</span> <span class="s">&#39;awesome&#39;</span><span class="p">,</span> <span class="s">&#39;You lack awesomeness!&#39;</span><span class="p">)</span> <span class="nd">@service.get</span><span class="p">(</span><span class="n">validator</span><span class="o">=</span><span class="p">(</span><span class="n">is_awesome</span><span class="p">))</span> <span class="k">def</span> <span class="nf">get1</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> <span class="k">return</span> <span class="p">{</span><span class="s">&quot;test&quot;</span><span class="p">:</span> <span class="s">&quot;succeeded&quot;</span><span class="p">}</span> </pre></div> <p>All the errors collected during the validation process, or after, are collected before returning the request. If any, a error 400 is fired up, with the list of problems encoutred encoded as a nice json list (we plan to support multiple formats in the future)</p> <p>As you might have seen, <cite>request.errors.add</cite> takes three parameters: <strong>location</strong>, <strong>name</strong> and <strong>description</strong>.</p> <p><strong>location</strong> is where the error arised. It can either be &quot;body&quot;, &quot;query&quot;, &quot;headers&quot; or &quot;path&quot;. <strong>name</strong> is the name of the variable causing problem, if any, and <strong>description</strong> contains a more detailled message.</p> <p>Here is an example of a malformed request:</p> <pre class="literal-block"> $ # run a demo app </pre> <p>To describe a web service in <em>cornice</em>, you have to write something like this</p> <div class="system-message"> <p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">./content/mozilla/introducing-cornice.rst</tt>, line 54)</p> <p>Content block expected for the &quot;code-block&quot; directive; none found.</p> <pre class="literal-block"> .. code-block:: python </pre> </div> </div> Quels usages pour l'informatique ?2011-12-01T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-12-01:/quels-usages-pour-linformatique-fr.html/<p>Quand on termine ses études, on s'en pose un tas, des questions. Sur le métier que l'on veut faire, sur ce que ça signifie, sur le sens et la valeur du travail. Et j'en suis arrivé à faire un constat simple: l'informatique, c'est utile, tant que ça ne viens pas vous pourrir la vie. Oui, parce que de l'informatique on en a partout, des &quot;geeks&quot; et des &quot;accros&quot; aussi, et que ça vient s'immiscer dans nos vies même quand d'autres moyens ou médias sont plus utiles ou pertinents.</p> <p>Certes, l'informatique nous permet de mieux communiquer et de mieux travailler. Mais à quel prix ? ce n'est pas parce qu'il est &quot;possible&quot; d'<a class="reference external" href="http://retourdactu.fr/2011/11/07/la-non-communication-nouveau-modele-de-societe/">industrialiser l'éducation</a> (ou l'agriculture !), que l'on doit le faire. Oui, ça me dérange d'être une des nombreuses personnes à l'œuvre derrière cette soit disant &quot;révolution&quot;, qui n'est pas toujours pour le meilleur. Attention, je ne remets pas l'informatique et son intérêt en cause: je me pose des questions quand à la place que je veux lui donner et la place que je souhaites occuper dans son évolution. Ce n'est pas parce qu'on peut tuer avec un marteau (avec un peu de volonté) qu'il s'agit d'un mauvais outil, mais si tout le monde se met à tuer avec des marteaux (y a des malades partout, hein), alors se poser la question de son rôle, en tant que fabricant de marteaux me semble nécessaire (oui, je vous l'accorde, on aura vu des comparaisons plus perspicaces).</p> <p>Donc: à partir de quel moment l'informatique cesse d'être un outil utile pour transformer nos modes de vies d'une manière qui me dérange ? Peut être avec son arrivée sur des périphériques mobiles ? Peut être quand elle se fait l'instrument du consumérisme et de l'individualisme.</p> <div class="section" id="et-alors-on-fait-quoi"> <h2>Et alors, on fait quoi ?</h2> <p>Mais si je continue à faire de l'informatique, il y à bien des raison. J'ai d'ailleurs trouvé mon intérêt de par le coté collaboratif qui est permis et développé par l'outil informatique, et notamment par le réseau des réseaux (internet). Faisons ensemble, mes amis. Prouvons que la collaboration à de meilleurs jours à vivre que la compétition. Le web, notamment, est une avancée majeure en ce qui concerne la liberté d'expression et le partage de connaissances (oui, kipédia). Je vous conseille d'ailleurs à ce propos <a class="reference external" href="http://owni.fr/2011/11/30/vers-une-economie-de-la-contribution/">l'excellent discours tenu par Bernard Stiegler</a> paru recemment sur <a class="reference external" href="http://www.owni.fr">owni</a>.</p> <p>Et c'est cet avenir qu'il me plait de défendre: l'ouverture d'esprit, la possibilité que chacun puisse contribuer et participer à une base de savoir commune, en apprenant des autres. Mais par pitié, n'imposons pas la technologie là ou elle n'est pas nécessaire, et utilisons là avec tact quand elle peut nous être profitable.</p> <p>Il me plait de repenser l'informatique comme outil et non plus comme mode de vie. Faisons le l'outil de la collaboration. À l'école, apprenons à nos enfants à collaborer, à susciter le partage, pas uniquement avec l'outil informatique, mais aussi avec celui ci, tout en leurs apprenant à avoir un regard critique sur les informations qu'il reçoivent.</p> <p>En bref, questionner le rôle que l'on souhaites avoir dans notre société par le biais de l'informatique est nécessaire. Comme d'autres, je suis arrivé à l'informatique par le biais du premier ordinateur familial, il y a de ça une bonne quinzaine d'années. Ça intrigue, on touche un peu à tout (on en fait des conneries !) et on finit par apprendre/comprendre comment ça marche, petit à petit. Cette curiosité n'est d'ailleurs pas le propre de l'informatique puisqu'on la retrouve dans la cuisine, dans le bricolage et dans un tas de domaines de notre vie quotidienne.</p> <p>Finalement, c'est aimer bidouiller, et comprendre comment ça fonctionne, quitte à sortir les compétences de leur domaine de prédilection (qui à dit que l'informatique ne pouvait être artistique ?) Le mouvement hacker (bidouilleurs) aime à sortir l'informatique de son carcan et l'appliquer ailleurs.</p> <p>C'est de cette manière que j'ai envie de considérer mon métier, qui avant tout est une passion. Je suis un bidouilleur, j'aime découvrir comment les choses fonctionnent et avoir une panoplie d'outils qui me permettent de répondre à des besoins réels.</p> </div> <div class="section" id="favoriser-la-collaboration"> <h2>Favoriser la collaboration</h2> <p>Et donc, en tant qu'individu, pourquoi faire de l'informatique ? Qu'est-ce qui m'attire dans cet outil ?</p> <p>Ce qu'on pourrait qualifier de &quot;recherche fondamentale&quot;, l'écriture de bibliothèques logicielles, est important mais n'est pas tout. Ce qui importe ce sont les usages qui en découlent. Je souhaite <strong>savoir écrire des outils qui sont utiles</strong>, <strong>qui favorisent la collaboration et participent à l'ouverture des esprits</strong>.</p> <p>Je choisis de faire de l'informatique pour créer les outils qui répondent à des problématiques réelles, pour trouver de meilleures manières de communiquer et de travailler ensemble. Mais, comme me le disait David, d'<a class="reference external" href="http://outils-reseaux.org/PresentationProjet">Outils-Réseaux</a>, on ne crée pas de la coopération: rien ne sert d'essayer de faire coopérer des gens qui ne veulent pas. On peut, cependant, la faciliter, en utilisant les bons outils et en formant les gens à leur utilisation, ainsi qu'aux pratiques collaboratives (qui, je le répète, ne s'arrêtent pas du tout aux frontières informatique).</p> <p>Le logiciel libre, avant d'être une force pour le marché logiciel, est une application du partage. Une démonstration qu'il est possible de travailler ensemble pour fabriquer quelque chose de fonctionnel et d'utile pour tous. Une sorte d'antithèse de ce modèle capitaliste incarné par les brevets logiciel.</p> <p>A plusieurs reprises, j'ai été bluffé par la réalité du logiciel libre. Oui, il est facile de collaborer lorsqu'on crée un logiciel, pour peu qu'on explique les tenants et les aboutissants aux participants. Les contributeurs sortent d'on ne sait ou, pour peu que le projet leur soit utile. Je ne parles pas d'outils &quot;corpo compliant&quot; (bien que ça soit probablement aussi le cas), mais d'outils que j'ai pu développer pour mon propre usage, et sur lesquels il à été possible de collaborer avec d'autres.</p> <p>Parce que l'informatique est utile dans bien des milieux, parce qu'elle peut être (et elle l'est) un vecteur de participation et de collaboration, défendons les valeurs qui nous sont chères (logiciels libres et ouverts!) et construisons des ponts entre les initiatives qui nous parlent (dans mon cas ça parles de fermes autogérées, et d'initiatives d'éducation populaire) et l'informatique. Faisons en sorte de rendre l'informatique accessible et utile dans les milieux ou elle peut apporter quelque chose !</p> </div> How are you handling your shared expenses?2011-10-15T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-10-15:/how-are-you-handling-your-shared-expenses.html/<p><strong>TL;DR:</strong> We're kick-starting a new application to manage your shared expenses. Have a look at <a class="reference external" href="http://ihatemoney.notmyidea.org">http://ihatemoney.notmyidea.org</a></p> <p>As a student, I lived in a lot of different locations, and the majority of them had something in common: I lived with others. It usually was a great experience (and I think I will continue to live with others). Most of the time, we had to spend some time each month to compute who had to pay what to the others.</p> <p>I wanted to create a pet project using flask, so I wrote a little (~150 lines) flask application to handle this. It worked out pretty well for my housemates and me, and as we had to move into different locations, one of them asked me if he could continue to use it for the year to come.</p> <p>I said yes and gave it some more thoughts: We probably aren't the only ones interested by such kind of software. I decided to extend a bit more the software to have a concept of projects and persons (the list of persons was hard-coded in the first time, boooh!).</p> <p>I then discussed with a friend of mine, who was excited about it and wanted to learn python. Great! That's a really nice way to get started. Some more friends were also interested in it and contributed some features and provided feedback (thanks <a class="reference external" href="http://www.sneakernet.fr/">Arnaud</a> and Quentin!)</p> <p>Since that, the project now support multiple languages and provides a REST API (android and iphone apps in the tubes!), into other things. There is no need to register for an account or whatnot, just enter a project name, a secret code and a contact email, invite friends and that's it (this was inspired by doodle)!</p> <img alt="images/ihatemoney.png" src="images/ihatemoney.png" /> <p>You can try the project at <a class="reference external" href="http://ihatemoney.notmyidea.org">http://ihatemoney.notmyidea.org</a> for now, and the code lives at <a class="reference external" href="https://github.com/spiral-project/ihatemoney/">https://github.com/spiral-project/ihatemoney/</a>.</p> <div class="section" id="features"> <h2>Features</h2> <p>In the wild, currently, there already are some implementations of this shared budget manager thing. The fact is that most of them are either hard to use, with a too much fancy design or simply trying to do too much things at once.</p> <p>No, I don't want my budget manager to make my shopping list, or to run a blog for me, thanks. I want it to let me focus on something else. Keep out of my way.</p> <div class="section" id="no-user-registration"> <h3>No user registration</h3> <p>You don't need to register an account on the website to start using it. You just have to create a project, set a secret code for it, and give both the url and the code to the people you want to share it with (or the website can poke them for you).</p> </div> <div class="section" id="keeping-things-simple"> <h3>Keeping things simple</h3> <p>&quot;Keep It Simple, Stupid&quot; really matches our philosophy here: you want to add a bill? Okay. Just do it. You just have to enter who paid, for who, how much, and a description, like you would have done when you're back from the farmer's market on raw paper.</p> </div> <div class="section" id="no-categories"> <h3>No categories</h3> <p>Some people like to organise their stuff into different &quot;categories&quot;: leisure, work, eating, etc. That's not something I want (at least to begin with).</p> <p>I want things to be simple. Got that? Great. Just add your bills!</p> </div> <div class="section" id="balance"> <h3>Balance</h3> <p>One of the most useful thing is to know what's your &quot;balance&quot; compared to others. In other words, if you're negative, you owe money, if you're positive, you have to receive money. This allows you to dispatch who has to pay for the next thing, in order to re-equilibrate the balance.</p> <p>Additionally, the system is able to compute for you who has to give how much to who, in order to reduce the number of transactions needed to restore the balance.</p> </div> <div class="section" id="api"> <h3>API</h3> <p>All of what's possible to do with the standard web interface is also available through a REST API. I developed a simple REST toolkit for flask for this (and I should release it!).</p> </div> </div> <div class="section" id="interested"> <h2>Interested?</h2> <p>This project is open source. All of us like to share what we are doing and would be happy to work with new people and implement new ideas. If you have a nice idea about this, if you want to tweak it or to fill bugs. Don't hesitate a second! The project lives at <a class="reference external" href="http://github.com/spiral-project/ihatemoney/">http://github.com/spiral-project/ihatemoney/</a></p> </div> La simplicité volontaire contre le mythe de l'abondance2011-10-14T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-10-14:/la-simplicite-volontaire-contre-le-mythe-de-labondance.html/<p>Paul Ariès dans la préface de &quot;<a class="reference external" href="http://www.editionsladecouverte.fr/catalogue/index.php?ean13=9782707169747">La simplicité volontaire contre le mythe de l'abondance</a>&quot;</p> <blockquote> Je sais aussi qu'à force d'être seulement contre, nous finissons par être &quot;tout contre&quot;, tout contre le système, ses débats pourris, ses pratiques immondes, ses pervertions mentales. Cessons de porter notre adversaire sur notre dos, car il finira par nous poignarder, au moment ou nous pensions justement pouvoir le vaincre… Entendons-nous bien, il ne s'agit pas d'apprendre à &quot;positiver&quot; sous prétexte que l'on pourrait &quot;moraliser&quot; ou repeindre en vert le capitalisme, il s'agit, bien au contraire, d'être aussi intraitables lorsque nous créons cet autre monde, que lorsque nous étions ces militants purs mais un peu durs à jouir, il s'agit d'être aussi indomptables mais sans oublier que le capitalisme ne pourra être arrété que par du non-capitaliste… c'est-à-dire en multipliant les expérimentations sociales, en acceptant de faire au maximum sécession, en inventant (réinventant?) une gauche buissonière et maquisarde, en faisant, au quotidien, la part belle à la dérive, à des modes de comportement expérimentaux. Nous ne devons plus accepter de faire de la politique aux conditions de nos adversaires, car c'est la seule façon d'éviter le pessimisme, le ressentiment, une désensibilisation croissante et… la mort lente.</blockquote> Using dbpedia to get languages influences2011-08-16T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-08-16:/using-dbpedia-to-get-languages-influences.html/<p>While browsing the Python's wikipedia page, I found information about the languages influenced by python, and the languages that influenced python itself.</p> <p>Well, that's kind of interesting to know which languages influenced others, it could even be more interesting to have an overview of the connexion between them, keeping python as the main focus.</p> <p>This information is available on the wikipedia page, but not in a really exploitable format. Hopefully, this information is provided into the information box present on the majority of wikipedia pages. And… guess what? there is project with the goal to scrap and index all this information in a more queriable way, using the semantic web technologies.</p> <p>Well, you may have guessed it, the project in question in dbpedia, and exposes information in the form of RDF triples, which are way more easy to work with than simple HTML.</p> <p>For instance, let's take the page about python: <a class="reference external" href="http://dbpedia.org/page/Python_%28programming_language%29">http://dbpedia.org/page/Python_%28programming_language%29</a></p> <p>The interesting properties here are &quot;Influenced&quot; and &quot;InfluencedBy&quot;, which allows us to get a list of languages. Unfortunately, they are not really using all the power of the Semantic Web here, and the list is actually a string with coma separated values in it.</p> <p>Anyway, we can use a simple rule: All wikipedia pages of programming languages are either named after the name of the language itself, or suffixed with &quot;( programming language)&quot;, which is the case for python.</p> <p>So I've built <a class="reference external" href="https://github.com/ametaireau/experiments/blob/master/influences/get_influences.py">a tiny script to extract the information from dbpedia</a> and transform them into a shiny graph using graphviz.</p> <p>After a nice:</p> <pre class="literal-block"> $ python get_influences.py python dot | dot -Tpng &gt; influences.png </pre> <p>The result is the following graph (<a class="reference external" href="http://files.lolnet.org/alexis/influences.png">see it directly here</a>)</p> <img alt="http://files.lolnet.org/alexis/influences.png" src="http://files.lolnet.org/alexis/influences.png" style="width: 800px;" /> <p>While reading this diagram, keep in mind that it is a) not listing all the languages and b) keeping a python perspective.</p> <p>This means that you can trust the scheme by following the arrows from python to something and from something to python, it is not trying to get the matching between all the languages at the same time to keep stuff readable.</p> <p>It would certainly be possible to have all the connections between all languages (and the resulting script would be easier) to do so, but the resulting graph would probably be way less readable.</p> <p>You can find the script <a class="reference external" href="https://github.com/ametaireau/experiments">on my github account</a>. Feel free to adapt it for whatever you want if you feel hackish.</p> Pelican, 9 months later2011-07-25T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-07-25:/pelican-9-months-later.html/<p>Back in October, I released <a class="reference external" href="http://docs.notmyidea.org/alexis/pelican">pelican</a>, a little piece of code I wrote to power this weblog. I had simple needs: I wanted to be able to use my text editor of choice (vim), a vcs (mercurial) and restructured text. I started to write a really simple blog engine in something like a hundred python lines and released it on github.</p> <p>And people started contributing. I wasn't at all expecting to see people interested in such a little piece of code, but it turned out that they were. I refactored the code to make it evolve a bit more by two times and eventually, in 9 months, got 49 forks, 139 issues and 73 pull requests.</p> <p><strong>Which is clearly awesome.</strong></p> <p>I pulled features such as translations, tag clouds, integration with different services such as twitter or piwik, import from dotclear and rss, fixed a number of mistakes and improved a lot the codebase. This was a proof that there is a bunch of people that are willing to make better softwares just for the sake of fun.</p> <p>Thank you, guys, you're why I like open source so much.</p> Using JPype to bridge python and Java2011-06-11T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-06-11:/using-jpype-to-bridge-python-and-java.html/<p>Java provides some interesting libraries that have no exact equivalent in python. In my case, the awesome boilerpipe library allows me to remove uninteresting parts of HTML pages, like menus, footers and other &quot;boilerplate&quot; contents.</p> <p>Boilerpipe is written in Java. Two solutions then: using java from python or reimplement boilerpipe in python. I will let you guess which one I chosen, meh.</p> <p>JPype allows to bridge python project with java libraries. It takes another point of view than Jython: rather than reimplementing python in Java, both languages are interfacing at the VM level. This means you need to start a VM from your python script, but it does the job and stay fully compatible with Cpython and its C extensions.</p> <div class="section" id="first-steps-with-jpype"> <h2>First steps with JPype</h2> <p>Once JPype installed (you'll have to hack a bit some files to integrate seamlessly with your system) you can access java classes by doing something like that:</p> <div class="highlight"><pre><span class="kn">import</span> <span class="nn">jpype</span> <span class="n">jpype</span><span class="o">.</span><span class="n">startJVM</span><span class="p">(</span><span class="n">jpype</span><span class="o">.</span><span class="n">getDefaultJVMPath</span><span class="p">())</span> <span class="c"># you can then access to the basic java functions</span> <span class="n">jpype</span><span class="o">.</span><span class="n">java</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;hello world&quot;</span><span class="p">)</span> <span class="c"># and you have to shutdown the VM at the end</span> <span class="n">jpype</span><span class="o">.</span><span class="n">shutdownJVM</span><span class="p">()</span> </pre></div> <p>Okay, now we have a hello world, but what we want seems somehow more complex. We want to interact with java classes, so we will have to load them.</p> </div> <div class="section" id="interfacing-with-boilerpipe"> <h2>Interfacing with Boilerpipe</h2> <p>To install boilerpipe, you just have to run an ant script:</p> <pre class="literal-block"> $ cd boilerpipe $ ant </pre> <p>Here is a simple example of how to use boilerpipe in Java, from their sources</p> <div class="highlight"><pre><span class="kn">package</span> <span class="n">de</span><span class="o">.</span><span class="na">l3s</span><span class="o">.</span><span class="na">boilerpipe</span><span class="o">.</span><span class="na">demo</span><span class="o">;</span> <span class="kn">import</span> <span class="nn">java.net.URL</span><span class="o">;</span> <span class="kn">import</span> <span class="nn">de.l3s.boilerpipe.extractors.ArticleExtractor</span><span class="o">;</span> <span class="kd">public</span> <span class="kd">class</span> <span class="nc">Oneliner</span> <span class="o">{</span> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="kd">final</span> <span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> <span class="kd">final</span> <span class="n">URL</span> <span class="n">url</span> <span class="o">=</span> <span class="k">new</span> <span class="n">URL</span><span class="o">(</span><span class="s">&quot;http://notmyidea.org&quot;</span><span class="o">);</span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">ArticleExtractor</span><span class="o">.</span><span class="na">INSTANCE</span><span class="o">.</span><span class="na">getText</span><span class="o">(</span><span class="n">url</span><span class="o">));</span> <span class="o">}</span> <span class="o">}</span> </pre></div> <p>To run it:</p> <div class="highlight"><pre><span class="nv">$ </span>javac -cp dist/boilerpipe-1.1-dev.jar:lib/nekohtml-1.9.13.jar:lib/xerces-2.9.1.jar src/demo/de/l3s/boilerpipe/demo/Oneliner.java <span class="nv">$ </span>java -cp src/demo:dist/boilerpipe-1.1-dev.jar:lib/nekohtml-1.9.13.jar:lib/xerces-2.9.1.jar de.l3s.boilerpipe.demo.Oneliner </pre></div> <p>Yes, this is kind of ugly, sorry for your eyes. Let's try something similar, but from python</p> <div class="highlight"><pre><span class="kn">import</span> <span class="nn">jpype</span> <span class="c"># start the JVM with the good classpaths</span> <span class="n">classpath</span> <span class="o">=</span> <span class="s">&quot;dist/boilerpipe-1.1-dev.jar:lib/nekohtml-1.9.13.jar:lib/xerces-2.9.1.jar&quot;</span> <span class="n">jpype</span><span class="o">.</span><span class="n">startJVM</span><span class="p">(</span><span class="n">jpype</span><span class="o">.</span><span class="n">getDefaultJVMPath</span><span class="p">(),</span> <span class="s">&quot;-Djava.class.path=</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">classpath</span><span class="p">)</span> <span class="c"># get the Java classes we want to use</span> <span class="n">DefaultExtractor</span> <span class="o">=</span> <span class="n">jpype</span><span class="o">.</span><span class="n">JPackage</span><span class="p">(</span><span class="s">&quot;de&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">l3s</span><span class="o">.</span><span class="n">boilerpipe</span><span class="o">.</span><span class="n">extractors</span><span class="o">.</span><span class="n">DefaultExtractor</span> <span class="c"># call them !</span> <span class="k">print</span> <span class="n">DefaultExtractor</span><span class="o">.</span><span class="n">INSTANCE</span><span class="o">.</span><span class="n">getText</span><span class="p">(</span><span class="n">jpype</span><span class="o">.</span><span class="n">java</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">URL</span><span class="p">(</span><span class="s">&quot;http://blog.notmyidea.org&quot;</span><span class="p">))</span> </pre></div> <p>And you get what you want.</p> <p>I must say I didn't thought it could work so easily. This will allow me to extract text content from URLs and remove the <em>boilerplate</em> text easily for infuse (my master thesis project), without having to write java code, nice!</p> </div> Un coup de main pour mon mémoire!2011-05-25T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-05-25:/un-coup-de-main-pour-mon-memoire.html/<p>Ça y est, bientôt la fin. LA FIN. La fin des études, et le début du reste. En attendant je bosse sur mon mémoire de fin d'études et j'aurais besoin d'un petit coup de main.</p> <p>Mon mémoire porte sur les systèmes de recommandation. Pour ceux qui connaissent last.fm, je fais quelque chose de similaire mais pour les sites internet: en me basant sur ce que vous visitez quotidiennement et comment vous le visitez (quelles horaires, quelle emplacement géographique, etc.) je souhaites proposer des liens qui vous intéresseront potentiellement, en me basant sur l'avis des personnes qui ont des profils similaires au votre.</p> <p>Le projet est loin d'être terminé, mais la première étape est de récupérer des données de navigation, idéalement beaucoup de données de navigation. Donc si vous pouvez me filer un coup de main je vous en serais éternellement reconnaissant (pour ceux qui font semblant de pas comprendre, entendez &quot;tournée générale&quot;).</p> <p>J'ai créé un petit site web (en anglais) qui résume un peu le concept, qui vous propose de vous inscrire et de télécharger un plugin firefox qui m'enverra des information sur les sites que vous visitez (si vous avez l'habitude d'utiliser chrome vous pouvez considérer de switcher à firefox4 pour les deux prochains mois pour me filer un coup de main). Il est possible de désactiver le plugin d'un simple clic si vous souhaitez garder votre vie privée privée ;-)</p> <p>Le site est par là: <a class="reference external" href="http://infuse.notmyidea.org">http://infuse.notmyidea.org</a>. Une fois le plugin téléchargé et le compte créé il faut renseigner vos identifiants dans le plugin en question, et c'est tout!</p> <p>A votre bon cœur ! Je récupérerais probablement des données durant les 2 prochains mois pour ensuite les analyser correctement.</p> <p>Merci pour votre aide !</p> Travailler moins pour mieux travailler ?2011-05-19T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-05-19:/travailler-moins-pour-mieux-travailler.html/<p>Je viens de passer une semaine et demi quasiment hors-ligne et je dois dire que je suis assez impressionné du résultat: je suis de retour chez mes parents pour le &quot;easter break&quot; et j'en ai profité pour donner un coup aux travaux de la maison (et pour me reposer un brin!).</p> <p>Bosser en extérieur est un réel plaisir et faire quelque chose de manuel également. Je n'ai pas pour habitude de bricoler autre chose que du logiciel et c'est vraiment quelque chose que j'apprécie.</p> <p>J'avoue, je mens un peu quand je dis que j'étais complètement déconnecté: j'ai vérifié mes mails assez régulièrement en utilisant mon téléphone (merci Arnaud pour le prêt du gadget!) et j'ai limité ma présence web au strict minimum. Je veux dire par là pas de twitter, pas d'IRC et autres mailing-lists.</p> <p>Quand je dis hors-ligne, je ne dis pas que je n'ai pas travaillé sur mon ordinateur. J'ai à fournir beaucoup plus de travail que ce que je ne pensait en premier lieu pour la rédaction de mon mémoire et j'ai passé quelques heures par ci par là à lire des articles et livres sur le sujet ainsi que rédigé une bonne partie de mon mémoire durant ces 10 jours. Résultat ? Les heures que j'ai passées à travailler ont été étonnement plus productives que celles que j'ai l'habitude de passer derrière un écran. Je ne parles pas uniquement du fait de procrastiner; évidemment c'est une des causes principales de ma perte de productivité, mais je pense également au fait de laisser le cerveau reposer, au moins en ce qui concerne la partie informatique. Bricoler demande de la concentration et de la réflexion mais permet également de laisser son esprit vagabonder. J'ai pu donc avancer mes sur certaines parties de mon mémoire alors que j'étais en train de poser le bardage sur la garage par exemple.</p> <p>Passer du temps sur autre chose (qui demandait également de la concentration par ailleurs) m'a permis d'être réellement plus efficace lors de mes phases de rédaction et de lecture.</p> <p>Je me demande depuis quelques temps quel sera mon futur travail et quelle forme il prendra. Éééh oui, la fin des études arrive pour la fin de l'année, c'est pas une blague. Et je me pose sérieusement la question du travail aux 3/4 temps. La raison principale étant que je ne souhaites pas passer la majeure partie de mon temps à travailler derrière un écran et que la formation que j'ai m'y rattache beaucoup. Ne me comprenez pas de travers: j'aime ce que je fais; mais j'aime aussi ce que je fais à coté de l'informatique: associatif, projets alternatifs, permaculture et autres.</p> <p>Viens s'ajouter à ça le fait d'avoir une qualité de vie qui me semble pouvoir passer par le fait de travailler moins (&quot;il est marant ce gamin, il à pas encore commencé à travailler qu'il veut bosser moins, regarde moi cette feignasse!&quot;) et travailler plus efficacement. Bien sur, on n'est jamais 100% productif et c'est d'autant plus vrai pour moi, alors si gagner en productivité peut passer par travailler moins, pourquoi pas s'y essayer !</p> <p>Peut être que vous pratiquez déjà le travail au 3/4 temps, que vous avez des retours d'expérience à faire : fausse bonne idée ? Vraie bonne idée ?</p> Analyse users' browsing context to build up a web recommender2011-04-01T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2011-04-01:/analyse-users-browsing-context-to-build-up-a-web-recommender.html/<p>No, this is not an april's fool ;)</p> <p>Wow, it's been a long time. My year in Oxford is going really well. I realized few days ago that the end of the year is approaching really quickly. Exams are coming in one month or such and then I'll be working full time on my dissertation topic.</p> <p>When I learned we'll have about 6 month to work on something, I first thought about doing a packaging related stuff, but finally decided to start something new. After all, that's the good time to learn.</p> <p>Since a long time, I'm being impressed by the <a class="reference external" href="http://last.fm">last.fm</a> recommender system. They're <em>scrobbling</em> the music I listen to since something like 5 years now and the recommendations they're doing are really nice and accurate (I discovered <strong>a lot</strong> of great artists listening to the &quot;neighbour radio&quot;.) (by the way, <a class="reference external" href="http://lastfm.com/user/akounet/">here is</a> my lastfm account)</p> <p>So I decided to work on recommender systems, to better understand what is it about.</p> <p>Recommender systems are usually used to increase the sales of products (like Amazon.com does) which is not really what I'm looking for (The one who know me a bit know I'm kind of sick about all this consumerism going on).</p> <p>Actually, the most simple thing I thought of was the web: I'm browsing it quite every day and each time new content appears. I've stopped to follow <a class="reference external" href="https://bitbucket.org/bruno/aspirator/">my feed reader</a> because of the information overload, and reduced drastically the number of people I follow <a class="reference external" href="http://twitter.com/ametaireau/">on twitter</a>.</p> <p>Too much information kills the information.</p> <p>You shall got what will be my dissertation topic: a recommender system for the web. Well, such recommender systems already exists, so I will try to add contextual information to them: you're probably not interested by the same topics at different times of the day, or depending on the computer you're using. We can also probably make good use of the way you browse to create groups into the content you're browsing (or even use the great firefox4 tab group feature).</p> <p>There is a large part of concerns to have about user's privacy as well.</p> <p>Here is my proposal (copy/pasted from the one I had to do for my master)</p> <div class="section" id="introduction-and-rationale"> <h2>Introduction and rationale</h2> <p>Nowadays, people surf the web more and more often. New web pages are created each day so the amount of information to retrieve is more important as the time passes. These users uses the web in different contexts, from finding cooking recipes to technical articles.</p> <p>A lot of people share the same interest to various topics, and the quantity of information is such than it's really hard to triage them efficiently without spending hours doing it. Firstly because of the huge quantity of information but also because the triage is something relative to each person. Although, this triage can be facilitated by fetching the browsing information of all particular individuals and put the in perspective.</p> <p>Machine learning is a branch of Artificial Intelligence (AI) which deals with how a program can learn from data. Recommendation systems are a particular application area of machine learning which is able to recommend things (links in our case) to the users, given a particular database containing the previous choices users have made.</p> <p>This browsing information is currently available in browsers. Even if it is not in a very usable format, it is possible to transform it to something useful. This information gold mine just wait to be used. Although, it is not as simple as it can seems at the first approach: It is important to take care of the context the user is in while browsing links. For instance, It's more likely that during the day, a computer scientist will browse computing related links, and that during the evening, he browse cooking recipes or something else.</p> <p>Page contents are also interesting to analyse, because that's what people browse and what actually contain the most interesting part of the information. The raw data extracted from the browsing can then be translated into something more useful (namely tags, type of resource, visit frequency, navigation context etc.)</p> <p>The goal of this dissertation is to create a recommender system for web links, including this context information.</p> <p>At the end of the dissertation, different pieces of software will be provided, from raw data collection from the browser to a recommendation system.</p> </div> <div class="section" id="background-review"> <h2>Background Review</h2> <p>This dissertation is mainly about data extraction, analysis and recommendation systems. Two different research area can be isolated: Data preprocessing and Information filtering.</p> <p>The first step in order to make recommendations is to gather some data. The more data we have available, the better it is (T. Segaran, 2007). This data can be retrieved in various ways, one of them is to get it directly from user's browsers.</p> <div class="section" id="data-preparation-and-extraction"> <h3>Data preparation and extraction</h3> <p>The data gathered from browsers is basically URLs and additional information about the context of the navigation. There is clearly a need to extract more information about the meaning of the data the user is browsing, starting by the content of the web pages.</p> <p>Because the information provided on the current Web is not meant to be read by machines (T. Berners Lee, 2001) there is a need of tools to extract meaning from web pages. The information needs to be preprocessed before stored in a machine readable format, allowing to make recommendations (Choochart et Al, 2004).</p> <p>Data preparation is composed of two steps: cleaning and structuring ( Castellano et Al, 2007). Because raw data can contain a lot of un-needed text (such as menus, headers etc.) and need to be cleaned prior to be stored. Multiple techniques can be used here and belongs to boilerplate removal and full text extraction (Kohlschütter et Al, 2010).</p> <p>Then, structuring the information: category, type of content (news, blog, wiki) can be extracted from raw data. This kind of information is not clearly defined by HTML pages so there is a need of tools to recognise them.</p> <p>Some context-related information can also be inferred from each resource. It can go from the visit frequency to the navigation group the user was in while browsing. It is also possible to determine if the user &quot;liked&quot; a resource, and determine a mark for it, which can be used by information filtering a later step (T. Segaran, 2007).</p> <p>At this stage, structuring the data is required. Storing this kind of information in RDBMS can be a bit tedious and require complex queries to get back the data in an usable format. Graph databases can play a major role in the simplification of information storage and querying.</p> </div> <div class="section" id="information-filtering"> <h3>Information filtering</h3> <p>To filter the information, three techniques can be used (Balabanovic et Al, 1997):</p> <ul class="simple"> <li>The content-based approach states that if an user have liked something in the past, he is more likely to like similar things in the future. So it's about establishing a profile for the user and compare new items against it.</li> <li>The collaborative approach will rather recommend items that other similar users have liked. This approach consider only the relationship between users, and not the profile of the user we are making recommendations to.</li> <li>the hybrid approach, which appeared recently combine both of the previous approaches, giving recommendations when items score high regarding user's profile, or if a similar user already liked it.</li> </ul> <p>Grouping is also something to consider at this stage (G. Myatt, 2007). Because we are dealing with huge amount of data, it can be useful to detect group of data that can fit together. Data clustering is able to find such groups (T. Segaran, 2007).</p> <p>References:</p> <ul class="simple"> <li>Balabanović, M., &amp; Shoham, Y. (1997). Fab: content-based, collaborative recommendation. Communications of the ACM, 40(3), 66–72. ACM. Retrieved March 1, 2011, from <a class="reference external" href="http://portal.acm.org/citation.cfm?id=245108.245124&amp;amp">http://portal.acm.org/citation.cfm?id=245108.245124&amp;amp</a>;.</li> <li>Berners-Lee, T., Hendler, J., &amp; Lassila, O. (2001). The semantic web: Scientific american. Scientific American, 284(5), 34–43. Retrieved November 21, 2010, from <a class="reference external" href="http://www.citeulike.org/group/222/article/1176986">http://www.citeulike.org/group/222/article/1176986</a>.</li> <li>Castellano, G., Fanelli, A., &amp; Torsello, M. (2007). LODAP: a LOg DAta Preprocessor for mining Web browsing patterns. Proceedings of the 6th Conference on 6th WSEAS Int. Conf. on Artificial Intelligence, Knowledge Engineering and Data Bases-Volume 6 (p. 12–17). World Scientific and Engineering Academy and Society (WSEAS). Retrieved March 8, 2011, from <a class="reference external" href="http://portal.acm.org/citation.cfm?id=1348485.1348488">http://portal.acm.org/citation.cfm?id=1348485.1348488</a>.</li> <li>Kohlschutter, C., Fankhauser, P., &amp; Nejdl, W. (2010). Boilerplate detection using shallow text features. Proceedings of the third ACM international conference on Web search and data mining (p. 441–450). ACM. Retrieved March 8, 2011, from <a class="reference external" href="http://portal.acm.org/citation.cfm?id=1718542">http://portal.acm.org/citation.cfm?id=1718542</a>.</li> <li>Myatt, G. J. (2007). Making Sense of Data: A Practical Guide to Exploratory Data Analysis and Data Mining.</li> <li>Segaran, T. (2007). Collective Intelligence.</li> </ul> </div> </div> <div class="section" id="privacy"> <h2>Privacy</h2> <p>The first thing that's come to people minds when it comes to process their browsing data is privacy. People don't want to be stalked. That's perfectly right, and I don't either.</p> <p>But such a system don't have to deal with people identities. It's completely possible to process completely anonymous data, and that's probably what I'm gonna do.</p> <p>By the way, if you have interesting thoughts about that, if you do know projects that do seems related, fire the comments !</p> </div> <div class="section" id="what-s-the-plan"> <h2>What's the plan ?</h2> <p>There is a lot of different things to explore, especially because I'm a complete novice in that field.</p> <ul class="simple"> <li>I want to develop a firefox plugin, to extract the browsing informations ( still, I need to know exactly which kind of informations to retrieve). The idea is to provide some <em>raw</em> browsing data, and then to transform it and to store it in the better possible way.</li> <li>Analyse how to store the informations in a graph database. What can be the different methods to store this data and to visualize the relationship between different pieces of data? How can I define the different contexts, and add those informations in the db?</li> <li>Process the data using well known recommendation algorithms. Compare the results and criticize their value.</li> </ul> <p>There is plenty of stuff I want to try during this experimentation:</p> <ul class="simple"> <li>I want to try using Geshi to visualize the connexion between the links, and the contexts</li> <li>Try using graph databases such as Neo4j</li> <li>Having a deeper look at tools such as scikit.learn (a machine learning toolkit in python)</li> <li>Analyse web pages in order to categorize them. Processing their contents as well, to do some keyword based classification will be done.</li> </ul> <p>Lot of work on its way, yay !</p> </div> Working directly on your server? How to backup and sync your dev environment with unison2011-03-16T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-03-16:/working-directly-on-your-server-how-to-backup-and-sync-your-dev-environment-with-unison.html/<p>I have a server running freebsd since some time now, and was wondering about the possibility to directly have a development environment ready to use when I get a internet connexion, even if I'm not on my computer.</p> <p>Since I use vim to code, and spend most of my time in a console while developing, it's possible to work via ssh, from everywhere.</p> <p>The only problem is the synchronisation of the source code, config files etc. from my machine to the server.</p> <p>Unison provides an interesting way to synchronise two folders, even over a network. So let's do it !</p> <div class="section" id="creating-the-jail"> <h2>Creating the jail</h2> <p>In case you don't use FreeBSD, you can skip this section.</p> <div class="highlight"><pre><span class="c"># I have a flavour jail named default</span> <span class="nv">$ </span>ezjail-admin -f default workspace.notmyidea.org 172.19.1.6 <span class="nv">$ </span>ezjail-admin start workspace.notmyidea.org </pre></div> <p>In my case, because the &quot;default&quot; flavour contains already a lot of interesting things, my jail come already setup with ssh, bash and vim for instance, but maybe you'll need it in your case.</p> <p>I want to be redirected to the ssh of the jail when I connect to the host with the 20006 port. Add lines in <cite>/etc/pf.conf</cite>:</p> <pre class="literal-block"> workspace_jail=&quot;172.19.1.6&quot; rdr on $ext_if proto tcp from any to $ext_ip port 20006 -&gt; $workspace_jail port 22 </pre> <p>Reload packet filter rules</p> <div class="highlight"><pre><span class="nv">$ </span>/etc/rc.d/pf reload </pre></div> </div> <div class="section" id="working-with-unison"> <h2>Working with unison</h2> <p>Now that we've set up the jail. Set up unison on the server and on your client. Unison is available on the freebsd ports so just install it</p> <div class="highlight"><pre><span class="nv">$ </span>ssh notmyidea.org -p 20006 <span class="nv">$ </span>make -C /usr/ports/net/unison-nox11 config-recursive <span class="nv">$ </span>make -C /usr/ports/net/unison-nox11 package-recursive </pre></div> <p>Install as well unison on your local machine. Double check to install the same version on the client and on the server. Ubuntu contains the 2.27.57 as well as the 2.32.52.</p> <p>Check that unison is installed and reachable via ssh from your machine</p> <div class="highlight"><pre><span class="nv">$ </span>ssh notmyidea.org -p 20006 unison -version unison version 2.27.157 <span class="nv">$ </span>unison -version unison version 2.27.57 </pre></div> </div> <div class="section" id="let-sync-our-folders"> <h2>Let sync our folders</h2> <p>The first thing I want to sync is my vim configuration. Well, it's already <a class="reference external" href="http://github.com/ametaireau/dotfiles/">in a git repository</a> but let's try to use unison for it right now.</p> <p>I have two machines then: <cite>workspace</cite>, the jail, and <cite>ecureuil</cite> my laptop.</p> <div class="highlight"><pre>unison .vim ssh://notmyidea.org:20006/.vim unison .vimrc ssh://notmyidea.org:20006/.vimrc </pre></div> <p>It is also possible to put all the informations in a config file, and then to only run <cite>unison</cite>. (fire up <cite>vim ~/.unison/default.prf</cite>.</p> <p>Here is my config:</p> <pre class="literal-block"> root = /home/alexis root = ssh://notmyidea.org:20006 path = .vimrc path = dotfiles path = dev follow = Name * </pre> <p>My vimrc is in fact a symbolic link on my laptop, but I don't want to specify each of the links to unison. That's why the <cite>follow = Name *</cite> is for.</p> <p>The folders you want to synchronize are maybe a bit large. If so, considering others options such as rsync for the first import may be a good idea (I enjoyed my university huge upload bandwith to upload 2GB in 20mn ;)</p> </div> <div class="section" id="run-the-script-frequently"> <h2>Run the script frequently</h2> <p>Once that done, you just need to run the unison command line some times when you want to sync your two machines. I've wrote a tiny script to get some feedback from the sync:</p> <div class="highlight"><pre><span class="kn">import</span> <span class="nn">os</span> <span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span> <span class="n">DEFAULT_LOGFILE</span> <span class="o">=</span> <span class="s">&quot;~/unison.log&quot;</span> <span class="n">PROGRAM_NAME</span> <span class="o">=</span> <span class="s">&quot;Unison syncer&quot;</span> <span class="k">def</span> <span class="nf">sync</span><span class="p">(</span><span class="n">logfile</span><span class="o">=</span><span class="n">DEFAULT_LOGFILE</span><span class="p">,</span> <span class="n">program_name</span><span class="o">=</span><span class="n">PROGRAM_NAME</span><span class="p">):</span> <span class="c"># init</span> <span class="n">display_message</span> <span class="o">=</span> <span class="bp">True</span> <span class="n">error</span> <span class="o">=</span> <span class="bp">False</span> <span class="n">before</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> <span class="c"># call unison to make the sync</span> <span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s">&#39;unison -batch &gt; {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logfile</span><span class="p">))</span> <span class="c"># get the duration of the operation</span> <span class="n">td</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> <span class="o">-</span> <span class="n">before</span> <span class="n">delta</span> <span class="o">=</span> <span class="p">(</span><span class="n">td</span><span class="o">.</span><span class="n">microseconds</span> <span class="o">+</span> <span class="p">(</span><span class="n">td</span><span class="o">.</span><span class="n">seconds</span> <span class="o">+</span> <span class="n">td</span><span class="o">.</span><span class="n">days</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">3600</span><span class="p">)</span> <span class="o">*</span> <span class="mi">10</span><span class="o">**</span><span class="mi">6</span><span class="p">)</span> <span class="o">/</span> <span class="mi">10</span><span class="o">**</span><span class="mi">6</span> <span class="c"># check what was the last entry in the log</span> <span class="n">log</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">logfile</span><span class="p">))</span> <span class="n">lines</span> <span class="o">=</span> <span class="n">log</span><span class="o">.</span><span class="n">readlines</span><span class="p">()</span> <span class="k">if</span> <span class="s">&#39;No updates to propagate&#39;</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> <span class="n">display_message</span> <span class="o">=</span> <span class="bp">False</span> <span class="k">else</span><span class="p">:</span> <span class="n">output</span> <span class="o">=</span> <span class="p">[</span><span class="n">l</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">lines</span> <span class="k">if</span> <span class="s">&quot;Synchronization&quot;</span> <span class="ow">in</span> <span class="n">l</span><span class="p">]</span> <span class="n">message</span> <span class="o">=</span> <span class="n">output</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="n">message</span> <span class="o">+=</span> <span class="s">&quot; It took {0}s.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">delta</span><span class="p">)</span> <span class="k">if</span> <span class="n">display_message</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s">&#39;notify-send -i {2} &quot;{0}&quot; &quot;{1}&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">program_name</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="s">&#39;error&#39;</span> <span class="k">if</span> <span class="n">error</span> <span class="k">else</span> <span class="s">&#39;info&#39;</span><span class="p">))</span> <span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span> <span class="n">sync</span><span class="p">()</span> </pre></div> <p>This is probably perfectible, but that does the job.</p> <p>Last step is to tell you machine to run that frequently. That's what <cite>crontab</cite> is made for, so let's <cite>crontab -e</cite>:</p> <pre class="literal-block"> $ * */3 * * * . ~/.Xdbus; /usr/bin/python /home/alexis/dev/python/unison-syncer/sync.py </pre> <p>The <cite>~/.Xdbus</cite> allows cron to communicate with your X11 session. Here is its content.</p> <div class="highlight"><pre><span class="c">#!/bin/bash</span> <span class="c"># Get the pid of nautilus</span> <span class="nv">nautilus_pid</span><span class="o">=</span><span class="k">$(</span>pgrep -u <span class="nv">$LOGNAME</span> -n nautilus<span class="k">)</span> <span class="c"># If nautilus isn&#39;t running, just exit silently</span> <span class="k">if</span> <span class="o">[</span> -z <span class="s2">&quot;$nautilus_pid&quot;</span> <span class="o">]</span>; <span class="k">then</span> <span class="nb">exit </span>0 <span class="k">fi</span> <span class="c"># Grab the DBUS_SESSION_BUS_ADDRESS variable from nautilus&#39;s environment</span> <span class="nb">eval</span> <span class="k">$(</span>tr <span class="s1">&#39;\0&#39;</span> <span class="s1">&#39;\n&#39;</span> &lt; /proc/<span class="nv">$nautilus_pid</span>/environ | grep <span class="s1">&#39;^DBUS_SESSION_BUS_ADDRESS=&#39;</span><span class="k">)</span> <span class="c"># Check that we actually found it</span> <span class="k">if</span> <span class="o">[</span> -z <span class="s2">&quot;$DBUS_SESSION_BUS_ADDRESS&quot;</span> <span class="o">]</span>; <span class="k">then</span> <span class="nb">echo</span> <span class="s2">&quot;Failed to find bus address&quot;</span> &gt;&amp;2 <span class="nb">exit </span>1 <span class="k">fi</span> <span class="c"># export it so that child processes will inherit it</span> <span class="nb">export </span>DBUS_SESSION_BUS_ADDRESS </pre></div> <p>And it comes from <a class="reference external" href="http://ubuntuforums.org/showthread.php?p=10148738#post10148738">here</a>.</p> <p>A sync takes about 20s + the upload time on my machine, which stay acceptable for all of my developments.</p> </div> Wrap up of the distutils2 paris' sprint2011-02-08T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-02-08:/wrap-up-of-the-distutils2-paris-sprint.html/<p>Finally, thanks to a bunch of people that helped me to pay my train and bus tickets, I've made it to paris for the distutils2 sprint.</p> <p>They have been a bit more than 10 people to come during the sprint, and it was very productive. Here's a taste of what we've been working on:</p> <ul class="simple"> <li>the <cite>datafiles</cite>, a way to specify and to handle the installation of files which are not python-related (pictures, manpages and so on).</li> <li><cite>mkgcfg</cite>, a tool to help you to create a setup.cfg in minutes (and with funny examples)</li> <li>converters from setup.py scripts. We do now have a piece of code which reads your current <cite>setup.py</cite> file and fill in some fields in the <cite>setup.cfg</cite> for you.</li> <li>a compatibility layer for distutils1, so it can read the <cite>setup.cfg</cite> you will wrote for distutils2 :-)</li> <li>the uninstaller, so it's now possible to uninstall what have been installed by distutils2 (see PEP 376)</li> <li>the installer, and the setuptools compatibility layer, which will allow you to rely on setuptools' based distributions (and there are plenty of them!)</li> <li>The compilers, so they are more flexible than they were. Since that's an obscure part of the code for distutils2 commiters (it comes directly from the distutils1 ages), having some guys who understood the problematics here was a must.</li> </ul> <p>Some people have also tried to port their packaging from distutils1 to distutils2. They have spotted a number of bugs and made some improvements to the code, to make it more friendly to use.</p> <p>I'm really pleased to see how newcomers went trough the code, and started hacking so fast. I must say it wasn't the case when we started to work on distutils1 so that's a very good point: people now can hack the code quicker than they could before.</p> <p>Some of the features here are not <em>completely</em> finished yet, but are on the tubes, and will be ready for a release (hopefully) at the end of the week.</p> <p>Big thanks to logilab for hosting (and sponsoring my train ticket) and providing us food, and to bearstech for providing some money for breakfast and bears^Wbeers.</p> <p>Again, a big thanks to all the people who gave me money to pay the transport, I really wasn't expecting such thing to happen :-)</p> PyPI on CouchDB2011-01-20T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-01-20:/pypi-on-couchdb.html/<p>By now, there are two ways to retrieve data from PyPI (the Python Package Index). You can both rely on xml/rpc or on the &quot;simple&quot; API. The simple API is not so simple to use as the name suggest, and have several existing drawbacks.</p> <p>Basically, if you want to use informations coming from the simple API, you will have to parse web pages manually, to extract informations using some black vodoo magic. Badly, magic have a price, and it's sometimes impossible to get exactly the informations you want to get from this index. That's the technique currently being used by distutils2, setuptools and pip.</p> <p>On the other side, while XML/RPC is working fine, it's requiring extra work to the python servers each time you request something, which can lead to some outages from time to time. Also, it's important to point out that, even if PyPI have a mirroring infrastructure, it's only for the so-called <em>simple</em> API, and not for the XML/RPC.</p> <div class="section" id="couchdb"> <h2>CouchDB</h2> <p>Here comes CouchDB. CouchDB is a document oriented database, that knows how to speak REST and JSON. It's easy to use, and provides out of the box a replication mechanism.</p> </div> <div class="section" id="so-what"> <h2>So, what ?</h2> <p>Hmm, I'm sure you got it. I've wrote a piece of software to link informations from PyPI to a CouchDB instance. Then you can replicate all the PyPI index with only one HTTP request on the CouchDB server. You can also access the informations from the index directly using a REST API, speaking json. Handy.</p> <p>So PyPIonCouch is using the PyPI XML/RPC API to get data from PyPI, and generate records in the CouchDB instance.</p> <p>The final goal is to avoid to rely on this &quot;simple&quot; API, and rely on a REST insterface instead. I have set up a couchdb server on my server, which is available at <a class="reference external" href="http://couchdb.notmyidea.org/_utils/database.html?pypi">http://couchdb.notmyidea.org/_utils/database.html?pypi</a>.</p> <p>There is not a lot to see there for now, but I've done the first import from PyPI yesterday and all went fine: it's possible to access the metadata of all PyPI projects via a REST interface. Next step is to write a client for this REST interface in distutils2.</p> </div> <div class="section" id="example"> <h2>Example</h2> <p>For now, you can use pypioncouch via the command line, or via the python API.</p> <div class="section" id="using-the-command-line"> <h3>Using the command line</h3> <p>You can do something like that for a full import. This <strong>will</strong> take long, because it's fetching all the projects at pypi and importing their metadata:</p> <pre class="literal-block"> $ pypioncouch --fullimport http://your.couchdb.instance/ </pre> <p>If you already have the data on your couchdb instance, you can just update it with the last informations from pypi. <strong>However, I recommend to just replicate the principal node, hosted at http://couchdb.notmyidea.org/pypi/</strong>, to avoid the duplication of nodes:</p> <pre class="literal-block"> $ pypioncouch --update http://your.couchdb.instance/ </pre> <p>The principal node is updated once a day by now, I'll try to see if it's enough, and ajust with the time.</p> </div> <div class="section" id="using-the-python-api"> <h3>Using the python API</h3> <p>You can also use the python API to interact with pypioncouch:</p> <pre class="literal-block"> &gt;&gt;&gt; from pypioncouch import XmlRpcImporter, import_all, update &gt;&gt;&gt; full_import() &gt;&gt;&gt; update() </pre> </div> </div> <div class="section" id="what-s-next"> <h2>What's next ?</h2> <p>I want to make a couchapp, in order to navigate PyPI easily. Here are some of the features I want to propose:</p> <ul class="simple"> <li>List all the available projects</li> <li>List all the projects, filtered by specifiers</li> <li>List all the projects by author/maintainer</li> <li>List all the projects by keywords</li> <li>Page for each project.</li> <li>Provide a PyPI &quot;Simple&quot; API equivalent, even if I want to replace it, I do think it will be really easy to setup mirrors that way, with the out of the box couchdb replication</li> </ul> <p>I also still need to polish the import mechanism, so I can directly store in couchdb:</p> <ul class="simple"> <li>The OPML files for each project</li> <li>The upload_time as couchdb friendly format (list of int)</li> <li>The tags as lists (currently it's only a string separated by spaces</li> </ul> <p>The work I've done by now is available on <a class="reference external" href="https://bitbucket.org/ametaireau/pypioncouch/">https://bitbucket.org/ametaireau/pypioncouch/</a>. Keep in mind that it's still a work in progress, and everything can break at any time. However, any feedback will be appreciated !</p> </div> Help me to go to the distutils2 paris' sprint2011-01-15T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2011-01-15:/help-me-to-go-to-the-distutils2-paris-sprint.html/<p><strong>Edit: Thanks to logilab and some amazing people, I can make it to paris for the sprint. Many thanks to them for the support!</strong></p> <p>There will be a distutils2 sprint from the 27th to the 30th of january, thanks to logilab which will host the event.</p> <p>You can find more informations about the sprint on the wiki page of the event (<a class="reference external" href="http://wiki.python.org/moin/Distutils/SprintParis">http://wiki.python.org/moin/Distutils/SprintParis</a>).</p> <p>I really want to go there but I'm unfortunately blocked in UK for money reasons. The cheapest two ways I've found is about £80, which I can't afford. Following some advices on #distutils, I've set up a ChipIn account for that, so if some people want to help me making it to go there, they can give me some money that way.</p> <p>I'll probably work on the installer (to support old distutils and setuptools distributions) and on the uninstaller (depending on the first task). If I can't make it to paris, I'll hang around on IRC to give some help while needed.</p> <p>If you want to contribute some money to help me go there, feel free to use this chipin page: <a class="reference external" href="http://ametaireau.chipin.com/distutils2-sprint-in-paris">http://ametaireau.chipin.com/distutils2-sprint-in-paris</a></p> <p>Thanks for your support !</p> Fork you ! or how the social coding can help you2010-11-05T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2010-11-05:/fork-you-or-how-the-social-coding-can-help-you.html/<p>With <a class="reference external" href="http://github.com">github</a> and <a class="reference external" href="http://www.bitbucket.org">bitbucket</a> coming around, a lot of new usages appears for the developpers: it's now easy to get feedback on your code/modifications, and to get help from others by, for instance, forking repositories.</p> <p>Eeach time I see people helping others, I'm amazed by how we like to share our knowledge.</p> <p>I say github, because it seems to be the more mainstream, but I think it's something strongly related to the <a class="reference external" href="http://en.wikipedia.org/wiki/Distributed_revision_control">DVCS</a> principles: the &quot;only&quot; thing github have made is to turn that into a social network, and to reveal the awesomeness of the DVCSes to the masses.</p> <p>What is really interesting is to see how this platform is addictive: it's automatically updating a webpages with the more accurate informations about the projects you're involved in, and add a bit of magic to that using webhooks, allowing you to update your website each time you push to you repository, for instance.</p> <p>Quite nothing, indeed, but, I don't know why, I find this fascinating.</p> <p>I haven't had the privilege to see my projects forked from github by strangers, but I've forked others repository to give an hand some times, when I wanted to, and the main reason is &quot;because it's <strong>fun</strong>&quot; to do so.</p> <p>Yeah, you're probably right, you have to be a nerd to find fun to fork others. The good point is that geeks are a kind of nerds, and some geeks are coders :)</p> <div class="section" id="new-ways-to-contribute"> <h2>New ways to contribute</h2> <p>In addition, it seems that he community, or the communities, are there, on those new social networks for coders. It's really handy to drop an eye on interesting projects, to report bugs, propose new features, and check what new projects this or this person have made.</p> <p>Well, &quot;it's not new&quot;, you may think. That's true, because it's been a while that SVN was there and even CVS before that. But, it was a bit messy to &quot;fork&quot; a project, isn't it ? And I'm not talking about all the hell SVN involved with it (who have not had issues with those messy .svn folders raises an hand !).</p> <p>It have not been so easy to share code and thoughts about code, to propose changes on existing code, than now. You think it's better to implement this or that in a different way ? Clone it (fork it), make your changes and publish them, and then ask projects owners about it. For sure you'll have answers.</p> <p>Even if they don't want it, you can easily keep your changes, and keep getting their updates!</p> <p>Also, lot of <em>fashionables</em> projects tend to move on DVCS. Personally, if I know I can fork on a DVCS instead of from a &quot;simple&quot; VCS, I'll probably be quicker to fork/clone, and to publish changes on my own copy, than if I had to do so on the upstream repository (and I'll likely dont have the rights to push to it), because I will not be afraid to break things.</p> <p>DVCSes makes the contribution easier.</p> </div> <div class="section" id="release-early-release-often"> <h2>Release early, release often</h2> <p>Maybe have you read <a class="reference external" href="http://www.catb.org/~esr/writings/cathedral-bazaar/">The cathedral and the bazaar</a>, by Eric Steven Raymond ? (If not, consider doing so, it's a really interesting reading)</p> <p>Among a lot of others interesting things, one hint he gives is <em>release early, release often</em>.</p> <p>I understand it as: if you want to get contributors, release your code early, even if it's not perfect, and don't be afraid to publish your changes each time it's needed.</p> <p>Without notifying it, that's basically what I was doing for my own projects. I guess that's because Social coding platforms encourages those practices, partially cause of the possible impact publishing each of your changes can have on your final solution.</p> <p>If you have considered publishing your projects, code snippets, or whatever (code related) but did not done it, considering them not yet ready, maybe should you think about it twice: you can get feedback and probably start some interesting discussions about it, if you write code that's readable, of course!</p> </div> <div class="section" id="a-step-further-for-open-source-softwares"> <h2>A step further for open source softwares</h2> <p>Well, DVCSes are a honking great idea, and they're starting to be really powerful when applied to free softwares. I mean: if you can't see a project, it will be hard to contribute to it. And, I don't think anyone wants to contribute to something closed/proprietary, <em>just for fun</em>. Or maybe am I missing something.</p> <p>Maybe it's a kind of revolution, about free and open source softwares (<a class="reference external" href="http://en.wikipedia.org/wiki/Free_and_open_source_software">FOSS</a>), that is going on. I really like to know I have my word to say about the changes in the tools I use, and to know that I can make them evolve.</p> <p>Let's take an example. Imagine I'm using a web framework on daily basis, as a part of my job as a web developer. I do like using an open source software because I know how it's working, and because I know that I can interact with the authors of the framework while they're doing the changes on it.</p> <p>That's communication, nothing more, and of course I can do that with an internal proprietary solution, but it will cost me <strong>a lot</strong> more time, for a dead-simple reason: a company is not as big and powerful as a community can be: it will cost time to work on this framework, resources to maintain it, fix bugs etc.</p> <p>Well, I'm starting advocating here about Free and Open Source Softwares use on companies, what is a bit beyond the scope of this article, so let's back to our DVCSes and new social related tools.</p> <p>If I find a bug in this framework, while working, I have the possibility to go and talk with the creators of the framework, to open a ticket, and even to make a fix for it, because I've access to the source code. If I want to create a new feature, I just have to fork it, hack it, and then publish my code to have feedback of the community.</p> <p>My fix/work will benefit to all the people (and maybe others companies) working with this framework, and it's a way to prove the community that my company is enough skilled to make code-fixes to the framework, so that's all good !</p> </div> <div class="section" id="what-s-next"> <h2>What's next ?</h2> <p>I hope those social coding platforms are only the begining of a new area. I hope they will make people realize what the power of the community is, and how easily they can becomes part of it.</p> <p>If you're not using them right now, maybe you should do so: have a look on how the programs you're using are made, consider publishing your experimentations, and share them with others, you will see, it's kind of addictive !</p> </div> How to reboot your bebox using the CLI2010-10-21T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-10-21:/how-to-reboot-your-bebox-using-the-cli.html/<p>I've an internet connection which, for some obscure reasons, tend to be very slow from time to time. After rebooting the box (yes, that's a hard solution), all the things seems to go fine again.</p> <div class="section" id="edit-using-grep"> <h2>EDIT : Using grep</h2> <p>After a bit of reflexion, that's also really easy to do using directly the command line tools curl, grep and tail (but really harder to read).</p> <div class="highlight"><pre>curl -X POST -u joel:joel http://bebox.config/cgi/b/info/restart/<span class="se">\?</span>be<span class="se">\=</span>0<span class="se">\&amp;</span>l0<span class="se">\=</span>1<span class="se">\&amp;</span>l1<span class="se">\=</span>0<span class="se">\&amp;</span>tid<span class="se">\=</span>RESTART -d <span class="s2">&quot;0=17&amp;2=`curl -u joel:joel http://bebox.config/cgi/b/info/restart/\?be\=0\&amp;l0\=1\&amp;l1\=0\&amp;tid\=RESTART | grep -o &quot;</span><span class="nv">name</span><span class="o">=</span><span class="s1">&#39;2&#39;</span> <span class="nv">value</span><span class="o">=</span><span class="err">&#39;</span><span class="o">[</span>0-9<span class="o">]</span><span class="se">\+</span><span class="s2">&quot; | grep -o &quot;</span><span class="o">[</span>0-9<span class="o">]</span><span class="se">\+</span><span class="s2">&quot; | tail -n 1`&amp;1&quot;</span> </pre></div> </div> <div class="section" id="the-python-version"> <h2>The Python version</h2> <p>Well, that's not the optimal solution, that's a bit &quot;gruik&quot;, but it works.</p> <div class="highlight"><pre><span class="kn">import</span> <span class="nn">urllib2</span> <span class="kn">import</span> <span class="nn">urlparse</span> <span class="kn">import</span> <span class="nn">re</span> <span class="kn">import</span> <span class="nn">argparse</span> <span class="n">REBOOT_URL</span> <span class="o">=</span> <span class="s">&#39;/b/info/restart/?be=0&amp;l0=1&amp;l1=0&amp;tid=RESTART&#39;</span> <span class="n">BOX_URL</span> <span class="o">=</span> <span class="s">&#39;http://bebox.config/cgi&#39;</span> <span class="k">def</span> <span class="nf">open_url</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">):</span> <span class="n">passman</span> <span class="o">=</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">HTTPPasswordMgrWithDefaultRealm</span><span class="p">()</span> <span class="n">passman</span><span class="o">.</span><span class="n">add_password</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">)</span> <span class="n">authhandler</span> <span class="o">=</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">HTTPBasicAuthHandler</span><span class="p">(</span><span class="n">passman</span><span class="p">)</span> <span class="n">opener</span> <span class="o">=</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">build_opener</span><span class="p">(</span><span class="n">authhandler</span><span class="p">)</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">install_opener</span><span class="p">(</span><span class="n">opener</span><span class="p">)</span> <span class="k">return</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> <span class="k">def</span> <span class="nf">reboot</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">):</span> <span class="n">data</span> <span class="o">=</span> <span class="n">open_url</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">)</span> <span class="n">token</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="s">&quot;name\=</span><span class="se">\\</span><span class="s">&#39;2</span><span class="se">\\</span><span class="s">&#39; value=</span><span class="se">\\</span><span class="s">&#39;([0-9]+)</span><span class="se">\\</span><span class="s">&#39;&quot;</span><span class="p">,</span> <span class="n">data</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">urllib2</span><span class="o">.</span><span class="n">Request</span><span class="p">(</span><span class="n">url</span><span class="o">=</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s">&#39;0=17&amp;2=</span><span class="si">%s</span><span class="s">&amp;1&#39;</span> <span class="o">%</span> <span class="n">token</span><span class="p">))</span> <span class="k">if</span> <span class="n">__file__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span> <span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s">&quot;&quot;&quot;Reboot your bebox !&quot;&quot;&quot;</span><span class="p">)</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="n">dest</span><span class="o">=</span><span class="s">&#39;user&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s">&#39;username&#39;</span><span class="p">)</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="n">dest</span><span class="o">=</span><span class="s">&#39;password&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s">&#39;password&#39;</span><span class="p">)</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="n">boxurl</span><span class="o">=</span><span class="s">&#39;boxurl&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">BOX_URL</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s">&#39;Base box url. Default is </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">BOX_URL</span><span class="p">)</span> <span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">()</span> <span class="n">url</span> <span class="o">=</span> <span class="n">urlparse</span><span class="o">.</span><span class="n">urljoin</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">boxurl</span><span class="p">,</span> <span class="n">REBOOT_URL</span><span class="p">)</span> <span class="n">reboot</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">username</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">password</span><span class="p">)</span> </pre></div> </div> Dynamically change your gnome desktop wallpaper2010-10-11T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-10-11:/dynamically-change-your-gnome-desktop-wallpaper.html/<p>In gnome, you can can use a XML file to have a dynamic wallpaper. It's not so easy, and you can't just tell: use the pictures in this folder to do so.</p> <p>You can have a look to the git repository if you want: <a class="reference external" href="http://github.com/ametaireau/gnome-background-generator">http://github.com/ametaireau/gnome-background-generator</a></p> <p>Some time ago, I've made a little python script to ease that, and you can now use it too. It's named &quot;gnome-background-generator&quot;, and you can install it via pip for instance.</p> <div class="highlight"><pre>$ pip install gnome-background-generator </pre></div> <p>Then, you have just to use it this way:</p> <div class="highlight"><pre>$ gnome-background-generator -p ~/Images/walls -s /home/alexis/Images/walls/dynamic-wallpaper.xml generated </pre></div> <p>Here is a extract of the <cite>--help</cite>:</p> <div class="highlight"><pre>$ gnome-background-generator --help usage: gnome-background-generator [-h] [-p PATH] [-o OUTPUT] [-t TRANSITION_TIME] [-d DISPLAY_TIME] [-s] [-b] A simple command line tool to generate an XML file to use for gnome wallpapers, to have dynamic walls optional arguments: -h, --help show this help message and exit -p PATH, --path PATH Path to look for the pictures. If no output is specified, will be used too for outputing the dynamic- wallpaper.xml file. Default value is the current directory (.) -o OUTPUT, --output OUTPUT Output filename. If no filename is specified, a dynamic-wallpaper.xml file will be generated in the path containing the pictures. You can also use &quot;-&quot; to display the xml in the stdout. -t TRANSITION_TIME, --transition-time TRANSITION_TIME Time (in seconds) transitions must last (default value is 2 seconds) -d DISPLAY_TIME, --display-time DISPLAY_TIME Time (in seconds) a picture must be displayed. Default value is 900 (15mn) -s, --set-background &#39;&#39;&#39;try to set the background using gnome-appearance- properties -b, --debug </pre></div> How to install NGINX + PHP 5.3 on FreeBSD.2010-10-10T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-10-10:/how-to-install-nginx-php-53-on-freebsd.html/<p>I've not managed so far to get completely rid of php, so here's a simple reminder about how to install php on NGINX, for FreeBSD. Nothing hard, but that's worse to have the piece of configuration somewhere !</p> <pre class="literal-block"> # update the ports $ portsnap fetch update # install php5 port $ make config-recursive -C /usr/ports/lang/php5-extensions $ make package-recursive -C /usr/ports/lang/php5-extensions # install nginx $ make config-recursive -C /usr/ports/www/nginx-devel $ make package-recursive -C /usr/ports/www/nginx-devel </pre> <p>Now we have all the dependencies installed, we need to configure a bit the server.</p> <p>That's a simple thing in fact, but it could be good to have something that will work without effort over time.</p> <p>Here's a sample of my configuration:</p> <pre class="literal-block"> server { server_name ndd; set $path /path/to/your/files; root $path; location / { index index.php; } location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { access_log off; expires 30d; } location ~ .php$ { fastcgi_param SCRIPT_FILENAME $path$fastcgi_script_name; fastcgi_pass backend; include fastcgi_params; } } upstream backend { server 127.0.0.1:9000; } </pre> <p>And that's it !</p> Pelican, a simple static blog generator in python2010-10-06T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-10-06:/pelican-a-simple-static-blog-generator-in-python.html/<p>Those days, I've wrote a little python application to fit my blogging needs. I'm an occasional blogger, a vim lover, I like restructured text and DVCSes, so I've made a little tool that makes good use of all that.</p> <p><a class="reference external" href="http://alexis.notmyidea.org/pelican/">Pelican</a> (for calepin) is just a simple tool to generate your blog as static files, letting you using your editor of choice (vim!). It's easy to extend, and has a template support (via jinja2).</p> <p>I've made it to fit <em>my</em> needs. I hope it will fit yours, but maybe it wont, and it have not be designed to feet everyone's needs.</p> <p>Need an example ? You're looking at it ! This weblog is using pelican to be generated, also for the atom feeds.</p> <p>I've released it under AGPL, since I want all the modifications to be profitable to all the users.</p> <p>You can find a mercurial repository to fork at <a class="reference external" href="http://hg.lolnet.org/pelican/">http://hg.lolnet.org/pelican/</a>, feel free to hack it !</p> <p>If you just want to get started, use your installer of choice (pip, easy_install, …) And then have a look to the help (<cite>pelican --help</cite>)</p> <div class="highlight"><pre><span class="nv">$ </span>pip install pelican </pre></div> <div class="section" id="usage"> <h2>Usage</h2> <p>Here's a sample usage of pelican</p> <div class="highlight"><pre><span class="nv">$ </span>pelican . writing /home/alexis/projets/notmyidea.org/output/index.html writing /home/alexis/projets/notmyidea.org/output/tags.html writing /home/alexis/projets/notmyidea.org/output/categories.html writing /home/alexis/projets/notmyidea.org/output/archives.html writing /home/alexis/projets/notmyidea.org/output/category/python.html writing /home/alexis/projets/notmyidea.org/output/pelican-a-simple-static-blog-generator-in-python.html Done ! </pre></div> <p>You also can use the <cite>--help</cite> option for the command line to get more informations</p> <div class="highlight"><pre><span class="nv">$pelican</span> --help usage: pelican <span class="o">[</span>-h<span class="o">]</span> <span class="o">[</span>-t TEMPLATES<span class="o">]</span> <span class="o">[</span>-o OUTPUT<span class="o">]</span> <span class="o">[</span>-m MARKUP<span class="o">]</span> <span class="o">[</span>-s SETTINGS<span class="o">]</span> <span class="o">[</span>-b<span class="o">]</span> path A tool to generate a static blog, with restructured text input files. positional arguments: path Path where to find the content files <span class="o">(</span>default is <span class="s2">&quot;content&quot;</span><span class="o">)</span>. optional arguments: -h, --help show this <span class="nb">help </span>message and <span class="nb">exit</span> -t TEMPLATES, --templates-path TEMPLATES Path where to find the templates. If not specified, will uses the ones included with pelican. -o OUTPUT, --output OUTPUT Where to output the generated files. If not specified, a directory will be created, named <span class="s2">&quot;output&quot;</span> in the current path. -m MARKUP, --markup MARKUP the markup language to use. Currently only ReSTreucturedtext is available. -s SETTINGS, --settings SETTINGS the settings of the application. Default to None. -b, --debug </pre></div> <p>Enjoy :)</p> </div> An amazing summer of code working on distutils22010-08-16T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-08-16:/an-amazing-summer-of-code-working-on-distutils2.html/<p>The <a class="reference external" href="http://code.google.com/soc/">Google Summer of Code</a> I've spent working on <a class="reference external" href="http://hg.python.org/distutils2/">distutils2</a> is over. It was a really amazing experience, for many reasons.</p> <p>First of all, we had a very good team, we were 5 students working on distutils2: <a class="reference external" href="http://zubin71.wordpress.com">Zubin</a>, <a class="reference external" href="http://wokslog.wordpress.com/">Éric</a>, <a class="reference external" href="http://gsoc.djolonga.com/">Josip</a>, <a class="reference external" href="http://konryd.blogspot.com/">Konrad</a> and me. In addition, <a class="reference external" href="http://mouadino.blogspot.com/">Mouad</a> have worked on the PyPI testing infrastructure. You could find what each person have done on <a class="reference external" href="http://bitbucket.org/tarek/distutils2/wiki/GSoC_2010_teams">the wiki page of distutils2</a>.</p> <p>We were in contact with each others really often, helping us when possible (in #distutils), and were continuously aware of the state of the work of each participant. This, in my opinion, have bring us in a good shape.</p> <p>Then, I've learned a lot. Python packaging was completely new to me at the time of the GSoC start, and I was pretty unfamiliar with python good practices too, as I've been introducing myself to python in the late 2009.</p> <p>I've recently looked at some python code I wrote just three months ago, and I was amazed to think about many improvements to made on it. I guess this is a good indicator of the path I've traveled since I wrote it.</p> <p>This summer was awesome because I've learned about python good practices, now having some strong <a class="reference external" href="http://mercurial.selenic.com/">mercurial</a> knowledge, and I've seen a little how the python community works.</p> <p>Then, I would like to say a big thanks to all the mentors that have hanged around while needed, on IRC or via mail, and especially my mentor for this summer, <a class="reference external" href="http://tarek.ziade.org">Tarek Ziadé</a>.</p> <p>Thanks a lot for your motivation, your leadership and your cheerfulness, even with a new-born and a new work!</p> <div class="section" id="why"> <h2>Why ?</h2> <p>I wanted to work on python packaging because, as the time pass, we were having a sort of complex tools in this field. Each one wanted to add features to distutils, but not in a standard way.</p> <p>Now, we have PEPs that describes some format we agreed on (see PEP 345), and we wanted to have a tool on which users can base their code on, that's <a class="reference external" href="http://hg.python.org/distutils2/">distutils2</a>.</p> </div> <div class="section" id="my-job"> <h2>My job</h2> <p>I had to provides a way to crawl the PyPI indexes in a simple way, and do some installation / uninstallation scripts.</p> <p>All the work done is available in <a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/">my bitbucket repository</a>.</p> <div class="section" id="crawling-the-pypi-indexes"> <h3>Crawling the PyPI indexes</h3> <p>There are two ways of requesting informations from the indexes: using the &quot;simple&quot; index, that is a kind of REST index, and using XML-RPC.</p> <p>I've done the two implementations, and a high level API to query those twos. Basically, this supports the mirroring infrastructure defined in PEP 381. So far, the work I've done is gonna be used in pip (they've basically copy/paste the code, but this will change as soon as we get something completely stable for distutils2), and that's a good news, as it was the main reason for what I've done that.</p> <p>I've tried to have an unified API for the clients, to switch from one to another implementation easily. I'm already thinking of adding others crawlers to this stuff, and it was made to be extensible.</p> <p>If you want to get more informations about the crawlers/PyPI clients, please refer to the distutils2 documentation, especially <a class="reference external" href="http://distutils2.notmyidea.org/library/distutils2.index.html">the pages about indexes</a>.</p> <p>You can find the changes I made about this in the <a class="reference external" href="http://hg.python.org/distutils2/">distutils2</a> source code .</p> </div> <div class="section" id="installation-uninstallation-scripts"> <h3>Installation / Uninstallation scripts</h3> <p>Next step was to think about an installation script, and an uninstaller. I've not done the uninstaller part, and it's a smart part, as it's basically removing some files from the system, so I'll probably do it in a near future.</p> <p><a class="reference external" href="http://hg.python.org/distutils2/">distutils2</a> provides a way to install distributions, and to handle dependencies between releases. For now, this support is only about the last version of the METADATA (1.2) (See, the PEP 345), but I'm working on a compatibility layer for the old metadata, and for the informations provided via PIP requires.txt, for instance.</p> </div> <div class="section" id="extra-work"> <h3>Extra work</h3> <p>Also, I've done some extra work. this includes:</p> <ul class="simple"> <li>working on the PEP 345, and having some discussion about it (about the names of some fields).</li> <li>writing a PyPI server mock, useful for tests. you can find more information about it on the <a class="reference external" href="http://distutils.notmyidea.org">documentation</a>.</li> </ul> </div> </div> <div class="section" id="futures-plans"> <h2>Futures plans</h2> <p>As I said, I've enjoyed working on distutils2, and the people I've met here are really pleasant to work with. So I <em>want</em> to continue contributing on python, and especially on python packaging, because there is still a lot of things to do in this scope, to get something really usable.</p> <p>I'm not plainly satisfied by the work I've done, so I'll probably tweak it a bit: the installer part is not yet completely finished, and I want to add support for a real <a class="reference external" href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> index in the future.</p> <p>We'll talk again of this in the next months, probably, but we definitely need a real <a class="reference external" href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> API for <a class="reference external" href="http://pypi.python.org">PyPI</a>, as the &quot;simple&quot; index <em>is</em> an ugly hack, in my opinion. I'll work on a serious proposition about this, maybe involving <a class="reference external" href="http://couchdb.org">CouchDB</a>, as it seems to be a good option for what we want here.</p> </div> <div class="section" id="issues"> <h2>Issues</h2> <p>I've encountered some issues during this summer. The main one is that's hard to work remotely, especially being in the same room that we live, with others. I like to just think about a project with other people, a paper and a pencil, no computers. This have been not so possible at the start of the project, as I needed to read a lot of code to understand the codebase, and then to read/write emails.</p> <p>I've finally managed to work in an office, so good point for home/office separation.</p> <p>I'd not planned there will be so a high number of emails to read, in order to follow what's up in the python world, and be a part of the community seems to takes some times to read/write emails, especially for those (like me) that arent so confortable with english (but this had brought me some english fu !).</p> </div> <div class="section" id="thanks"> <h2>Thanks !</h2> <p>A big thanks to <a class="reference external" href="http://www.graine-libre.fr/">Graine Libre</a> and <a class="reference external" href="http://www.makina-corpus.com/">Makina Corpus</a>, which has offered me to come into their offices from time to time, to share they cheerfulness ! Many thanks too to the Google Summer of Code program for setting up such an initiative. If you're a student, if you're interested about FOSS, dont hesitate any second, it's a really good opportunity to work on interesting projects!</p> </div> Introducing the distutils2 index crawlers2010-07-06T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-07-06:/introducing-the-distutils2-index-crawlers.html/<p>I'm working for about a month for distutils2, even if I was being a bit busy (as I had some class courses and exams to work on)</p> <p>I'll try do sum-up my general feelings here, and the work I've made so far. You can also find, if you're interested, my weekly summaries in <a class="reference external" href="http://wiki.notmyidea.org/distutils2_schedule">a dedicated wiki page</a>.</p> <div class="section" id="general-feelings"> <h2>General feelings</h2> <p>First, and it's a really important point, the GSoC is going very well, for me as for other students, at least from my perspective. It's a pleasure to work with such enthusiast people, as this make the global atmosphere very pleasant to live.</p> <p>First of all, I've spent time to read the existing codebase, and to understand what we're going to do, and what's the rationale to do so.</p> <p>It's really clear for me now: what we're building is the foundations of a packaging infrastructure in python. The fact is that many projects co-exists, and comes all with their good concepts. Distutils2 tries to take the interesting parts of all, and to provide it in the python standard libs, respecting the recently written PEP about packaging.</p> <p>With distutils2, it will be simpler to make &quot;things&quot; compatible. So if you think about a new way to deal with distributions and packaging in python, you can use the Distutils2 APIs to do so.</p> </div> <div class="section" id="tasks"> <h2>Tasks</h2> <p>My main task while working on distutils2 is to provide an installation and an un-installation command, as described in PEP 376. For this, I first need to get informations about the existing distributions (what's their version, name, metadata, dependencies, etc.)</p> <p>The main index, you probably know and use, is PyPI. You can access it at <a class="reference external" href="http://pypi.python.org">http://pypi.python.org</a>.</p> </div> <div class="section" id="pypi-index-crawling"> <h2>PyPI index crawling</h2> <p>There is two ways to get these informations from PyPI: using the simple API, or via xml-rpc calls.</p> <p>A goal was to use the version specifiers defined in`PEP 345 &lt;<a class="reference external" href="http://www.python.org/dev/peps/pep-0345/">http://www.python.org/dev/peps/pep-0345/</a>&gt;`_ and to provides a way to sort the grabbed distributions depending our needs, to pick the version we want/need.</p> <div class="section" id="using-the-simple-api"> <h3>Using the simple API</h3> <p>The simple API is composed of HTML pages you can access at <a class="reference external" href="http://pypi.python.org/simple/">http://pypi.python.org/simple/</a>.</p> <p>Distribute and Setuptools already provides a crawler for that, but it deals with their internal mechanisms, and I found that the code was not so clear as I want, that's why I've preferred to pick up the good ideas, and some implementation details, plus re-thinking the global architecture.</p> <p>The rules are simple: each project have a dedicated page, which allows us to get informations about:</p> <ul class="simple"> <li>the distribution download locations (for some versions)</li> <li>homepage links</li> <li>some other useful informations, as the bugtracker address, for instance.</li> </ul> <p>If you want to find all the distributions of the &quot;EggsAndSpam&quot; project, you could do the following (do not take so attention to the names here, as the API will probably change a bit):</p> <div class="highlight"><pre><span class="o">&gt;&gt;&gt;</span> <span class="n">index</span> <span class="o">=</span> <span class="n">SimpleIndex</span><span class="p">()</span> <span class="o">&gt;&gt;&gt;</span> <span class="n">index</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&quot;EggsAndSpam&quot;</span><span class="p">)</span> <span class="p">[</span><span class="n">EggsAndSpam</span> <span class="mf">1.1</span><span class="p">,</span> <span class="n">EggsAndSpam</span> <span class="mf">1.2</span><span class="p">,</span> <span class="n">EggsAndSpam</span> <span class="mf">1.3</span><span class="p">]</span> </pre></div> <p>We also could use version specifiers:</p> <div class="highlight"><pre><span class="o">&gt;&gt;&gt;</span> <span class="n">index</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&quot;EggsAndSpam (&lt; =1.2)&quot;</span><span class="p">)</span> <span class="p">[</span><span class="n">EggsAndSpam</span> <span class="mf">1.1</span><span class="p">,</span> <span class="n">EggsAndSpam</span> <span class="mf">1.2</span><span class="p">]</span> </pre></div> <p>Internally, what's done here is the following:</p> <ul class="simple"> <li>it process the <a class="reference external" href="http://pypi.python.org/simple/FooBar/">http://pypi.python.org/simple/FooBar/</a> page, searching for download URLs.</li> <li>for each found distribution download URL, it creates an object, containing informations about the project name, the version and the URL where the archive remains.</li> <li>it sort the found distributions, using version numbers. The default behavior here is to prefer source distributions (over binary ones), and to rely on the last &quot;final&quot; distribution (rather than beta, alpha etc. ones)</li> </ul> <p>So, nothing hard or difficult here.</p> <p>We provides a bunch of other features, like relying on the new PyPI mirroring infrastructure or filter the found distributions by some criterias. If you're curious, please browse the <a class="reference external" href="http://distutils2.notmyidea.org/">distutils2 documentation</a>.</p> </div> <div class="section" id="using-xml-rpc"> <h3>Using xml-rpc</h3> <p>We also can make some xmlrpc calls to retreive informations from PyPI. It's a really more reliable way to get informations from from the index (as it's just the index that provides the informations), but cost processes on the PyPI distant server.</p> <p>For now, this way of querying the xmlrpc client is not available on Distutils2, as I'm working on it. The main pieces are already present (I'll reuse some work I've made from the SimpleIndex querying, and <a class="reference external" href="http://github.com/ametaireau/pypiclient">some code already set up</a>), what I need to do is to provide a xml-rpc PyPI mock server, and that's on what I'm actually working on.</p> </div> </div> <div class="section" id="processes"> <h2>Processes</h2> <p>For now, I'm trying to follow the &quot;documentation, then test, then code&quot; path, and that seems to be really needed while working with a community. Code is hard to read/understand, compared to documentation, and it's easier to change.</p> <p>While writing the simple index crawling work, I must have done this to avoid some changes on the API, and some loss of time.</p> <p>Also, I've set up <a class="reference external" href="http://wiki.notmyidea.org/distutils2_schedule">a schedule</a>, and the goal is to be sure everything will be ready in time, for the end of the summer. (And now, I need to learn to follow schedules ...)</p> </div> Sprinting on distutils2 in Tours2010-07-06T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-07-06:/sprinting-on-distutils2-in-tours.html/<p>Yesterday, as I was traveling to Tours, I've took some time to visit Éric, another student who's working on distutils2 this summer, as a part of the GSoC. Basically, it was to take a drink, discuss a bit about distutils2, our respective tasks and general feelings, and to put a face on a pseudonym. I'd really enjoyed this time, because Éric knows a lot of things about mercurial and python good practices, and I'm eager to learn about those. So, we have discussed about things, have not wrote so much code, but have some things to propose so far, about documentation, and I also provides here some bribes of conversations we had.</p> <div class="section" id="documentation"> <h2>Documentation</h2> <p>While writing the PyPI simple index crawler documentation, I realized that we miss some structure, or how-to about the documentation. Yep, you read well. We lack documentation on how to make documentation. Heh. We're missing some rules to follow, and this lead to a not-so-structured final documentation. We probably target three type of publics, and we can split the documentation regarding those:</p> <ul class="simple"> <li><strong>Packagers</strong> who want to distribute their softwares.</li> <li><strong>End users</strong> who need to understand how to use end user commands, like the installer/uninstaller</li> <li><strong>packaging coders</strong> who <em>use</em> distutils2, as a base for building a package manager.</li> </ul> <p>We also need to discuss about a pattern to follow while writing documentation. How many parts do we need ? Where to put the API description ? etc. That's maybe seems to be not so important, but I guess the readers would appreciate to have the same structure all along distutils2 documentation.</p> </div> <div class="section" id="mercurial"> <h2>Mercurial</h2> <p>I'm really <em>not</em> a mercurial power user. I use it on daily basis, but I lack of basic knowledge about it. Big thanks Éric for sharing yours with me, you're of a great help. We have talked about some mercurial extensions that seems to make the life simpler, while used the right way. I've not used them so far, so consider this as a personal note.</p> <ul class="simple"> <li>hg histedit, to edit the history</li> <li>hg crecord, to select the changes to commit</li> </ul> <p>We have spent some time to review a merge I made sunday, to re-merge it, and commit the changes as a new changeset. Awesome. These things make me say I <strong>need</strong> to read <a class="reference external" href="http://hgbook.red-bean.com/read/">the hg book</a>, and will do as soon as I got some spare time: mercurial seems to be simply great. So ... Great. I'm a powerful merger now !</p> </div> <div class="section" id="on-using-tools"> <h2>On using tools</h2> <p>Because we <em>also</em> are <em>hackers</em>, we have shared a bit our ways to code, the tools we use, etc. Both of us were using vim, and I've discovered vimdiff and hgtk, which will completely change the way I navigate into the mercurial history. We aren't &quot;power users&quot;, so we have learned from each other about vim tips. You can find <a class="reference external" href="http://github.com/ametaireau/dotfiles">my dotfiles on github</a>, if it could help. They're not perfect, and not intended to be, because changing all the time, as I learn. Don't hesitate to have a look, and to propose enhancements if you have !</p> </div> <div class="section" id="on-being-pythonic"> <h2>On being pythonic</h2> <p>My background as an old Java user disserves me so far, as the paradigms are not the same while coding in python. Hard to find the more pythonic way to do, and sometimes hard to unlearn my way to think about software engineering. Well, it seems that the only solution is to read code, and to re-read import this from times to times ! <a class="reference external" href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html">Coding like a pythonista</a> seems to be a must-read, so, I know what to do.</p> </div> <div class="section" id="conclusion"> <h2>Conclusion</h2> <p>It was really great. Next time, we'll need to focus a bit more on distutils2, and to have a bullet list of things to do, but days like this one are opportunities to catch ! We'll probably do another sprint in a few weeks, stay tuned !</p> </div> Use Restructured Text (ReST) to power your presentations2010-06-25T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-06-25:/use-restructured-text-rest-to-power-your-presentations.html/<p>Wednesday, we give a presentation, with some friends, about the CouchDB Database, to <a class="reference external" href="http://www.toulibre.org">the Toulouse local LUG</a>. Thanks a lot to all the presents for being there, it was a pleasure to talk about this topic with you. Too bad the season is over now an I quit Toulouse next year.</p> <p>During our brainstorming about the topic, we used some paper, and we wanted to make a presentation the simpler way. First thing that come to my mind was using <a class="reference external" href="http://docutils.sourceforge.net/rst.html">restructured text</a>, so I've wrote a simple file containing our different bullet points. In fact, there is quite nothing to do then, to have a working presentation.</p> <p>So far, I've used <a class="reference external" href="http://code.google.com/p/rst2pdf/">the rst2pdf program</a>, and a simple template, to generate output. It's probably simple to have similar results using latex + beamer, I'll try this next time, but as I'm not familiar with latex syntax, restructured text was a great option.</p> <p>Here are <a class="reference external" href="http://files.lolnet.org/alexis/rst-presentations/couchdb/couchdb.pdf">the final PDF output</a>, <a class="reference external" href="http://files.lolnet.org/alexis/rst-presentations/couchdb/couchdb.rst">Rhe ReST source</a>, <a class="reference external" href="http://files.lolnet.org/alexis/rst-presentations/slides.style">the theme used</a>, and the command line to generate the PDF:</p> <pre class="literal-block"> rst2pdf couchdb.rst -b1 -s ../slides.style </pre> first week working on distutils22010-06-04T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-06-04:/first-week-working-on-distutils2.html/<p>As I've been working on <a class="reference external" href="http://hg.python.org/distutils2/">Distutils2</a> during the past week, taking part of the <a class="reference external" href="http://code.google.com/intl/fr/soc/">GSOC</a> program, here is a short summary of what I've done so far.</p> <p>As my courses are not over yet, I've not worked as much as I wanted, and this will continues until the end of June. My main tasks are about making installation and uninstallation commands, to have a simple way to install distributions via <a class="reference external" href="http://hg.python.org/distutils2/">Distutils2</a>.</p> <p>To do this, we need to rely on informations provided by the Python Package Index (<a class="reference external" href="http://pypi.python.org/">PyPI</a>), and there is at least two ways to retreive informations from here: XML-RPC and the &quot;simple&quot; API.</p> <p>So, I've been working on porting some <a class="reference external" href="http://bitbucket.org/tarek/distribute/">Distribute</a> related stuff to <a class="reference external" href="http://hg.python.org/distutils2/">Distutils2</a>, cutting off all non distutils' things, as we do not want to depend from Distribute's internals. My main work has been about reading the whole code, writing tests about this and making those tests possible.</p> <p>In fact, there was a need of a pypi mocked server, and, after reading and introducing myself to the distutils behaviors and code, I've taken some time to improve the work <a class="reference external" href="http://bitbucket.org/konrad">Konrad</a> makes about this mock.</p> <div class="section" id="a-pypi-server-mock"> <h2>A PyPI Server mock</h2> <p>The mock is embeded in a thread, to make it available during the tests, in a non blocking way. We first used <a class="reference external" href="http://wsgi.org">WSGI</a> and <a class="reference external" href="http://docs.python.org/library/wsgiref.html">wsgiref</a> in order control what to serve, and to log the requests made to the server, but finally realised that <a class="reference external" href="http://docs.python.org/library/wsgiref.html">wsgiref</a> is not python 2.4 compatible (and we <em>need</em> to be python 2.4 compatible in Distutils2).</p> <p>So, we switched to <a class="reference external" href="http://docs.python.org/library/basehttpserver.html">BaseHTTPServer</a> and <a class="reference external" href="http://docs.python.org/library/simplehttpserver.html">SimpleHTTPServer</a>, and updated our tests accordingly. It's been an opportunity to realize that <a class="reference external" href="http://wsgi.org">WSGI</a> has been a great step forward for making HTTP servers, and expose a really simplest way to discuss with HTTP !</p> <p>You can find <a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/changesets">the modifications I made</a>, and the <a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/src/tip/docs/source/test_framework.rst">related docs</a> about this on <a class="reference external" href="http://bitbucket.org/ametaireau/distutils2/">my bitbucket distutils2 clone</a>.</p> </div> <div class="section" id="the-pypi-simple-api"> <h2>The PyPI Simple API</h2> <p>So, back to the main problematic: make a python library to access and request information stored on PyPI, via the simple API. As I said, I've just grabbed the work made from <a class="reference external" href="http://bitbucket.org/tarek/distribute/">Distribute</a>, and played a bit with, in order to view what are the different use cases, and started to write the related tests.</p> </div> <div class="section" id="the-work-to-come"> <h2>The work to come</h2> <p>So, once all use cases covered with tests, I'll rewrite a bit the grabbed code, and do some software design work (to not expose all things as privates methods, have a clear API, and other things like this), then update the tests accordingly and write a documentation to make this clear.</p> <p>Next step is to a little client, as I've <a class="reference external" href="http://github.com/ametaireau/pypiclient">already started here</a> I'll take you updated !</p> </div> A Distutils2 GSoC2010-05-01T00:00:00+02:00Alexis Métaireautag:blog.notmyidea.org,2010-05-01:/a-distutils2-gsoc.html/<p>WOW. I've been accepted to be a part of the <a class="reference external" href="http://code.google.com/intl/fr/soc/">Google Summer Of Code</a> program, and will work on <a class="reference external" href="http://python.org/">python</a> <a class="reference external" href="http://hg.python.org/distutils2/">distutils2</a>, with <a class="reference external" href="http://pygsoc.wordpress.com/">a</a> <a class="reference external" href="http://konryd.blogspot.com/">lot</a> <a class="reference external" href="http://ziade.org/">of</a> (intersting!) <a class="reference external" href="http://zubin71.wordpress.com/">people</a>.</p> <blockquote> So, it's about building the successor of Distutils2, ie. &quot;the python package manager&quot;. Today, there is too&nbsp;many ways to package a python application (pip, setuptools, distribute, distutils, etc.) so&nbsp;there is a huge effort to make in order to make all this packaging stuff interoperable, as pointed out by the&nbsp;<a class="reference external" href="http://www.python.org/dev/peps/pep-0376/">PEP 376</a>.</blockquote> <p>In more details, I'm going to work on the Installer / Uninstaller features of Distutils2, and on a PyPI XML-RPC client for distutils2. Here are the already defined tasks:</p> <ul class="simple"> <li>Implement Distutils2 APIs described in PEP 376.</li> <li>Add the uninstall command.</li> <li>think about a basic installer / uninstaller script. (with deps) -- similar to pip/easy_install</li> <li>in a pypi subpackage;</li> <li>Integrate a module similar to setuptools' package_index'</li> <li>PyPI XML-RPC client for distutils 2: <a class="reference external" href="http://bugs.python.org/issue8190">http://bugs.python.org/issue8190</a></li> </ul> <p>As I'm relatively new to python, I'll need some extra work in order to apply all good practice, among other things that can make a developper-life joyful. I'll post here, each week, my advancement, and my tought about python and especialy python packaging world.</p> Le temps des grâces, courrez-y !2010-03-28T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2010-03-28:/le-temps-des-graces-courrez-y.html/<p>Ouf, notre <a class="reference external" href="http://www.reseaugrappe.org">semaine de l'environnement</a> s'est terminée, après un peu de neige et un brin de soleil quand il en fallait.</p> <p>Ce fut l'occasion de rencontrer beaucoup de gens biens, et de regarder d'un peu plus près toutes ces problématiques qui mériteraient à elles seules, chacune un billet. Après un répis d'une semaine, pour récupérer des folies organisatrices (c'est ça qui fait du bien, ceci dit -- les folies, pas le repos), je me retrouve de nouveau sur ces mêms réflexions, grâce aux journées organisées par <a class="reference external" href="http://www.fne.asso.fr/">France Nature Environnement</a>, qui proposaient ce jeudi soir une projection de &quot;Le temps des grâces&quot;, un documentaire sur l'agriculture.</p> <p>Parce que depuis 60 ans, il est pratiqué le remembrement des parcelles à gogo, parce que nos sols deviennent completement morts à cause des tonnes d'intrants qu'on leur fait absorber, et parce que les exploitations s'agrandissent sans en finir pour tenter de réagir façe à un marché financier toujours plus insaisissable, mené de très loin par la PAC, il fallait un film pour en parler. C'est ce que fait &quot;le temps des grâçes&quot;, avec un bon sens et une facilité à faire passer des messages, qu'on ne peut qu'applaudir.</p> <p>Malheureusement il s'agissait de la dernière diffusion à <a class="reference external" href="http://www.cinemas-utopia.org/toulouse/">L'Utopia de Toulouse</a>... Si vous en avez l'occasion, sautez dessus et profitez le temps de ces 2 heures, ou vous pourrez écouter à la fois des discours d'agronomes, d'agriculteurs, de chercheurs et bien d'autres, qui dressent un constat pas si brillant de notre agriculture. On n'est pas sorti de l'auberge, enfin, c'est l'expression.</p> <p>Je vous laisse avec le synopsis et une bande annonce.</p> <blockquote> Une enquête documentaire sur le monde agricole français aujourd'hui à travers de nombreux récits : agriculteurs, chercheurs, agronomes, écrivains... Un monde qui parvient à résister aux bouleversements qui le frappent - économiques, scientifiques, sociaux - et qui, bon gré mal gré, continue d'entretenir les liens entre générations. Un monde au centre d'interrogations majeures sur l'avenir.</blockquote> <p>Ainsi qu'un commentaire que je ne peux m'empécher de relayer, trouvé sur allocine.fr (oui, vous savez, ce site rempli de pubs).</p> <blockquote> Le temps des grâces c'est je pense le plus grand film traitant de l'écologie en tant que documentaire ou en sujet principal, on y apprend une multitude de choses, on en ressort en colère contre le système, le film propose différents points de vues, ici on a pas de voix off moralisatrice à deux balles avec des gros titres bien surlignés pour que même les beaufs matant TF1 puissent comprendre, ici même si ça reste accessible au citoyen lambda, le film ne fait pas de compromis avec le monde agroalimentaire, il ose dénoncer les filière d'agronomie qui apprennent pas les bonnes choses à leurs étudiants, aux lobbys de cette agro-industrie qui n'en fait qu'à sa tête pour amasser de l'argent, cette tendance à tout uniformiser et détruire… Franchement j'ai trouvé ça génial de bout en bout, captivant, on explore cette campagne française, on comprend les dilemmes des paysants. Le film n'étant pas opposé à la modernité, ni même réactionnaire, il propose juste un constat alarmant du monde agricole français, tout en proposant des alternatives qui pourraient être utilisée, si les pouvoirs publics lâchaient un peu la main des lobbys. Passionnant, vraiment.</blockquote> <p>Courrez-y, je vous dis.</p> Semaine de l’environnement: La consommation étudiante2010-02-24T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2010-02-24:/semaine-de-lenvironnement-la-consommation-etudiante.html/<p>Les acteurs associatifs sont bien souvent moteurs des critiques de nos sociétés. Je pense à <a class="reference external" href="http://www.framasoft.net/">Framasoft</a>, à <a class="reference external" href="http://www.laquadrature.net/">la Quadrature du net</a> ou à <a class="reference external" href="http://www.arsindustrialis.org/">Ars Industrialis</a> (dans le domaine de la science et de l'informatique), mais aussi <a class="reference external" href="http://www.amisdelaterre.org/">aux Amis de la Terre</a>, à <a class="reference external" href="http://www.attac.org/">ATTAC</a> (dans le domaine de l'environnement entres autres), et a tout un tas d'autres associations que je ne peux pas citer ici exhaustivement... Ce sont eux qui sont porteurs de messages alternatifs, et qui sont les initiateurs de débats publics, qui permettent de faire avancer des thématiques aussi importantes que le logiciel libre ou la protection de l'environnement.</p> <p>Dans cette optique, depuis près de 3 ans (déjà !), au sein du <a class="reference external" href="http://www.reseaugrappe.org">réseau GRAPPE</a>, on <em>essaye</em> d'aborder des thématiques qui touchent de près ou de loin à l'environnement, parce que c'est un sujet qui nous importe et nous passionne. L'année dernière, c'était l'alimentation étudiante, ce qui à abouti à la publication de <a class="reference external" href="http://public.reseaugrappe.org/alimentation.pdf">la revue &quot;les étudiants se mettent à table&quot;</a>. Cette année c'est la consommation étudiante qui est au programme.</p> <div class="section" id="la-consommation-etudiante"> <h2>La consommation étudiante ?</h2> <p>L'idée principale de cette étude est de tenter de faire une analyse de la &quot;société de consommation&quot;, souvent questionnée par les étudiants et par d'autres, et de jeter un œil sur le rapport des étudiants à cette société: Quoi et comment consomment-ils ? Les universités et les écoles ne poussent-elles pas d’une certaine manière les étudiants à la consommation ? Quelles sont les alternatives face aux dérives de surconsommation ?</p> <blockquote> Analyse des pratiques, réflexions et mobilisations des étudiants en termes de consommation seront réalisés pour comprendre leur modes de vie, mais aussi leurs attentes, leurs propositions sur cette thématique</blockquote> </div> <div class="section" id="la-semaine-de-l-environnement"> <h2>La semaine de l'environnement !</h2> <p>A travers l'ensemble des villes du réseau, des projections de films et des débats auront donc lieu sur ce thème, lors de la semaine de l'environnement 2010, qui se déroulera d'ailleurs durant le mois de Mars <a class="reference external" href="http://www.reseaugrappe.org/la-semaine-de-lenvironnement-programme/">partout en france</a>, et <strong>du 6 au 14 Mars sur Toulouse</strong>. <a class="reference external" href="http://docs.notmyidea.org/sde/prog-toulouse.pdf">Jetez un oeil au programme</a> ! Avec pour objectif de sonder un peu le ressenti des étudiants en terme de consommation, nous avons mis en place <a class="reference external" href="http://spreadsheets.google.com/viewform?formkey=dHV2bVllS2lWbzhyV3NBN3NUbi1TM2c6MA">un questionnaire en ligne</a>, que vous pouvez compléter en une petite 10aine de minutes, n'hésitez pas ! <a class="reference external" href="http://www.reseaugrappe.org/consommation/">La page sur la consommation étudiante sur le site du GRAPPE</a></p> </div> Python ? go !2009-12-17T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2009-12-17:/python-go.html/<p>Cela fait maintenant un peu plus d'un mois que je travaille sur un projet en <a class="reference external" href="http://www.djangoproject.org">django</a>, et que, nécessairement, je me forme à <a class="reference external" href="http://python.org/">Python</a>. Je prends un plaisir non dissimulé à découvrir ce langage (et à l'utiliser), qui ne cesse de me surprendre. Les premiers mots qui me viennent à l'esprit à propos de Python, sont &quot;logique&quot; et &quot;simple&quot;. Et pourtant puissant pour autant. Je ne manque d'ailleurs pas une occasion pour faire un peu d'<em>évangélisation</em> auprès des quelques personnes qui veulent bien m'écouter.</p> <div class="section" id="the-zen-of-python"> <h2>The Zen of Python</h2> <p>Avant toute autre chose, je pense utile de citer Tim Peters, et <a class="reference external" href="http://www.python.org/dev/peps/pep-0020/">le PEP20</a>, qui constituent une très bonne introduction au langage, qui prends la forme d'un <em>easter egg</em> présent dans python</p> <div class="highlight"><pre>&gt;&gt;&gt; import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren<span class="s1">&#39;t special enough to break the rules.</span> <span class="s1">Although practicality beats purity.</span> <span class="s1">Errors should never pass silently.</span> <span class="s1">Unless explicitly silenced.</span> <span class="s1">In the face of ambiguity, refuse the temptation to guess.</span> <span class="s1">There should be one-- and preferably only one --obvious way to do it.</span> <span class="s1">Although that way may not be obvious at first unless you&#39;</span>re Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it<span class="s1">&#39;s a bad idea.</span> <span class="s1">If the implementation is easy to explain, it may be a good idea.</span> <span class="s1">Namespaces are one honking great idea -- let&#39;</span>s <span class="k">do </span>more of those! </pre></div> <p>J'ai la vague impression que c'est ce que j'ai toujours cherché à faire en PHP, et particulièrement dans <a class="reference external" href="http://www.spiral-project.org">le framework Spiral</a>, mais en ajoutant ces concepts dans une sur-couche au langage. Ici, c'est directement de <em>l'esprit</em> de python qu'il s'agit, ce qui signifie que la plupart des bibliothèques python suivent ces concepts. Elle est pas belle la vie ?</p> </div> <div class="section" id="comment-commencer-et-par-ou"> <h2>Comment commencer, et par ou ?</h2> <p>Pour ma part, j'ai commencé par la lecture de quelques livres et articles intéressants, qui constituent une bonne entrée en matière sur le sujet (La liste n'est bien évidemment pas exhaustive et vos commentaires sont les bienvenus) :</p> <ul class="simple"> <li><a class="reference external" href="http://diveintopython.adrahon.org/">Dive into python</a></li> <li><a class="reference external" href="http://www.swaroopch.com/notes/Python_fr:Table_des_Matières">A byte of python</a></li> <li><a class="reference external" href="http://www.amazon.fr/Python-Petit-guide-lusage-développeur/dp/2100508830">Python: petit guide à l'usage du développeur agile</a> de <a class="reference external" href="http://tarekziade.wordpress.com/">Tarek Ziadé</a></li> <li><a class="reference external" href="http://docs.python.org/index.html">La documentation officielle python</a>, bien sûr !</li> <li><a class="reference external" href="http://video.pycon.fr/videos/pycon-fr-2009/">Les vidéos du pyconfr 2009</a>!</li> <li>Un peu de temps, et une console python ouverte :)</li> </ul> <p>J'essaye par ailleurs de partager au maximum les ressources que je trouve de temps à autres, que ce soit <a class="reference external" href="http://www.twitter.com/ametaireau">via twitter</a> ou <a class="reference external" href="http://delicious.com/ametaireau">via mon compte delicious</a>. Allez jeter un œil <a class="reference external" href="http://delicious.com/ametaireau/python">au tag python</a> sur mon profil, peut être que vous trouverez des choses intéressantes, qui sait!</p> </div> <div class="section" id="un-python-sexy"> <h2>Un python sexy</h2> <p>Quelques fonctionnalités qui devraient vous mettre l'eau à la bouche:</p> <ul class="simple"> <li><a class="reference external" href="http://docs.python.org/library/stdtypes.html#comparisons">Le chaînage des opérateurs de comparaison</a> est possible (a&lt;b &lt;c dans une condition)</li> <li>Assignation de valeurs multiples (il est possible de faire a,b,c = 1,2,3 par exemple)</li> <li><a class="reference external" href="http://docs.python.org/tutorial/datastructures.html">Les listes</a> sont simples à manipuler !</li> <li>Les <a class="reference external" href="http://docs.python.org/tutorial/datastructures.html#list-comprehensions">list comprehension</a>, ou comment faire des opérations complexes sur les listes, de manière simple.</li> <li>Les <a class="reference external" href="http://docs.python.org/library/doctest.html?highlight=doctest">doctests</a>: ou comment faire des tests directement dans la documentation de vos classes, tout en la documentant avec de vrais exemples.</li> <li>Les <a class="reference external" href="http://www.python.org/doc/essays/metaclasses/meta-vladimir.txt">métaclasses</a>, ou comment contrôler la manière dont les classes se construisent</li> <li>Python est <a class="reference external" href="http://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language">un langage à typage fort dynamique</a>: c'est ce qui m'agaçait avec PHP qui est un langage à typage faible dynamique.</li> </ul> <p>Cous pouvez également aller regarder <a class="reference external" href="http://video.pycon.fr/videos/free/53/">l'atelier donné par Victor Stinner durant le Pyconfr 09</a>. Have fun !</p> </div> AMAP + Média = Paniers bio à 5e ?!2009-11-11T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2009-11-11:/amap-media-paniers-bio-a-5e.html/<p>Le raccourci me semble un peu rapide. Et pourtant, il est emprunté bien trop souvent. La dernière <em>mes-utilisation</em> que j'ai à décrier est celle d'un reportage télé, passé sur France 2 vendredi 23 Octobre (<a class="reference external" href="http://docs.notmyidea.org/amap/amap-fr2.avi">voir la vidéo</a>), ou on parles de <a class="reference external" href="http://amap.zest.free.fr">l'AMAP étudiante Zest</a>.</p> <p>Malgré tout le temps passé à expliquer que justement, l'AMAP c'est avant tout, pour nous, une notion de solidarité envers les agriculteurs, malgré le fait que le message soit plus profond que simplement aller acheter du bio (ça, c'est possible aussi en supermarché), malgré le fait qu'il s'agisse en fait d'une remise en cause plus profonde de la société, les journalistes n'ont choisi de prendre que les quelques secondes qui leurs convenaient, celles qui ne faisaient pas tache, celle ou je dis que &quot;l'AMAP permet aux étudiants de réapprendre à cuisiner, plutôt que de manger des nouilles et de se faire des plats réchauffés&quot;. Bien sur, je l'ai dit et je le pense d'ailleurs, là n'est pas le problème, mais mon message n'était pas celui là.</p> <p>Jamais, dans les quelques minutes du reportage, on ne dit ce que AMAP signifie: Association de <strong>Maintien</strong> d'une Agriculture <strong>Paysanne</strong>. On ne parles même pas des agriculteurs ! C'est simplement plus facile pour les étudiants de venir récupérer leurs paniers, puisque les points de distribution sont sur les facs, et en plus ça ne coute que 5 euros ! ...</p> <p>Alors je crois bon de rappeler que L'AMAP n'est pas seulement un service, c'est un engagement. Sur 5 mois, un engagement solidaire, c'est la donnée principale de l'équation, celle sans quoi ça ne peut fonctionner. Par le biais de cette AMAP, on essaye de montrer que d'autres agricultures sont possibles, que la solidarité c'est bien réel, et qu'il est possible de sortir du <em>tout, tout de suite</em>.</p> <p>Mais bon, apparemment, ça passe pas bien à la télé.</p>