Thursday, May 1, 2014

Sigal

I had the following problem in sigal after upgrade to Ubuntu 14.04:

INFO: Processing /home/luc/sigal_pictures/pictures/2014/04/27/mvi_6794.avi
INFO: Processing /home/luc/sigal_pictures/pictures/2014/04/25/img_6755.jpg
INFO: Processing /home/luc/sigal_pictures/pictures/2014/04/11/img_6667.jpg
INFO: Processing /home/luc/sigal_pictures/pictures/2014/04/24/img_6698.jpg
INFO: Processing /home/luc/sigal_pictures/pictures/2014/04/10/img_6632.jpg
Traceback (most recent call last):
  File "/home/luc/pythonenvs/py27/bin/sigal", line 9, in <module>
    load_entry_point('sigal==0.6.0', 'console_scripts', 'sigal')()
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/sigal/__init__.py", line 154, in main
    parser.dispatch()
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/argh/helpers.py", line 53, in dispatch
    return dispatch(self, *args, **kwargs)
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/argh/dispatching.py", line 124, in dispatch
    for line in lines:
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/argh/dispatching.py", line 200, in _execute_command
    for line in result:
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/argh/dispatching.py", line 183, in _call
    result = args.function(*positional, **keywords)
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/sigal/__init__.py", line 109, in build
    gal.build()
  File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/sigal/gallery.py", line 226, in build
    self.pool.map_async(worker, media_list).get(9999)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 558, in get
    raise self._value
OSError: [Errno 2] No such file or directory

This traceback doesn’t show the real culprit because it uses a pool. The trick was then to use sigal build -n 1 to tell it to not create a multithreading pool.

The OSError occured during the following code:

def call_subprocess(cmd):
    """Wrapper to call subprocess.Popen and return stdout & stderr."""
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

which I changed to:

def call_subprocess(cmd):
    """Wrapper to call subprocess.Popen and return stdout & stderr."""
    try:
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except Exception as e:
        raise e.__class__('Error while running `%s` : %s' % (cmd, e))

And the problem finally became unveiled:

OSError: Error while running `['ffmpeg', '-i', u'/home/luc/sigal_pictures/pictures/2014/04/27/mvi_6794.avi']` : [Errno 2] No such file or directory

Which then leads to some explanations:

(Since videos aren’t that important in my blog, I personally then chose to remove the blog tag from all videos instead of getting ffmpeg.)