12. May 2013

Unicode Python plugin for Unicode NSIS

NSIS is very common project for building installer packages. It requires less time to work with NSIS than using WiX or MSI.

It has also certain drawbacks like very weird programming language which resembles assembler mixed with Postscript. Quite scary at first glance. There is remedy for this glitch.

NSIS is good for building installer “container” and it could hand over more complex logic to its plugins like Python plugin.

Original NSIS has another one glitch: no support for unicode. Luckily guys took NSIS and they fixed the issue by creating Unicode NSIS.

Unfortunately unicode version was not able to work with former Python plugin.

It required some effort to fix Python calls from NSIS and voilà Unicode Python plugin is available at github – nsPythonUnicode. 🙂

11. May 2013

Plone Error: There is a version conflict. We already have: distribute 0.6.38

I was trying to update one very old instance of Plone configured by buildout. Result of running ./bin/buildout was this error message:

  Loading extensions.
Error: There is a version conflict.
We already have: distribute 0.6.38

There was distribute package installed on system which caused conflict. The solution was to remove the package:

apt-get remove --purge python-zc.buildout

That leads to another error message that buildout script is outdated. Correction:

curl -O http://downloads.buildout.org/2/bootstrap.py
python bootstrap.py

There was another error after using latest version of buildout:

  Getting section instance.
  Initializing section instance.
  Installing recipe plone.recipe.zope2instance.
Error: There is a version conflict.
We already have: zope.interface 3.6.1

Solution was same as before. Just remove zope.interface package from system:

apt-get remove --purge python-zope.interface

After this small fix it was possible to run buildout without any problem.

Update: I encountered this issue again. This time it was necessary to delete develop-eggs directory and restart buildout again.

11. May 2013

Edge – invoke PowerShell from NodeJS

Project Edge allows seamless integration of NodeJS and PowrShell.

Just install packages:

npm install edge
npm install edge-ps

Create NodeJS application which contains PowerShell code:

var edge = require('edge');

var hello = edge.func('ps', function () {/*
"PowerShell welcomes $inputFromJS on $(Get-Date)"

hello('Node.js', function (error, result) {
 if (error) throw error;

Start application and you’ll get output

PowerShell welcomes Node.js on 05/11/2013 07:14:38

Project Edge also allows integration of NodeJS with other technologies (e.g. Python)

8. May 2013

Vim mode in Cloud9 IDE

Cloud9 IDE is cloud base IDE for NodeJS, Python, Ruby or PHP projects.

The cool thing about this IDE is that code editor has support for Vim mode (it also supports Emacs) 🙂


Go to View, Keyboard Mode and select Vim.

Voila you can use many Vim features, like indentation by >> or many others.

Here is offical video from Cloud9 Youtube channel:

4. February 2013

Useful Django package: django-debug-toolbar

django-debug-toolbar is simply must have tool for Django development.

It adds powerfull toolbar which allows detailed diagnostic and debugging of Django site.

django-debug-toolbarQuick install:

pip install django-debug-toolbar

Open settings.py and add:

    # ...
    # ...

Make sure that DEBUG is set to True

DEBUG = True

29. September 2012

Plone upgrade – Clear and Rebuild failed

Plone is not working very well when portal_catalog is not up-to-date. This happens after upgrades. It is recommended to go to portal_catalog, section Advanced and run: Clear and Rebuild.

I did this, but after few seconds I’ve got this fancy error:

Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Products.CMFPlone.CatalogTool, line 460, in manage_catalogRebuild
Module plone.app.discussion.patches, line 45, in patchedClearFindAndRebuild
Module Products.ZCatalog.ZCatalog, line 287, in manage_catalogClear
Module Products.ZCatalog.Catalog, line 102, in clear

If you dig deep down into ZCatalog code, then you’ll see that some objects in DB simply don’t have clear method. Those objects are typically some ancient instances of TextIndex or instance of some long dead product.

Solution is to catch this error and remove those old grumpy objects from DB. Here is small patch:

    def clear(self):
        """ clear catalog """

        self.data = IOBTree()  # mapping of rid to meta_data
        self.uids = OIBTree()  # mapping of uid to rid
        self.paths = IOBTree()  # mapping of rid to uid
        self._length = BTrees.Length.Length()
        to_delete = []

        for index in self.indexes.keys():
                LOG.error('unclearable object %s. ' % str(index))

        for del_index in to_delete:
            LOG.error('Removing from index %s. ' % str(del_index))
            del self.indexes[del_index]

Remove eggs/Products.ZCatalog-2.13.23-py2.7.egg/Products/ZCatalog/Catalog.pyc file to avoid caching. Start the Plone and run Clear and Rebuild function. Watch log file also for error messages from ZCatalog.

29. September 2012

Plone buildout problem – We already have zc.buildout

If you want to upgrade Plone just with buildout, then you may find following funny error:

 Loading extensions.
 Error: There is a version conflict.
 We already have: zc.buildout 1.5.2

Typical cause of this problem is that your bin/buildout is out of date. Solution is simple. Remove bin directory. Download latest version of bootstrap.py and let it generate new version of bin/buildout for you. Run biuldout again 🙂

wget http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py
python bootstrap.py

26. August 2012

WebExpo Startup Camp – summer 2012 – materials

I’m glad that I had opportunity to join Startup Camp in Trhový Štěpánov as mentor. Together with startup teams we were discussing and preparing new sites for their products. People were learning how to use Git, how to program in Python and how to create sites in Django. At the end of the day they were able to create prototype or deploy it to Heroku cloud.

Yyou can find my slides at SlideShare or download it as PDF.

Examples of Python code and simple Django testing project are available at GitHub in repository try_git.

Read more about WebExpo Startup camp.

23. August 2012

IntelliJ Idea – How to enable zoom of text by CTRL + Mouse wheel

You can zoom-in or out text in editor window of IntelliJ idea (PyCharm) by CTRL + Mouse wheel.

The only problem is that this feature is disabled by default. You have to turn it on.

Press CTRL + Alt + S (Settings) and type: “change font size” into text search field. Select: Editor and check option “Change font size (Zoom) with Ctrl+Mouse Wheel”

20. August 2012

Problems with deploying Heroku Django app from Windows

Deploying Django app to Heroku from Windows machine is little bit tricky.

You can follow instructions in Heroku manual. The first problem that you may encounter is with Postgres support in Python. There is problem with this command:

pip install Django psycopg2 dj-database-url

If you do not have Visual Studio installed on your machine, you’ll receive error that vcvarsall.bat is missing.

Solution is quite easy. You don’t need to install Visaul Studio. Just download binary version of psycopg2 module from http://www.stickpeople.com/projects/python/win-psycopg/

Then you can exclude psycopg2 from pip install command, because it is installed in system directory of Python.

Another tricky issue is with command:

pip freeze >requirements.txt

If you type this command in PowerShell then it will automatically create Unicode file with extra bytes. When you try to deploy project with messed requirements.txt to Herou then you’ll see self explanatory error 😉

TypeError: must be encoded string without NULL bytes, not str

Nice 🙂

Just open requirements.txt file with notepad and select Save as. In Save as dialog choose ANSI.

Commit file and push project to Heroku. It will work 😉

  • Where’s the fish?

  • Translations

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics