Topic on Extension talk:Collection

Collection Extension: RuntimeError: command failed with returncode 256

17
Anewuserformediawiki (talkcontribs)

Hello,

I'm using MediaWiki 1.16.3 with a Windows XAMPP-Stack 1.7.4 (Apache 2.2.17, MySQL 5.5.8, PHP 5.3.5 (VC6 X86 32bit) + PEAR).

I tried to install and configure the Collection extension with the following LocalSettings.php configuration:

require_once("$IP/extensions/Collection/Collection.php");

$wgCollectionMWServeURL = "http://tools.pediapress.com/mw-serve/";

$wgCollectionFormats = array('rl' => 'PDF', 'odf' => 'ODT', );

When I try to download the PDF/ODT offline Version of a new book I get an error message:

Auf dem Render-Server ist ein Fehler aufgetreten: RuntimeError: RuntimeError: command failed with returncode 256: ['mw-zip', '-o', u'cache/ee/ee57ce6375c56696/collection.zip', '-m', u'cache/ee/ee57ce6375c56696/metabook.json', '--status', u'qserve://localhost:14311/ee57ce6375c56696:makezip', '--config', u'http://s10vitl01/wiki', '--template-blacklist', u'MediaWiki:PDF Template Blacklist', '--template-exclusion-category', u'Vom Druck ausschlie\xdfen', '--print-template-prefix', u'Drucken', '--print-template-pattern', u'$1/Druck'] Last Output: 2011-11-04T07:40:17 mwlib.options.warn >> Both --print-template-pattern and --print-template-prefix (deprecated) specified. Using --print-template-pattern only. 1% creating nuwiki in u'cache/ee/ee57ce6375c56696/tmpl0yZuX/nuwiki' ERR: <urlopen error [Errno 4] ARES_ENOTFOUND: Domain name not found> ERR: <urlopen error [Errno 4] ARES_ENOTFOUND: Domain name not found> ERR: <urlopen error [Errno 4] ARES_ENOTFOUND: Domain name not found> ERR: <urlopen error [Errno 4] ARES_ENOTFOUND: Domain name not found> Traceback (most recent call last): File "/home/pp/local/lib/python2.7/site-packages/gevent/greenlet.py", line 402, in run result = self._run(*self.args, **self.kwargs) File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/make_nuwiki.py", line 120, in run self.fetch_pages_from_metabook(api) File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/make_nuwiki.py", line 60, in fetch_pages_from_metabook fetch_images=not self.options.noimages) File "/home/pp/local/lib/python2.7/site-packages/mwlib/net/fetch.py", line 268, in __init__ siteinfo = self.get_siteinfo_for(self.api) File "/home/pp/local/lib/python2.7/site-packages/mwlib/net/fetch.py", line 417, in get_siteinfo_for return m.get_siteinfo() File "/home/pp/local/lib/python2.7/site-packages/mwlib/net/sapi.py", line 166, in get_siteinfo raise RuntimeError("could not get siteinfo") RuntimeError: could not get siteinfo <Greenlet at 0x24aff30: <bound method start_fetcher.run of <mwlib.apps.make_nuwiki.start_fetcher object at 0x2540c50>>> failed with RuntimeError removing tmpdir u'cache/ee/ee57ce6375c56696/tmpl0yZuX' memory used: res=16.6 virt=128.9 1% error Traceback (most recent call last): File "/home/pp/local/bin/mw-zip", line 9, in <module> load_entry_point('mwlib==0.12.17', 'console_scripts', 'mw-zip')() File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/buildzip.py", line 155, in main make_zip(output, options, env.metabook, podclient=podclient, status=status) File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/buildzip.py", line 50, in make_zip make_nuwiki(fsdir, metabook=metabook, options=options, podclient=podclient, status=status) File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/make_nuwiki.py", line 193, in make_nuwiki pool.join(raise_error=True) File "/home/pp/local/lib/python2.7/site-packages/gevent/pool.py", line 105, in join raise greenlet.exception RuntimeError: could not get siteinfo in function system, file ./bin/nslave.py, line 37 in function qaddw, file /home/pp/local/lib/python2.7/site-packages/qs/slave.py, line 66

Any help would be appreciated.

212.66.144.68 (talkcontribs)

Hallo i have the same error, even if i use my own render Server or if i use the $wgCollectionMWServeURL = ("http://tools.pediapress.com/mw-serve/"); Server!!!!! Please any one can help? I'm using wiki 1.17.0

46.180.199.47 (talkcontribs)

