Archive for the ‘Python’ Category

It’s something I need to remember: how do I install an old PyUSB package on Xubuntu (or a similar Debian-based OS). Why, you ask? Because I need that old version 0.4.3 for the little script that reads the solar energy numbers from the SMA Sunny Beam.

Image of the SMA Sunny Beam monitor for our solar panel installation

The SMA Sunny Beam monitor for our solar panel installation

Luckily, it isn’t too hard to do. This is my context:

Step one is to make sure you have the required header files to compile the PyUSB package. So you open up a terminal session and execute

sudo apt-get install libusb-dev
sudo apt-get install python-dev

Step two: Extract the root folder and all the files from the PyUSB archive, and make that folder your current directory in the terminal session.

Step three: compile and install the package with this command:

sudo python setup.py install

That’s it. When all goes well, you’ll be able to verify the existence of two new files on your system, in a directory called “/usr/local/lib/python2.7/dist-packages“:



Read Full Post »

You may be forgiven to think that nowadays developers no longer need text editors, now that there are fantastic IDE’s on the market (IDE = Integrated Development Environment). But if you do any kind of web development, you’re probably using some kind of text editor, in combination with the IDE of your choice or perhaps even instead of an IDE. I know I prefer a tool that doesn’t try to be everything at once.

Choosing a text editor is not so simple, however. No matter what OS you’re on, Windows or OS X or Linux or even Android or iOS, you’ll have a rich palette of tools to choose from – and choosing is always hard. That’s why you will find dozens of web pages extolling the virtues of “the ten best text editors” on your favourite OS! I have mentioned a few OS X editors 9 months ago, but in the meantime I have also installed and worked with KomodoEdit.

I have been trying out a whole series of text editors on Windows as well. Choosing is hard, not only because currently any tool I pick also has to be compatible with Windows XP (I know, don’t say it). At work, I need even more features in an editor: I want macros or programmability, search and replace with regular expressions, syntax highlighting for all my favourite languages, extensibility, and more. Plus a tool I’ll be using a lot has to be friendly to this user: it should please me visually, and I want my most frequent commands to be easily executed from the keyboard. You can see why I do not yet have made my choice…

At this moment, I have no quarrel with TextMate on the Mac, but I’m not really pushing it either. On Windows, I am a staunch defender of Notepad++, which I use daily. Notepad++ is fast, knows HTML, XML, JavaScript and more, does macros, sorts lines, can handle read-only files, has a flexible search-and-replace: that’s almost all I need. I also appreciate its author, who is not afraid to publish a new version of his application just to express his opinion: the latest version, as we speak, is the “6.7.4 Je Suis Charlie” version. Well done, Don!


So why would I look beyond Notepad++? Well, for SharePoint developments Notepad++ comes in handy, for a quick check of HTML or JavaScript. But the rest of my code is mostly CFML (ColdFusion). The standard XML syntax colouring is a bit too simple, and that’s where my troubles start.  You see, there’s a nice plugin to support ColdFusion development in Notepad++ – but it is not entirely compatible with the latest versions of Notepad++. I used Brien Malone’s instructions to get the plugin installed in version 6.7.3. Unfortunately, from time to time the application complains about a missing plugin, and then I have to redo parts of the manual installation described by Brien. After a while, that is no longer funny and adventurous, just plain annoying.

Besides that: sometimes I need just a bit more from my text editor. I do not have a C-compiler at hand to create my own plugins, so I went looking for an alternative text editor. Like I said, the list of possible candidates is long, but in the end I decided to try out KomodoEdit and Editra. Not because they’re the absolute best, but because they work on XP and are installable without admin rights… Their programmability far exceeds Notepad++, and that has already paid off (I’m also learning a bit of Python this way, just on the side). I can use them on Windows – but there are versions for the Mac and Linux as well, which is handy if you dabble on all three platforms like me. But for the moment both of them stay as an assistant to Notepad++, and neither is going to become my main editor soon.

If you’re looking for a text editor, be prepared to spend a serious amount of time on your search – and make sure that you know what you need and what you don’t need.

PS. I think I have found a small but annoying bug in Notepad++. I had this little macro that included a “goto the end of the line” instruction. When repeated until the end of the file, however, the macro failed to do its intended work if and when the editor was in “word wrap” mode. I’m not sure it’s the same problem as described in bug report “#4526 Macro scrambles on EOL with word wrap“, but it seems to be related… Anyway, it’s a bug that easily avoided, so this won’t make me throw Notepad++ out the window ;-)

Read Full Post »

While installing the ColdFusion Builder app I obtained at the ColdFusion 11 Launch Party last week, I needed a Java runtime. I recalled installing a Java 8 runtime on my Macs (or at least on one of them) , but couldn’t find it on the Mac Mini I currently use for development. I really should document the maintenance and configuration of my machines… and why not start now, on an autumn afternoon in October?

For a long time, I have wanted to play around with Python (the programming language, not the snake), but I never found enough time to try my hand at real, serious Python programming. But today I thought: why not whip up an instance of my favorite bug tracker and use that for my documentation? Trac, to be explicit, is a Python application that does what I want (and lots more), and it can be installed in the cloud – and that last part is useful if I want to make certain that I can read my docs even when the machines at home go down.

