Feeds:
Posts
Comments

Archive for the ‘Python’ Category

There is a new markup language on the market. As a Wikificionado I like markup languages better than using any wordprocessor – for my own writing I haven’t used a wordprocessor in many, many years. Even at work I only use Word when I have to, and that has been a while ago (that probably means all I write are emails and code). And bug reports and documentation get dropped into JSPWiki and Trac and Joplin – all I need is simple markup.

I like markup for regular writing, and I use it daily in tools like Trac and JSPWiki. The trouble, of course, is that each of those tools (and many others!) uses a slightly different markup scheme.

And now there is a new contender on offer: Mau.

Click the image to go to the source code on Github

I can see where it comes from: the author needed more than what any simple markup could offer. I too have at times been frustrated by the lack of feature X or Y in any markup scheme. It surprised me to see that he did not check out LaTeX, which as far as I know should have covered his requirements. But it would probably have been too steep a learning curve.

Back to Mau: I haven’t yet tried it, but I can see that it would be a very nice tool for writing documentation. However, for me the system should be an extension of Markdown, let’s say a SuperMarkdown or MarkdownPlusPlus, rather than another variant markup scheme with subtle differences from what I know.

I guess I am not the only one to dislike “yet another divergent markup scheme”. So far I haven’t seen much traction for Mau… although it is, in a way, a very cool project. I applaud Mau’s author for making the effort – he clearly thought this through. And who knows: perhaps Mau becomes wildly successful in the future?

Read Full Post »

In “The State of the Octoverse ” for 2019 Github writes:

And for the first time, Python outranked Java as the second most popular language on GitHub by repository contributors.

Not bad – JavaScript takes first place, Python and Java follow.

Talking about Python allows me to announce that I hacked my first Python application ;-)

You see, I’m still running an old version of Trac to track issues and document my developments. Old means: version 0.10.5, and the problem is that I don’t have the time at this moment to upgrade to the latest version. So when I had to move to a brand-new Windows 2016 server I just took the existing installation instructions and got Trac running fine, although not under the wings of IIS. Except for one thing: the new server was behind a firewall and a virtual IP address (VIP), the latter also taking care of HTTPS to HTTP conversion. So when my browser sends an HTTPS request, Trac sees HTTP traffic and responds with HTTP redirects when replying to certain actions. Those replies turn into error pages in the browser, since HTTP traffic from the browser does not pass the firewall and is not intercepted by the VIP…

I have been reading up on Python, but I can’t say I have developed anything seriously in it. Python is however sufficiently readable so that I easily found my way in the code. To solve my problem, I just had to force Trac to always redirect to HTTPS URLs. As far as I can tell, I had to change but a single line of code to make that happen. Here’s the code of the ‘_reconstruct_url’ function after my hack:

Image of the Python code for the function '_reconstruct_url'

I changed lines 226-227 to the single statement in line 228

I’m calling this a hack because it only solves my problem; this is not something you want to submit to a public repo. It also means that the application no longer responds to standard HTTP requests. But it’s good enough for now.

From what I have seen on the Trac website there are solutions for running later versions of Trac over SSL, but most (all?) of them seem to rely on an SSL front on the same server as Trac. Too bad that such a solution won’t work for me. Guess I’ll have to study Python and Trac a lot deeper to find the best way to cope with the architecture at work.

Read Full Post »

Sure. As told on the Zappa webpage:

Zappa makes it super easy to build and deploy server-less, event-driven Python applications (including, but not limited to, WSGI web apps) on AWS Lambda + API Gateway. Think of it as “serverless” web hosting for your Python apps. That means infinite scaling, zero downtime, zero maintenance – and at a fraction of the cost of your current deployments!

That’s less revolutionary than Frank Zappa, of course. But it might come in handy, once I find the time to do some real Python development… Then again, you will probably beat me to it!

Read Full Post »

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“:

usb.so
pyusb-0.4.3.egg-info

Done!

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!

npp.png

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 »

Can a $35 computer persuade kids to put down their smartphones and try their hands at programming?” That’s the question Simson Garfinkel wants to answer in his review of the Raspberry Pi. So this is not a technical review, with benchmarks and comparisons with similar hardware. Basically, it’s just about a father who wants to know whether a small but complete computer can keep his kids interested and get them tinkering with software (and possibly with  the hardware as well). His conclusion: the current software version needs an upgrade to be truly compelling for such a young audience.

I was reading this review while sitting in my “office”, which also houses the remote display panel of our solar panel installation on the roof. That explains why I suddenly started thinking about using a Pi to monitor the energy production of our solar panels. The Pi has low power consumption (much less, I hope, than the old Pentium PC that lingers in a dark corner). It has a USB port to connect to the SMA Sunny Beam display. It runs Linux, and thus it should be able to gets the numbers every hour and drop them into a database, from which they can be read in a web app or web service. There’s a lot of talk about the Python programming language in the Pi community, and I have a Python script to read my Sunny Beam… When I write it down like this, it should be dead easy, right?

Read Full Post »

I should have found this sooner, but never mind, now it’s on my todo list: “pyvideo.org. Python related video indexed so you can find it“.

Read Full Post »

If you recognised the phrase I used as a title for this post, then that means that you are getting old… or that you are a reader of a Python blog called “Let’s discuss the matter further“. I mention this blog post not because I am/was a fan of the game in the 1980’s, but because Brandon Rhodes marvelously explains how a rewrite of an older program can throw a few surprises at you on one hand and teach you something new at the same time ;-)

Read Full Post »

Pedro Kroger has created a Python Quick Reference Card that looks quite interesting, at least when (note: when, not if) I start using Python for more than just a few very small hacks for Wikidpad or Trac

Read Full Post »

From the SitePoint tribune 555, in an interview with the founder and author of Twit Cleaner: “The initial version I wrote using 5 million text files & C#. I’d come from a pretty deep artificial intelligence/finance background, so C# was what I was used to. Then I moved to PHP – which got a public site up quickly, but was otherwise horrible. Now, finally, it’s all python, with a database backend…”

Twit Cleaner could be a useful tool (I don’t follow enough people for TC make a substantial difference to what I can do all by myself), regardless of the technology and development tools used, of course ;-)

Read Full Post »

Older Posts »