[Python/CherryPy]

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • eXtink
  • Registratie: Februari 2009
  • Niet online
Beste mede-tweakers!

Ik ben tegen een probleem aangelopen met cherrypy voor python. Als ik cherry wil importeren vanuit een lib folder dan werkt cherry niet correct (zie test2.py) Echter als ik cherrypy importeer vanuit hetzelfde niveau als de executable (test.py) dan werkt het correct. Zou iemand mij dit kunnen uitleggen waarom het niet werkt? In de lib folder is een lege __init__.py aanwezig.

test.py
code:
1
2
3
4
5
6
7
8
import cherrypy
options_dict = {
                'log.screen':               True,
                'server.socket_port':       8797,
        }
cherrypy.config.update(options_dict)    
cherrypy.server.start() 
cherrypy.engine.exit()

Output test.py
code:
1
2
3
4
5
6
7
8
9
C:\Users\Bob\Programming\Hoarder>python test.py
[05/Feb/2014:16:54:09] ENGINE Serving on 127.0.0.1:8797
[05/Feb/2014:16:54:09] ENGINE Bus STOPPING
[05/Feb/2014:16:54:09] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8797)) shut down
[05/Feb/2014:16:54:09] ENGINE No thread running for None.
[05/Feb/2014:16:54:09] ENGINE No thread running for None.
[05/Feb/2014:16:54:09] ENGINE Bus STOPPED
[05/Feb/2014:16:54:09] ENGINE Bus EXITING
[05/Feb/2014:16:54:09] ENGINE Bus EXITED



test2.py
code:
1
2
3
4
5
6
7
8
import libs.cherrypy as cherrypy
options_dict = {
                'log.screen':               True,
                'server.socket_port':       8797,
        }
cherrypy.config.update(options_dict)    
cherrypy.server.start() 
cherrypy.engine.exit()

Output test2.py
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
C:\Users\Bob\Programming\Hoarder>python test2.py
[05/Feb/2014:16:55:18] ENGINE Serving on 127.0.0.1:8080
[05/Feb/2014:16:55:18] ENGINE Serving on 127.0.0.1:8080
[05/Feb/2014:16:55:18] ENGINE Bus STOPPING
[05/Feb/2014:16:55:18] ENGINE Bus STOPPING
[05/Feb/2014:16:55:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down
[05/Feb/2014:16:55:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down
[05/Feb/2014:16:55:18] ENGINE HTTP Server None already shut down
[05/Feb/2014:16:55:18] ENGINE HTTP Server None already shut down
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE No thread running for None.
[05/Feb/2014:16:55:18] ENGINE Bus STOPPED
[05/Feb/2014:16:55:18] ENGINE Bus STOPPED
[05/Feb/2014:16:55:18] ENGINE Bus EXITING
[05/Feb/2014:16:55:18] ENGINE Bus EXITING
[05/Feb/2014:16:55:18] ENGINE Bus EXITED
[05/Feb/2014:16:55:18] ENGINE Bus EXITED

Acties:
  • 0 Henk 'm!

  • Solopher
  • Registratie: December 2002
  • Laatst online: 11-09 14:55
Volgens mij zou dit moeten werken?
Python:
1
from libs import cherrypy


Dat werkt dus niet :-), maar klein vraagje waarom maak je geen gebruik van Virtualenv?
Dan kun je namelijk met pip gewoon je requirements installeren in plaats van een "losse" module te gebruiken.

[ Voor 54% gewijzigd door Solopher op 05-02-2014 20:37 ]