So I created a free “Beginner” account at the PythonAnywhere site, and started playing around in an attempt to get Trac 1.0.1 running on that site. There are instructions to be found on the PythonAnywhere Forums for just that purpose, but I managed to get a first reasonable response in just five simple steps:

  1. From the PythonAnywhere dashboard of your ‘Beginner’,  start a ‘bash’ console;
  2. Run the ‘trac-admin /home/youruseraccountname/trac initenv’ command (substituting your account name for the ‘youruseraccountname’ part, of course) and giving your repository a name;
  3. Go to the ‘Web’ tab of your dashboard, and adapt the WSGI configuration file (just click on the link to this file, and you’ll be able to edit it in the browser). Comment out all the existing content or start from an empty file and add these lines:
    import os
    import sys
    import trac
    import trac.web.main
    os.environ['TRAC_ENV'] = '/home/youruseraccountname/trac'
    os.environ['PYTHON_EGG_CACHE'] = '/tmp'
    trac_app = trac.web.main.dispatch_request
  4. Reload your app with the big green button;
  5. Check out your app at your PythonAnywhere address ;-)
Your first Trac screen in the Cloud!

Your first Trac screen in the Cloud!

No, you’re not done yet: you still need to configure Trac to your linking – but that is not different from any normal Trac configuration action. I’m currently the only user for my PA instance, and I just need the Wiki and the ticket tracker, so I won’t be trying to add user management and access control to Trac. Nor will I be using source control for the time being. But all that is quite possible, if I’m to believe the experts…

Read Full Post »

A few days ago, Daniel Greenfeld wrote a blog post on the “Tools we used to write Two Scoops of Django“. Mentioning the words “tools” and “Django” in a single phrase is sure to get my attention, and the post did not disappoint. What fascinated me most, however, was not the “tools” part nor the “Django” part. The story is a good example to explain which difficulties show up in the process of creating and managing good content – even when it is “just” the writing of a book and its publication in multiple formats.

If you read the story, you will notice that

  • the authors started using familiar tools, like Python’s reStructuredText and Google Documents;
  • they then noticed that those tools did not measure up to their requirements, and had to switch again and again – until they ended up with LaTeX, allowing them to clearly structure the content and only then apply the formatting and layout for a paper version;
  • e-book formats are a world on their own, and it’s a complex world with many pitfalls;
  • technical content is never finished, so it requires forethought and planning to keep up with reality during the lifetime of your document.

All this about a relatively simple thing as a book, and by that I mean no disrespect to the authors. But assembling and maintaining say a website with hundreds of pages will be even harder, since such an endeavour add factors such as user management, target audiences, multiple authors, possibly multiple languages, categorization of pages, an editorial policy, and more – and that’s not mentioning a series of technical aspects. Enterprise content management ups the ante again, sometimes by several factors. So, yes, Content Management can be hard, very hard, to do right.

* * *

And what about the book, you ask? Well, if I’m ever going to do anything serious with Django I’ll need a copy of “Two Scoops of Django“. The sample chapter was a bit over my head, since I’m an absolute Django beginner, but the patterns and tips seemed logical and well explained. The writing is clear and sensible. The only thing I did not like is the fact that code samples are sometimes being split over two pages. That should not happen except when the code is longer than what fits on a single page, and even then I would prefer the code to be rewritten and packaged in smaller blocks. But all in all, this looks like a worthwhile book.

Read Full Post »

A month ago, I mentioned the appeal by the Python Software Foundation to help them defend the name “Python”. The good news is that both sides came to an amicable agreement: PO Box Hosting Limited (trading as Veber) will rebrand its services later under a yet to be determined name.

In the words of the Chairman of the PSF: “To Veber’s credit, they were willing to recognize the Python brand without protracted negotiations. We are grateful for Veber’s support and we wish them luck in their business“. I agree: it’s good to see that a dispute like this can be resolved amicably in just a few weeks, without having to go to court.

Read Full Post »

It’s all here: “Python trademark at risk in Europe: We need your help!“. I have no materials to submit, but I can tell you that my first mention of Python (actually, it was JPython) on this very blog dates back to November 2000

Read Full Post »

WikiNotes is a wiki-based note-sharing platform created to facilitate student collaboration (beware: the site can be slow!). Basically it’s a system that allows students (and others ;-) to publish course notes, questions from examinations, study notes, etc. The current version of WikiNotes is based on the classic MediaWiki-software that also powers the WikiPedia. But a small team of student developers is rewriting the system from scratch. A beta version can be explored at http://beta.wikinotes.ca/ – and its source code is published under the GPLv3 on GitHub.

Why do I mention this project? First of all: I am a Wiki fan ;-)

Secondly, it’s a good example of what a Wiki can be used for: the creation of a public body of knowledge that is fed and maintained by anyone who wants to help. Of course, not all courses are equally well documented, but since a Wiki can be edited anytime that might change rapidly (or never ;-). Not everyone was (is) convinced of the value of such an initiative – users of WikiNotes should be aware of possible copyright issues, to name the most frequently mentioned counter-argument –  but I have found several pleas for a more nuanced approach that can benefit both the students and the University. Check out this editorial from the McGill Tribune for suggestions on how to govern the WikiNotes site.

Thirdly, the new version is being written in Python and created on top of the Django framework. I find it stimulating to see the progress in the development of this application, from a developers prespective.

Last but not least, this Wiki started out as a student initiative – there are clearly smart students at McGill!

At the same time, this project illustrates an essential aspect of any content management project. Before choosing any CMS, or writing your own, you have to analyse your requirements. You have to know what you will be dealing with: what type of “content” (text, image, video, …) about which subjects will you be handling; what metadata do you need for each content type; who is going to handle that content, and what will they be doing exactly; who is the target audience for the content, and what are their expectations; etc. Without clear answers to these and more questions you will never be able to set up a suitable CMS, let alone claim a succesful implementation.

PS. This is why I fear that the brand new Brussels Wiki (‘Wikibru, the wiki of the City of Brussels‘) will be a failure: a wiki needs more justification than the possibility “for people to add something to the site”…

Read Full Post »

Older Posts »