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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

odarvall
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 ?

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Tim Roberts
On Apr 24, 2019, at 8:11 AM, [hidden email] 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, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

odarvall
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.

On Thursday, 25 April 2019 06:30:04 UTC+2, Tim Roberts wrote:
On Apr 24, 2019, at 8:11 AM, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="GUTVv0SzCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">odar...@... 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, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="GUTVv0SzCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.