Make Celery ignore Django settings

I wanted to run an instance of Celery on my Linux machine. I installed it in a separate virtual environment (celery-test), but when I tried to run a sample application, I’ve got an error

ImportError: No module named xxx.settings

It was obvious that the problem was that I had Django installed system wide, so even from its own virtualenv my Celery could see Django settings. So I checked if I have references to Django in my environment variables:

printenv | grep xxx

Let’s get rid of Django references for this particular virtualenv. Virtual environments have hooks for different types of events like preactivate or postdeactivate. They are stored in separate files in the virtualenv folder:


In my case I decided to delete Django environment variables after I activate my Celery virtualenv and set them back when I deactivate it. To do that I had to put the following command to $VIRTUAL_ENV/bin/postactivate :


And modify $VIRTUAL_ENV/bin/postdeactivate to set variables back:



Now don’t forget to re-activate the virtualenv and the Celery should run fine:

deactivate  # deactivate virtualenv
workon celery-test  # activate virtualenv

celery worker -A tasks  # run celery


Install Phonegap on Windows

Required tools

1. PhoneGap Desktop application.

This will let you easily transfer the application to the mobile device without necessity to compile the application on host computer and transfer the .apk file (in case of Android device).

Install the PhoneGap Desktop application as described here. Download the installer and run it.

2. PhoneGap CLI

If your goal is simple Javascript applications, you can stop after the previous step. But I’m going to use plugins, so I’ll need a command line tool.

Prerequisite is node.js. Download it and install. I will use the latest version, but LTS is always safer. Note, that on different versions of Windows node.js behaves differently. On Windows8 I recall I got a separate console for Node.js. On Windows7 it can be run from a normal Windows console (type cmd  in the command search).

Now from console run the following command:

npm install -g phonegap@latest

From now on we can use phonegap  command from the command line.

3. Android SDK manager

On windows this comes as a part of Android Studio, though it’s possible to install it separately:

I will download Android Studio: and call SDK Manager from the toolbar.

Optional tools

I store my code on Github, so I’ll need Git.


Download the installer here and run it.

When the installer asks about the PATH modification, I prefer to choose the option to allow git to run from command line (third option on the picture below):
Git installer


Git for Windows as a perfect installer

I just have installed git under Windows and what I want to say: this was probably the most perfect program installer I’ve ever seen.

Usually I have to check if the program didn’t check unnecessary checkboxes and whether it doesn’t try to install some additional crapware. In best cases you just click through without modifying checkboxes.

In case of git I even had to decrease the ‘safety level’ of some options. I just see that this was made with love to users and that creators really thought what people need from their program and how they’re going to use it.

With love to git.

Building a PhoneGap project with plugins in Ubuntu

Okay, ladies and gentlemen, today I’m working on the proof of concept (PoC) of a mobile application that has to work with Bluetooth.

For this purpose I’ve chosen a PhoneGap framework which lets us build mobile application for all mobile platforms (Android, iOS, Windows Phone and some others). Strong side of PhoneGap is plugins – modules of native code for all mobile platforms which can be accessed from PhoneGap Javascript.

Normally for a simple project I’d choose Adobe Build to build the project for me. It can automatically build packages for all mobile platforms for you and even do more like publishing your project in corresponding app markets.

Unfortunately, I had issues building the project using Adobe Builder – it seems not to include plugins to the project. As right now I need only a package for Android, I decided not to strugle with Adobe and to build the .apk locally. For that go to the project directory and run the following:

$ phonegap build android

Build starting… and failing:

[phonegap] executing 'cordova platform add --save android'...
[phonegap] completed 'cordova platform add --save android'
[phonegap] executing 'cordova build android'...
Running command: /var/www/phonegap-bluetooth-poc/platforms/android/cordova/build

[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]

ERROR building one of the platforms: Error: /var/www/phonegap-bluetooth-poc/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project

So, failed to find ‘android’ command in your ‘PATH’. To fix that we need an Android SDK; we’ll get it from Android website.

After installing Android SDK, let’s update environment variables. Add the following lines to the end of ~/.bashrc file (replace /home/minras/Android/Sdk/  with your path):

export ANDROID_HOME=/home/minras/Android/Sdk/
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

And finally run source ~/.bashrc to initialize those variables.

Now the build should succeed:

$ phonegap build android

Alembic template path

Short answer:

Longer story

So I wanted to fix the template I use for alembic revisions, and I always forget where to search for it.

The template is in file in your alembic directory.

For example, my alembic.ini  is in db folder, and my file is located in db/migration.

Internet never forgets

Amazon. Nothing is forgotten. This picture Amazon showed me on some IT website today. First watches here is what I’ve searched for just yesterday on European Amazon, the second one is what I bought from American Amazon five years ago.

So, Internet remembers everything. Feels a bit scary when it’s related personally to you. Your past and your future in one picture built by a computer.

Robot Framework notes

So, I had a chance to try Robot Framework for testing our project. In this post I’ll collect some quick notes and impressions from using the tool.


  • The structure of tests is quite intuitive and straightforward.
  • GUI and the test cases style can be good for testers not familiar with programming (but someone still has to program keywords).

