Look at the scheduler documentation. I have mine called this way from
my db.py. This calls a few different tasks, adding file size and also
calling a task called unzip / untar which are functions i have written
to handle zipping and unzipping. Hopefully this explains it somewhat


def upload_post_hook(row_id):

    row = db(db.uploads.id == row_id).select('up_file', 'username',
'filename')[0]

    add_size(row_id)

    if row.filename.endswith('.zip'):
        scheduler.queue_task(unzip,pvars=dict(filename=row.up_file,
username=row.username, folder=request.folder,
real_filename=row.filename, id=row_id))
    if any(row.filename.endswith(ext) for ext in ['.tar', 'tgz',
'.tar.gz', '.tar.bz', '.tar.xz', '.tar.bz2']):
      scheduler.queue_task(untar,pvars=dict(filename=row.up_file,
username=row.username, folder=request.folder,
real_filename=row.filename, id=row_id))

    return None


db.uploads._after_insert.append(lambda id, i: upload_post_hook(i))

On 30 January 2014 16:31, desta <demes...@gmail.com> wrote:
> Hello everyone,
>
> A user uploads a file through a form and I want to process it using an
> external python script. I read from the manual about the Homemade task
> queues (http://web2py.com/books/default/chapter/29/04#Homemade-task-queues).
> I understand how it works.
>
> What I am missing is how to actually run the following command from my
> controller
>
> python web2py.py -S app -M -R applications/app/private/myscript.py -A a b c
>
>
> I would appreciate any help!
>
> Thanks for reading
>
> --
> 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/groups/opt_out.

-- 
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/groups/opt_out.

Reply via email to