Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Wednesday, November 4, 2009

yokadi on windows

While reading planet KDE a bit I somehow got caught by Aurélien's release announcement for Yokadi, "the command-line driven, geek friendly, sqlite backed TODO list". I was in need of such a tool already for quite some time, and so began to look at it.
First of all Yokadi is written in python using an sqlite database, which is basically the size I was looking for. Also it makes it possible to run also on windows... In the README it says that Mac OS X and Windows should work but haven't been tested and so I started my way through it.

To make it possible for more people to use this application I want to document what I needed to do to get yokadi working on Windows:
  1. Install the python setuptools if you haven't done so yet. After the installation you might need to adjust your PATH to include the Scripts folder of your python installation so that the easy_install.exe is included.

  2. get pyreadline, sqlobject and dateutils by simply running easy_install[PACKAGENAME]. Make sure you have svn.exe in your path for pyreadline. Except for this requirement, everything went smooth so far.

  3. Now get the yokadi sources with git. I needed to add a patch, so make sure this patch is already contained in your yokadi sources. I send this patch to the mailing list and hope it gets committed soon.

  4. After you made sure about the patch, run setup.py install from the commandline. This will install yokadi as a python site-package.

  5. Set the EDITOR variable if you don't have vi.exe in your path. I installed the commandline version of vim for that: set EDITOR="C:\Program Files\vim\vim72\vim.exe".

  6. To not add a HOME variable to my local environment, I made a yokadi.bat which basically sets the environment variable HOME to the directory where I want to store the database (and the history file) and then calls the yokadi python script in the scripts folder.


I haven't tried the yokadid daemon which is supposed to notify you about due dates: both because I don't like such notifications and as well because at least the master version looks suspiciously Unix-only ;-).
So far I am really pleased by yokadi, it matches my way to work (yes I use the windows cmd.exe a lot!) and I hope I can get rid of all those .todo files now :-D.

Friday, June 27, 2008

Python: subprocesses after all

Back in September 2007 I was sitting with dipesh until late in the night on a very interesting problem:
We wanted to implement a "tee"-like class in python which would work as the same command under unix: get input via one stream, double the input and give it out into a file and into a stream (like sys.stdout). This shouldn't be a big problem but when you try to give this class to subprocess.Popen as one of the streams you will find out that Popen doesn't use the write function but instead uses the fileno() function of the fileobject. But there would be a workaround for that:
We use subprocess.PIPE for the wanted input stream, then we check regularly for any stuff within the pipe - that this will not work on windows one could expect.
The problem is that all available read processes will block execution if not enough bytes can be read.

The solution is called pywin32 and is a python package for windows. Mark Hammond from starship has made them and they include a function called PeekNamedPipe which does exactly what we need: peek into the pipe without blocking it. I should leave the rest as a homework to the reader, but for those who don't want to invest any more research, I'll give a first solution from where you can start (look at the class Popen).