Not good

  • Too GUI based as for developers. Integration with IDE would be handier. Although there are plugins for IDE’s, but I still have to use Robot Framework GUI and the IDE together.
  • Extremely slow application startup, scrolling, test case tree navigation, etc. (V 1.2.3)
  • Have to periodically close/reopen (V 1.2.3).
    • When it doesn’t print results in bottom-right part.
    • When git repository is updated.
  • Insufficient logging/debugging. When test fails or exception is thrown, it becomes a programmer problem to put enough information to exception/log/console.
  • “If it doesn’t work – close it and open again”. Just like Windows.

Personal summary

  • I found it adding unnecessary complexity as an additional GUI tool instead of being an additional library/framework.
  • In case you’re choosing a test framework for your project: good alternative as for me is py.test. It is more programmer-friendly having the same level of integration with Selenium, better integration with IDE; keywords is a nice abstraction, but py.test fixtures are not worse. Both have to have a proper code architecture and structure; then test suites can be good structured and intuitive. If in your project you already use Robot, this paragraph is not relevant.
  • GUI application is very-very slow and full of bugs. In newer versions some issues are fixed. V1.4 doesn’t have the scroll issue, V1.3 doesn’t have to be restarted after every test.

Results of working one iteration (3 weeks) as a tester

  • Installed RobotFramework, Ride for RobotFramework, the test project in local environment (on Ubuntu 14.04).
  • Researched the Ride updates. Current used version is 1.2.x; V1.4 has issue with long start (freezes on Loading window for three minutes); v1.3 is more stable than 1.2.
  • Researched current test project architecture; created a library (class) for working with web driver elements.
  • Researched the possibility to use polling instead of sleep(), including the proof of concept on some test cases.
  • StackOverflow question: Send a keyword to another keyword as a parameter
  • StackOverflow question #2: Send a non-serializable parameter to a keyword


Submit a bug to Ride Github.

PyCharm notes

Most of the notes should be applicable to the latest PyCharm version, but by historical reasons in the office I use PyCharm 3.4, so some of the notes might be related to it.

Auto-expanding import blocks

To make the import blocks expanded by default go to File -> Settings -> Editor -> Code Folding  and uncheck the Imports  check-box.

Explanation: by default the import section in the beginning of Python files is collapsed and for me having it expanded is much more convenient. Because modifying the import section is a common task that is often done manually. And clicking on a small expand/collapse icon is a bit annoying.

Adding a virtual environment (virtualenv) interpreter

Navigate to File -> Settings -> Project Interpreter , click the cog icon in the top-right corner and select Add Local . In the appeared file selection window navigate to your virtual environment directory select a Python executable (for example python2.7), which usually sits in the bin subfolder.

Android development, VirtualBox and KVM

Few times already in the past couple years I tried doing some development for Android, but most of the time I decided to postpone that for another piece of undefined time.

The reason was that I always had issues with setting up the virtual device for debugging. And without debugging there is no development.

So, what was the problem? I always used a VirtualBox machine for development, having Windows as host and Ubuntu as guest. But to run AVD (Android Virtual Device), Linux uses KVM infrastructure; and according to StackOverflow, KVM can’t be run together with VirtualBox.

Although, KVM can be emulated, but then AVD is extremely slow (which I observed on the previous computer).


Solution? I pulled from the shelf one of my old Android phones (not to kill the tablet accidentally) and configured it to be a debugging device instead of AVD. Bingo 🙂

Virtualbox ‘error in supR3HardenedWinReSpawn’ on Windows 8

I have recently bought a desktop PC with Windows 8 on-board, and one of the first programs I installed was Virtualbox.

But unfortunately I’ve got a famous error ‘VirtualBox – Error in supR3HardenedWinReSpawn’ when running any virtual machine. In my case it was NtCreateFile error.


Forums said that the error was introduced somewhere at version 4.3.14 and had to be fixed in later builds (current build is 4.3.28), but in the latest version I still observe the error.

Solution that worked for for me was uninstalling Windows update KB3045999 (to do that, go to Control Panel -> Installed Updates, find patch KB3045999, right click it, choose Uninstall).

Unfortunately, after some time Windows installed the update again, so I had to turn the automatic updates off.

What I tried and what did NOT help:

  • Playing with VirtualBox settings.
  • Downgrading to VirtualBox 4.2.* where some security features are not present yet.

Hope this helps someone.

Even better solution would be to use Linux 🙂

‘Unstage’ a file in git

I usually use a mix of command line and IDE GUI to run git commands. And today while trying to click Git Commit I accidentally clicked Git Add  for the whole folder including my IDE .idea sub-folder which I don’t need in my repository.

So I had to ‘unstage’ the content of the .idea sub-folder.

The operation is opposite to git add  and is called git reset. The parameter is the file (or directory) which has to be ‘unstaged’.

git reset <file>

In my case it was:

git reset .idea

Helpful links