Sunday, February 24, 2013

Python subprocess throws [Errno 2] No such file or directory

First steps in Python, and I've been spending a while trying to understand why my python script would fail when called from my webserver. The same script would work just fine when I run it manually.

simple example


        import os, sys,

        subprocess.check_call(["mvn", "clean", "install"])

This will work if run manually
mvn clean install

but fails terribly when called by a web server

  File "/home/use/", line 105, in build
  File "/usr/lib/python2.5/", line 457, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python2.5/", line 444, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.5/", line 594, in __init__
    errread, errwrite)
  File "/usr/lib/python2.5/", line 1149, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Reading around, I found tips, that there is no shell, make sure you have bash or csh... Of course, I have shell=False for security, still, I thought "mvn" is pretty well known executable on the system, it should find it, well NO.


and the correct way to do really is

              subprocess.check_call(["/opt/apache-maven-3.0.4/bin/mvn", "clean", "install"])

Friday, February 15, 2013

Check or Turn Off Windows UAC (User Account Control)

Windows User Account Control or UAC is another Windows feature that may cause any non-Microsoft application to malfunction.

Deciding whether the security benefit is worth the trouble is your choice.

Here's my preferred way of verifying it:

1- Open Regedit on the machine
2- check the registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA 
(REG_DWORD) if the key is missing or its value is 0, then it's disabled, any other value (like 1) then it's enabled

The way to do it from the UI is as follow:

From your "Start Menu"
Launch the "Control Panel"
Select "User Accounts"
Then "Change User Account Control Settings"

reboot your computer after any change!