Re: [web2py] Re: How to start server from within a python file ?

2010-08-24 Thread Stef Mientki
 thanks Massimo,

that's the solution,
works under windows and probably will also work under Linux, I'll try.
cheers,
Stef

On 24-08-2010 04:43, mdipierro wrote:
 It does not hang. It starts the server. The server blocks. If you want
 to start the server is a new thread:

 import os, sys, thread, time
 filepath = r'P:/Web2Py/web2py_src/web2py'
 sys.path.append ( filepath )
 os.chdir ( filepath ) ## == absolutely necessary to
 get the version number !!!
 from gluon.main import HttpServer
 server = HttpServer ( password='xxx' ) #ip,port,admin_password)
 thread.start_new_thread(server.start,(,))
 print 'piep'
 time.sleep(1)

 will print piep but will only live for 1. It is up to you to
 handle concurrency.



Re: [web2py] Re: How to start server from within a python file ?

2010-08-23 Thread Stef Mientki
 thanks Massimo,
but it doesn't work by me ...

On 23-08-2010 04:33, mdipierro wrote:
 from gluon.main import HttpServer
here the problem begin, 

Maybe I should start with a more basic question,
what should I do with the sources ?
I don't see a setup file,
so I just dumped the source files in the python site-packages

site-packages\web2py\...

is that enough ?

thanks,
Stef


[web2py] Re: How to start server from within a python file ?

2010-08-23 Thread mdipierro
No.

you either dubmp the gluon folder in site-packages

   site-packages/gluon

or better

   import sys
   sys.path.append('location/to/web2py/')


On Aug 23, 2:16 pm, Stef Mientki stef.mien...@gmail.com wrote:
  thanks Massimo,
 but it doesn't work by me ...

 On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer

 here the problem begin, 

 Maybe I should start with a more basic question,
 what should I do with the sources ?
 I don't see a setup file,
 so I just dumped the source files in the python site-packages

     site-packages\web2py\...

 is that enough ?

 thanks,
 Stef


Re: [web2py] Re: How to start server from within a python file ?

2010-08-23 Thread Stef Mientki
 hi Massimo,


On 23-08-2010 22:56, mdipierro wrote:
 No.

 you either dubmp the gluon folder in site-packages

site-packages/gluon
then it crashes on not having a version number
 or better

import sys
sys.path.append('location/to/web2py/')
the program just hangs completely:

import os, sys
filepath = r'P:/Web2Py/web2py_src/web2py'
sys.path.append ( filepath )
os.chdir ( filepath ) ## == absolutely necessary to get the 
version number !!!
from gluon.main import HttpServer
server = HttpServer ( password='xxx' ) #ip,port,admin_password)
server.start()
print 'piep'