I have the same problem. I use trunk version of this extention and MW 19.2. My settings:

require_once( "$IP/extensions/Collection/Collection.php" );
$wgCollectionFormats = array(
	  'rl' => 'PDF',
	  'odf' => 'ODT',
);

  $wgCollectionArticleNamespaces = array(
	  NS_MAIN,
	  NS_PROJECT,
);

$wgCollectionMWServeURL = ("http://tools.pediapress.com/mw-serve/");

Error message:

RuntimeError: RuntimeError: command failed with returncode 256: ['mw-zip', '-o', u'/home/pp/cache/ce/ce21a325a1031a95/collection.zip', '-m', u'/home/pp/cache/ce/ce21a325a1031a95/metabook.json', '--status', u'qserve://localhost:14311/ce21a325a1031a95:makezip', '--template-blacklist', u'MediaWiki:PDF Template Blacklist', '--template-exclusion-category', u'\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0435\u0447\u0430\u0442\u0438', '--print-template-prefix', u'\u041f\u0435\u0447\u0430\u0442\u044c', '--print-template-pattern', u'$1/\u041f\u0435\u0447\u0430\u0442\u044c'] Last Output: 2012-04-20T22:43:24 mwlib.options.warn >> Both --print-template-pattern and --print-template-prefix (deprecated) specified. Using --print-template-pattern only. 1% creating nuwiki in u'/home/pp/cache/ce/ce21a325a1031a95/tmpkvsX2V/nuwiki' removing tmpdir u'/home/pp/cache/ce/ce21a325a1031a95/tmpkvsX2V' memory used: res=15.7 virt=122.5 1% error Traceback (most recent call last): File "/home/pp/local/bin/mw-zip", line 9, in <module> load_entry_point('mwlib==0.13.3', 'console_scripts', 'mw-zip')() File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/buildzip.py", line 151, in main make_zip(output, options, env.metabook, podclient=podclient, status=status) File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/buildzip.py", line 50, in make_zip make_nuwiki(fsdir, metabook=metabook, options=options, podclient=podclient, status=status) File "/home/pp/local/lib/python2.7/site-packages/mwlib/apps/make_nuwiki.py", line 152, in make_nuwiki assert x.wikiident in id2wiki, "no wikiconf for %r (%s)" % (x.wikiident, x) AssertionError: no wikiconf for None (<article {'_env': <mwlib.wiki.Environment object at 0x1666250>, 'content_type': u'text/x-wiki', 'title': u'\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430', 'timestamp': u'1326466208', 'type': 'article', 'revision': u'2311'}>) in function system, file ./bin/nslave.py, line 63 in function qaddw, file /home/pp/local/lib/python2.7/site-packages/qs/slave.py, line 66

85.158.224.252 (talkcontribs)

You need to specify credentials for the pdf generation to work.

First try if those commands work on your system:
mw-zip -c http://hostname/wiki --username=yourusername --password=yourpassword -o startpage.zip Main_Page mw-render -c startpage.zip -o startpage.pdf -w rl

If this works then you are good to go - without the --username and --password it would not work.

If this worked you can proceeded by adding the following below your require_once
$wgCollectionMWServeCredentials = "yourusername:yourpassword";

This worked for me :)

This post was posted by 85.158.224.252, but signed as User:Friesoft.

Varnent (talkcontribs)

Still not working for me. Anyone else having better luck?

Pastakhov (talkcontribs)

apache access_log on mw-zip with the --username and --password

92.46.175.36 - - [31/May/2012:13:10:26 +0600] "POST /w/api.php HTTP/1.1" 301 317 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:10:26 +0600] "GET /w/api.php HTTP/1.1" 500 128 "-" "Python-urllib/2.7"

without the --username and --password

92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap|namespacealiases|magicwords|rightsinfo&format=json HTTP/1.1" 301 446 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap|namespacealiases|magicwords|rightsinfo&format=json HTTP/1.1" 500 128 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap|namespacealiases|magicwords&format=json HTTP/1.1" 301 435 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap|namespacealiases|magicwords&format=json HTTP/1.1" 500 128 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap|namespacealiases&format=json HTTP/1.1" 301 424 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap|namespacealiases&format=json HTTP/1.1" 500 128 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap&format=json HTTP/1.1" 301 407 "-" "Python-urllib/2.7"
92.46.175.36 - - [31/May/2012:13:15:14 +0600] "GET /w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|interwikimap&format=json HTTP/1.1" 500 128 "-" "Python-urllib/2.7"


mw-zip says

