HelloWorld sanity check please - AttributeError: 'tuple' object has no attribute 'startswith'

1,403 views
Skip to first unread message

odar...@gmail.com

unread,
Apr 24, 2019, 11:47:22 AM4/24/19
to cherrypy-users
I have a VERY simple application that refuses to start.
This is the error trace:

pi@raspberrypi:~/Projects/HelloWorld $ python3.5m  main.py

[24/Apr/2019:16:50:28] ENGINE Listening for SIGUSR1.
[24/Apr/2019:16:50:28] ENGINE Listening for SIGHUP.
[24/Apr/2019:16:50:28] ENGINE Listening for SIGTERM.
[24/Apr/2019:16:50:28] ENGINE Bus STARTING
[24/Apr/2019:16:50:28] ENGINE Error in 'start' listener <cherrypy._cpchecker.Checker object at 0x76049470>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/cherrypy/process/wspbus.py", line 230, in publish
    output.append(listener(*args, **kwargs))
  File "/usr/local/lib/python3.5/dist-packages/cherrypy/_cpchecker.py", line 40, in __call__
    method()
  File "/usr/local/lib/python3.5/dist-packages/cherrypy/_cpchecker.py", line 144, in check_static_paths
    if os.path.isabs(dir):
  File "/usr/lib/python3.5/posixpath.py", line 64, in isabs
    return s.startswith(sep)
AttributeError: 'tuple' object has no attribute 'startswith'

[24/Apr/2019:16:50:28] ENGINE Started monitor thread 'Autoreloader'.
[24/Apr/2019:16:50:28] ENGINE Serving on http://0.0.0.0:8080
[24/Apr/2019:16:50:28] ENGINE Shutting down due to error in start listener:

main.py:
import os, os.path
import cherrypy


class HelloWorld(object):
        @cherrypy.expose
        def index(self):
                return "Hello World !"


        @cherrypy.expose
        def greet(self, name='Unknown'):
                return "Hello " + name + " !"


if __name__ == '__main__':
        cherrypy.quickstart(HelloWorld(), '/', 'main.conf')

main.conf:
[global]
server.socket_host = '0.0.0.0'
server.socket_port = 8080
log.access_file = ''
log.error_file = ''

[/]
tools.trailing_slash.on = False
tools.staticdir.root = os.path.abspath(os.getcwd())

[/html]
tools.staticdir.on = True
tools.staticdir.dir = './html',
tools.staticdir.index = 'index.html'

[/css]
tools.staticdir.on = True
tools.staticdir.dir = './css'


If I leave only the [global] section in the conf file then the application starts.
So it seems something is wrong with the [/] and onwards part.

But what ? Any ideas ?

Tim Roberts

unread,
Apr 25, 2019, 12:30:04 AM4/25/19
to cherryp...@googlegroups.com
On Apr 24, 2019, at 8:11 AM, odar...@gmail.com wrote:
I have a VERY simple application that refuses to start.
This is the error trace:...
...
main.conf:
...
[/html]
tools.staticdir.on = True
tools.staticdir.dir = './html',
tools.staticdir.index = 'index.html'

You really can't see it?  That the second line in the [/html] section has a trailing comma?  In Python, that turns it from a string constant to a one-item tuple.
— 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

odar...@gmail.com

unread,
Apr 25, 2019, 1:47:48 AM4/25/19
to cherrypy-users
Yeah, it took almost 4 hours for me to eventually spot the extra comma.
Sometimes all you need is an extra pair of (more objective) eyes !

Thanks for the reply.
Reply all
Reply to author
Forward
0 new messages