and never says 'piep' :-(

cheers,
Stef

 On Aug 23, 2:16 pm, Stef Mientki stef.mien...@gmail.com wrote:
  thanks Massimo,
 but it doesn't work by me ...

 On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer

 here the problem begin, 

 Maybe I should start with a more basic question,
 what should I do with the sources ?
 I don't see a setup file,
 so I just dumped the source files in the python site-packages

 site-packages\web2py\...

 is that enough ?

 thanks,
 Stef



[web2py] Re: How to start server from within a python file ?

2010-08-23 Thread mdipierro
It does not hang. It starts the server. The server blocks. If you want
to start the server is a new thread:

import os, sys, thread, time
filepath = r'P:/Web2Py/web2py_src/web2py'
sys.path.append ( filepath )
os.chdir ( filepath ) ## == absolutely necessary to
get the version number !!!
from gluon.main import HttpServer
server = HttpServer ( password='xxx' ) #ip,port,admin_password)
thread.start_new_thread(server.start,(,))
print 'piep'
time.sleep(1)

will print piep but will only live for 1. It is up to you to
handle concurrency.



On Aug 23, 5:07 pm, Stef Mientki stef.mien...@gmail.com wrote:
  hi Massimo,

 On 23-08-2010 22:56, mdipierro wrote: No.

  you either dubmp the gluon folder in site-packages

     site-packages/gluon

 then it crashes on not having a version number or better

     import sys
     sys.path.append('location/to/web2py/')

 the program just hangs completely:

 import os, sys
 filepath = r'P:/Web2Py/web2py_src/web2py'
 sys.path.append ( filepath )
 os.chdir ( filepath )                 ## == absolutely necessary to get the 
 version number !!!
 from gluon.main import HttpServer
 server = HttpServer ( password='xxx' ) #ip,port,admin_password)
 server.start()
 print 'piep'

 and never says 'piep' :-(

 cheers,
 Stef



  On Aug 23, 2:16 pm, Stef Mientki stef.mien...@gmail.com wrote:
   thanks Massimo,
  but it doesn't work by me ...

  On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer

  here the problem begin, 

  Maybe I should start with a more basic question,
  what should I do with the sources ?
  I don't see a setup file,
  so I just dumped the source files in the python site-packages

      site-packages\web2py\...

  is that enough ?

  thanks,
  Stef


[web2py] Re: How to start server from within a python file ?

2010-08-22 Thread mdipierro
from gluon.main import HttpServer
server = HttpServer(ip,port,admin_password)
server.start()

On Aug 22, 3:03 pm, Stef Mientki stef.mien...@gmail.com wrote:
  hello,

 I just tried to run Web2Py_CC, (that's the best name I could think of for my 
 editor ;-)
 on Ubuntu and Fedora, and most of the things works quit well.
 One of the problems I encounter is launching of the web2py server.

 Launching the server under windows works perfect through the web2py exe-file)
 For launching the server in Linux,
 from within a python program,
 the only thing I can think of,
 is the use of execfile().

 As I run web2py.py from the command line, it runs ok.

 The following program, doesn't work
 filename = r'P:/Web2Py/web2py_src/web2py/web2py.py'
 import os
 os.chdir ( os.path.split ( filename)[0] )
 print os.getcwd()
 execfile ( filename )

 and gives the following error message:
 Traceback (most recent call last):
   File D:\Data_Python_25\support\test.py, line 21, in module
     execfile ( filename )
   File P:/Web2Py/web2py_src/web2py/web2py.py, line 16, in module
     import gluon.import_all
 ImportError: No module named gluon.import_all

 Now if I add the web2py path to the python system path, I get the following 
 error
 (it looks to me that the web2py_path is not very well derived)
 Traceback (most recent call last):
   File D:\Data_Python_25\support\test.py, line 26, in module
     execfile ( filename )
   File P:/Web2Py/web2py_src/web2py/web2py.py, line 17, in module
     import gluon.widget
   File P:/Web2Py/web2py_src/web2py\gluon\widget.py, line 28, in module
     import main
   File P:/Web2Py/web2py_src/web2py\gluon\main.py, line 63, in module
     version_info = open(os.path.join(web2py_path, 'VERSION'), 'r')
 IOError: [Errno 2] No such file or directory: 
 'D:\\Data_Python_25\\support\\VERSION'

 If try subprocess.Popen,
 import subprocess
 Params = 'python ' + filename + ' -i localhost -v -D 0 -a aap'
 subprocess.Popen ( Params )

 I get the following error:
 web2py Enterprise Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2010
 Version 1.81.5 (2010-07-22 23:56:21)
 Database drivers available: pysqlite2, MSSQL/DB2
 Starting hardcron...
 DEBUG:root:WEB2PY CRON: Acquiring lock
 DEBUG:root:WEB2PY CRON: Releasing cron lock
 please visit:
        http://localhost:8000INFO:root:Hardcron daemon started

 use kill -SIGTERM 2024 to shutdown the web2py server
 INFO:root:starting web server...
 INFO:root:SSL is off
 INFO:root:SSL is off
 DEBUG:Rocket.Errors.ThreadPool:Initializing ThreadPool.
 INFO:Rocket.Errors.ThreadPool:Starting Rocket 1.0.6
 DEBUG:Rocket.Errors.ThreadPool:This platform does not support signals.
 DEBUG:Rocket.Errors.ThreadPool:Starting threads.
 DEBUG:Rocket.Errors.Thread-4:Entering main loop.
 DEBUG:Rocket.Errors.Thread-5:Entering main loop.
 DEBUG:Rocket.Errors.Thread-10:Entering main loop.
 DEBUG:Rocket.Errors.Thread-6:Entering main loop.
 DEBUG:Rocket.Errors.Thread-11:Entering main loop.
 DEBUG:Rocket.Errors.Thread-12:Entering main loop.
 DEBUG:Rocket.Errors.Thread-3:Entering main loop.
 DEBUG:Rocket.Errors.Thread-8:Entering main loop.
 DEBUG:Rocket.Errors.Thread-7:Entering main loop.
 DEBUG:Rocket.Errors.Thread-9:Entering main loop.
 DEBUG:Rocket.Monitor:Entering monitor loop.
 DEBUG:Rocket.Monitor:In receive timed-out connections loop.
 INFO:Rocket.Errors.ThreadPool:Listening on sockets: localhost:8000
 INFO:Rocket.Errors.ThreadPool:Stopping Server
 DEBUG:Rocket.Errors.ThreadPool:Stopping threads.
 DEBUG:Rocket.Monitor:Received a death threat.
 DEBUG:Rocket.Errors.Thread-6:Received a death threat.
 DEBUG:Rocket.Errors.Thread-5:Received a death threat.
 DEBUG:Rocket.Errors.Thread-8:Received a death threat.
 DEBUG:Rocket.Monitor:Flushing waiting connections
 DEBUG:Rocket.Errors.Thread-3:Received a death threat.
 DEBUG:Rocket.Errors.Thread-9:Received a death threat.
 DEBUG:Rocket.Errors.Thread-11:Received a death threat.
 DEBUG:Rocket.Errors.Thread-10:Received a death threat.
 DEBUG:Rocket.Errors.Thread-12:Received a death threat.
 DEBUG:Rocket.Errors.Thread-7:Received a death threat.
 DEBUG:Rocket.Errors.Thread-4:Received a death threat.
 DEBUG:Rocket.Monitor:Flushing queued connections
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-4.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-5.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-10.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-6.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-11.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-3.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-12.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-8.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-7.
 DEBUG:Rocket.Errors.ThreadPool:Removing dead thread: Thread-9.

 any sugestions ?
 thanks,
 Stef Mientki