[web2py] Re: How to execute a function in scheduler.py using command line

2017-05-18 Thread Dave S


On Thursday, May 18, 2017 at 12:02:02 PM UTC-7, icodk wrote:
>
> As I understand( might be wrong) what you suggest is to execute a function 
> in a controller 
>

yes

 

> but  scheduler.py is not a controller and it is in the models folder
>

yes
 

> I could QUEUE the function and run the scheduler but it is cumbersome  to 
> wait for the scheduler and debugging is  not the same 
>

You only to specify current time for the start time; the scheduler will run 
it ASAP.
As for information for debugging, standard out is recorded (up to a limit), 
so "print" can be very useful.
 

> I could  also  copy the function to a controller and  back to the 
> scheduler.py.hope there is a better way
>
>
Why not just start a python shell, import your module, and run it 
interactively?

/dps

 

>
> On Thursday, May 18, 2017 at 3:19:06 PM UTC+2, icodk wrote:
>>
>> For testing purposes I would like to execute a function in scheduler.py 
>> using command line (better ideas are welcome)
>> I tried:
>> web2py.exe  -S myapp/scheduler/dummy_task  -M
>>
>> But got the following error
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2017
>> Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>> Database drivers available: psycopg2, pymysql, imaplib, MySQLdb, sqlite3, 
>> pyodbc
>> Traceback (most recent call last):
>>   File "", line 6, in 
>>   File "__main__.py", line 128, in 
>>   File "__main__web2py__.py", line 33, in 
>>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\widget.py", line 1146, 
>> in start
>> cronjob=options.cronjob)
>>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\shell.py", line 245, 
>> in run
>> exec read_pyc(pycfile) in _env
>>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\compileapp.py", line 
>> 461, in read_pyc
>> data = read_file(filename, 'rb')
>>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\fileutils.py", line 
>> 103, in read_file
>> f = open(filename, mode)
>> IOError: [Errno 2] No such file or directory: 
>> 'applications\\myapp\\compiled\\controllers_scheduler_dummy_task.pyc'
>>
>>
>>
>> Thanks for any help
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to execute a function in scheduler.py using command line

2017-05-18 Thread icodk
As I understand( might be wrong) what you suggest is to execute a function 
in a controller but  scheduler.py is not a controller and it is in the 
models folder
I could QUEUE the function and run the scheduler but it is cumbersome  to 
wait for the scheduler and debugging is  not the same 
I could  also  copy the function to a controller and  back to the 
scheduler.py.hope there is a better way


On Thursday, May 18, 2017 at 3:19:06 PM UTC+2, icodk wrote:
>
> For testing purposes I would like to execute a function in scheduler.py 
> using command line (better ideas are welcome)
> I tried:
> web2py.exe  -S myapp/scheduler/dummy_task  -M
>
> But got the following error
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2017
> Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
> Database drivers available: psycopg2, pymysql, imaplib, MySQLdb, sqlite3, 
> pyodbc
> Traceback (most recent call last):
>   File "", line 6, in 
>   File "__main__.py", line 128, in 
>   File "__main__web2py__.py", line 33, in 
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\widget.py", line 1146, 
> in start
> cronjob=options.cronjob)
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\shell.py", line 245, in 
> run
> exec read_pyc(pycfile) in _env
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\compileapp.py", line 
> 461, in read_pyc
> data = read_file(filename, 'rb')
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\fileutils.py", line 
> 103, in read_file
> f = open(filename, mode)
> IOError: [Errno 2] No such file or directory: 
> 'applications\\myapp\\compiled\\controllers_scheduler_dummy_task.pyc'
>
>
>
> Thanks for any help
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to execute a function in scheduler.py using command line

2017-05-18 Thread Dave S


On Thursday, May 18, 2017 at 6:19:06 AM UTC-7, icodk wrote:
>
> For testing purposes I would like to execute a function in scheduler.py 
> using command line (better ideas are welcome)
> I tried:
> web2py.exe  -S myapp/scheduler/dummy_task  -M
>
> But got the following error
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2017
> Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
> Database drivers available: psycopg2, pymysql, imaplib, MySQLdb, sqlite3, 
> pyodbc
> Traceback (most recent call last):
>   File "", line 6, in 
>   File "__main__.py", line 128, in 
>   File "__main__web2py__.py", line 33, in 
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\widget.py", line 1146, 
> in start
> cronjob=options.cronjob)
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\shell.py", line 245, in 
> run
> exec read_pyc(pycfile) in _env
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\compileapp.py", line 
> 461, in read_pyc
> data = read_file(filename, 'rb')
>   File "C:\Dev\web\web2py_win\web2py_2_14_06\gluon\fileutils.py", line 
> 103, in read_file
> f = open(filename, mode)
> IOError: [Errno 2] No such file or directory: 
> 'applications\\myapp\\compiled\\controllers_scheduler_dummy_task.pyc'
>
>
>
> Thanks for any help
>


I haven't tried to do that, but it's easy enough to use a "non-exposed" 
function to QUEUE a task.  It's now in the book (in the latest builds, but 
not yet on the website).

See 
https://groups.google.com/d/msg/web2py-developers/cI7R-9hex7k/PfTsGodYEwAJ>
for the draft text.

/dps

 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.