Package: python-bottle
Version: 0.8.0-1
Severity: normal

Hello,

thanks for packaging Bottle.

I'd like to run a bottle server without it spewing messages to
stdout/stderr. For that, I need to turn off the welcome code here:

   def run(app=None, server=AutoServer, host='127.0.0.1', port=8080,
           interval=1, reloader=False, **kargs):
       """ Runs bottle as a web server. """
       app = app if app else default_app()
       quiet = bool(kargs.get('quiet', False))
       # Instantiate server, if it is a class instead of an instance
       if isinstance(server, type):
           server = server(host=host, port=port, **kargs)
       if not isinstance(server, ServerAdapter):
           raise RuntimeError("Server must be a subclass of WSGIAdapter")
       if not quiet and isinstance(server, ServerAdapter): # pragma: no cover
           if not reloader or os.environ.get('BOTTLE_CHILD') == 'true':
               print "Bottle server starting up (using %s)..." % repr(server)
               print "Listening on http://%s:%d/"; % (server.host, server.port)
               print "Use Ctrl-C to quit."
               print
           else:
               print "Bottle auto reloader starting up..."
       try:
           if reloader and interval:
               reloader_run(server, app, interval)
           else:
               server.run(app)
       except KeyboardInterrupt:
           if not quiet: # pragma: no cover
               print "Shutting Down..."

Note that in order to do it, one just needs to pass quiet=True. Great.
Except, it uses kargs.get instead of kargs.pop, therefore leaving quiet
in the args that are passed to the server constructor 3 lines later.

Except, nowhere it says that the server constructor will accept a
'quiet' argument:

   $ ./arki-server ../data/conf  --quiet
   Traceback (most recent call last):
   [...]
     File "./arki-server", line 385, in start_server
       bottle.run(host=info.host, port=info.port, quiet=True)
     File "/usr/lib/pymodules/python2.5/bottle.py", line 1246, in run
       server.run(app)
     File "/usr/lib/pymodules/python2.5/bottle.py", line 1219, in run
       return sa(self.host, self.port, **self.options).run(handler)
     File "/usr/lib/pymodules/python2.5/bottle.py", line 1143, in run
       httpserver.serve(app, host=self.host, port=str(self.port), 
**self.options)
   TypeError: serve() got an unexpected keyword argument 'quiet'

All I'm left is monkeypatching ServerAdapter to remove quiet from its
args:

    # Monkeypatch bottle.ServerAdapter in order not to choke on 'quiet'
    oldinit = bottle.ServerAdapter.__init__
    def wrapper(self, host='127.0.0.1', port=8080, **kargs):
        kargs.pop("quiet", None)
        oldinit(self, host, port, **kargs)
    bottle.ServerAdapter.__init__ = wrapper

And yet, it's not enough:

    $ ./arki-server ../data/conf  --quiet
    serving on http://127.0.0.1:8080

There is no way whatsoever to tell paste's httpserver to shut up. It
just damn prints. From /usr/share/pyshared/paste/httpserver.py:

    if converters.asbool(start_loop):
        protocol = is_ssl and 'https' or 'http'
        host, port = server.server_address
        if host == '0.0.0.0':
            print 'serving on 0.0.0.0:%s view at %s://127.0.0.1:%s' % \
                (port, protocol, port)
        else:
            print "serving on %s://%s:%s" % (protocol, host, port)
        try:
            server.serve_forever()
        except KeyboardInterrupt:
            # allow CTRL+C to shutdown
            pass

I'll now quietly go in a corner to sob and pull all my hair out one by
one.


Cheers,

Enrico

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-bottle depends on:
ii  python                        2.5.4-9    An interactive high-level object-o
ii  python-support                1.0.8      automated rebuilding support for P

python-bottle recommends no packages.

python-bottle suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to