...
ERR: HTTP Error 500: MediaWiki configuration Error
...
RuntimeError: could not get siteinfo
Pastakhov (talkcontribs)

in LocalSettings.php add $wgEnableAPI = true;
This worked for me :)

Unikum~mediawikiwiki (talkcontribs)
Inkydjango (talkcontribs)

Newbie on this extension, i have spend my time to have the solution of this.

You need more than just the module, you must install some local server to translate your wiki page on pdf file.

You must install firt the tool to access to module install pip

# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
# tar zxvf setuptools-0.6c11.tar.gz
# cd setuptools-0.6c11
# python setup.py build
# python setup.py install 
$ wget http://pypi.python.org/packages/source/p/pip/pip-1.2.tar.gz
$ tar xvf pip-1.2.tar.gz
$ cd pip-1.2
# python setup.py install


  • when it is done, you must follow that :
# yum install g++ perl python python-dev python-setuptools python-imaging python-lxml libevent-devel
# yum install python-devel 
# yum install libxml2-python.x86_64 libxslt-python.x86_64 libxslt-devel.x86_64
# yum install python-imaging python-lxml pdftk
# wget http://python-distribute.org/distribute_setup.py
# sudo python distribute_setup.py
# sudo easy_install -U virtualenv
$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$ gtar -zxvf Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
$ ~/plone-python/bin/python setup.py install 
# pip install -i http://pypi.pediapress.com/simple/ pil
# pip install -i http://pypi.pediapress.com/simple/ mwlib
# pip install -i http://pypi.pediapress.com/simple/ mwlib.rl
# pip install -i http://pypi.pediapress.com/simple/ pyfribidi
  • verif de l'install
# mw-zip -c :en -o test.zip Acdc Number
# mw-render -c test.zip -o test.pdf -w rl
  • boot script example mw-serve
#!/bin/sh
#
#chkconfig: 345 20 80
#
#description: mw-serve

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin

case "$1" in
    start)
        su - www-data -c 'nserve.py >> /tmp/mwcache/log.txt 2>&1  &'
        su - www-data -c 'mw-qserve >> /tmp/mwcache/log.txt 2>&1 &'
        su - www-data -c 'nslave.py --cachedir /tmp/mwcache/ >> /tmp/mwcache/log.txt 2>&1 &'
        su - www-data -c 'postman.py >> /tmp/mwcache/log.txt 2>&1 &'
    ;;
  stop)
        mv /data/mwcache/log.txt /data/mwcache/log.old
        killall nserve.py
        killall mw-qserve
        killall nslave.py
        killall postman.py
    ;;
  force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/mw-serve {start|stop}"
    exit 1
    ;;
esac

exit 0
# mkdir /tmp/mw-serve
# adduser www-data
# chown www-data /etc/init.d/mw-serve
# chown -R www-data /tmp/mw-serve
# chkconfig --add mw-serve
# /etc/init.d/mw-serve start

config file

following an extract of my localsettings.php file

require_once("$IP/extensions/PdfExport/PdfExport.php");
$wgPdfExportMwLibPath = '/usr/bin/mw-render';
$wgPdfExportBackground = "/tmp/background-image/image.jpg";
$wgPdfExportAttach = true;

########################
# creation pdf 
require_once("$IP/extensions/Collection/Collection.php");
$wgCollectionFormats=array( 'rl' => 'PDF', );

#$wgCollectionPODPartners = false;
$wgGroupPermissions['*']['collectionsaveascommunitypage'] = true;
$wgGroupPermissions['*']['collectionsaveasuserpage']      = true;
$wgEnableAPI = true;
$wgCollectionMWServeCredentials = "collection_user:password";
$wgCollectionMaxArticles = 150;

# Collection tool for the PediaPress extension
$wgCollectionMWServeURL="http://localhost:8899/";
$wgCommunityCollectionNamespace=NS_MEDIAWIKI;

  • You can help yourself with this link to complete this previous process

http://edutechwiki.unige.ch/en/Mediawiki_collection_extension_installation

Inkydjango (talkcontribs)

So I have done this process, but it is still not running. The command line is OK. The create PDF page from special page is OK, but the create book on the main nenu NOK.

On the log.txt, the pdf file is created but the log show that mw-zip can create the file. A file with 0 octet size stay on the cache directory.

THe firewall on 8899 is open. The cache directory is 777 permission for the moment. I don't find the solution. Is there anybody that a complete install process working ??

Thanks a lot

Inkydjango (talkcontribs)

my error is

File "/usr/lib64/python2.6/site-packages/mwlib/apps/make_nuwiki.py", line 152, in make_nuwiki
        assert x.wikiident in id2wiki, "no wikiconf for %r (%s)" % (x.wikiident,  x)
    AssertionError: no wikiconf for None (<article {'_env': <mwlib.wiki.Environment object at 0x8eec90>, 'content_type': u'text/x-wiki', 'title': u'Recontruction des handlers', 'timestamp': u'1286529761', 'type': 'article', 'revision': u'661'}>)
     in function system, file /usr/bin/nslave.py, line 64
62.231.10.170 (talkcontribs)

The only way to deal with

no wikiconf for None

is to define $wgScriptPath in config, making it different from "", i.e.

$wgScriptPath       = "/w";

or

$wgScriptPath       = "http://server_name"; #WITHOUT SLASH ON END

but not

$wgScriptPath       = "";

it's a bug in collection extension (see https://github.com/pediapress/Collection/issues/1)

Kghbln (talkcontribs)

This one is a life-saver. I just added this info to the extensions page. Thank you for sharing. :) Cheers

188.22.199.103 (talkcontribs)
97.64.134.182 (talkcontribs)

When following your instructions I discovered some issues on my Centos server. Below is a quote from your instructions:

start)

       su - www-data -c 'nserve.py >> /tmp/mwcache/log.txt 2>&1  &'
       su - www-data -c 'mw-qserve >> /tmp/mwcache/log.txt 2>&1 &'
       su - www-data -c 'nslave.py --cachedir /tmp/mwcache/ >> /tmp/mwcache/log.txt 2>&1 &'
       su - www-data -c 'postman.py >> /tmp/mwcache/log.txt 2>&1 &'
   ;;
 stop)
       mv /data/mwcache/log.txt /data/mwcache/log.old
       killall nserve.py
       killall mw-qserve
       killall nslave.py
       killall postman.py
   ;;

I made the following changes in BOLD:

start)

       su - www-data -c 'nserve >> /tmp/mwcache/log.txt 2>&1  &'
       su - www-data -c 'mw-qserve >> /tmp/mwcache/log.txt 2>&1 &'
       su - www-data -c 'nslave --cachedir /tmp/mwcache/ >> /tmp/mwcache/log.txt 2>&1 &'
       su - www-data -c 'postman >> /tmp/mwcache/log.txt 2>&1 &'
   ;;
 stop)
       mv /tmp/mwcache/log.txt /tmp/mwcache/log.old
       killall nserve
       killall mw-qserve
       killall nslave
       killall postman
   ;;


Thank you for all of your help

This post was posted by 97.64.134.182, but signed as Jecker.

WessexOne (talkcontribs)

Hi,

I know this thread is quite old but encountered this problem and none of the suggested fixes worked for me. Just in case anyone else has the same issue still, I thought I'd post my solution.

I'm running a private render server on the same server as our Wiki. CentOS 6.5 x64 MediaWiki 1.22.6 PHP 5.3.3 MySQL 5.1.73 Collection Version 1.6.1

The first step is to ensure SELINUX is disabled. If it was not, the curl_exec($ch) didn't work for me (and I couldn't figure out how to make it work with SELinux).

The second step is to edit

$IP/extensions/Collection/Collection.body.php

In the function

static function mwServeCommand( $command, $args ) {

Replace

$serveURL = $wgCollectionMWServeURL;

with

$serveURL = 'myservername:8899/';

For me, this got rid of the "RuntimeError: command failed with returncode 256" error as it seems that, regardless of what is set in LocalSettings.php, $wgCollectionMWServeURL was being set to pediapress. However, I was then left with the "The POST request to server:8899/ failed ($2)" error. I fixed this by replacing

$response = Http::post($serveURL, array('postData' => $args));

with

$boundary = '--myboundary-bps';
$retval= '';
foreach($args as $key => $value){
    $retval .= "--$boundary\nContent-Disposition: form-data; name=\"$key\"\n\n$value\n";
}
$retval .= "--$boundary--";
$body = $retval;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data; boundary=$boundary"));
curl_setopt($ch, CURLOPT_URL, $serveURL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec($ch);


I got the code from this site and tweaked it http://scraperblog.blogspot.co.uk/2013/07/php-curl-multipart-form-posting.html

Nemo bis (talkcontribs)

I don't see a bug filed for $wgCollectionMWServeURL being overridden, please file one or even better submit a patch. Thanks!

Reply to "Collection Extension: RuntimeError: command failed with returncode 256"