I think apt sends the output to stdout. There are two ways to capture
that:

1) redirect stdout to a file, then read and display the file. This is
not thread safe which requires you lock when you do it

2) use multiprocessing or popen and run the function in a separate
process which then captures the output.

I this case I would go with 1.



On Jan 12, 8:24 pm, blackshirt <[email protected]> wrote:
> i have some a littel coding with web2py framework..
> here is my controller and file :
>
> def update():
>    cache = apt.Cache()
>    progress = apt.progress.TextFetchProgress()
>    res = cache.update(progress)
>    return dict(res = res)
>
> in this related view..
>
> {{extend 'layout.html'}}
> {{=res}}
> {{pass}}
>
> the controller works normally, ie. update the APT database.. i see it
> progress on console output.
> but on view just return value
>
> True
>
> after process update finish...
>
> i hope, the output progress, like this normally :
>
> Hithttp://ftp.hk.debian.orgstable Release.gpg
> Hithttp://security.debian.orgstable/updates Release.gpg
> Ignoredhttp://security.debian.org/stable/updates/contrib Translation-
> en
> Failedhttp://security.debian.org/stable/updates/contrib Translation-
> en
> Ignoredhttp://security.debian.org/stable/updates/main Translation-en
> Failedhttp://security.debian.org/stable/updates/main Translation-en
> Ignoredhttp://security.debian.org/stable/updates/non-free
> Translation-en
> Failedhttp://security.debian.org/stable/updates/non-free Translation-
> en
> Hithttp://security.debian.orgstable/updates Release
> Donehttp://security.debian.orgstable/updates Release
> Ignoredhttp://ftp.hk.debian.org/debian/stable/contrib Translation-en
> Failedhttp://ftp.hk.debian.org/debian/stable/contrib Translation-en
> Hithttp://security.debian.orgstable/updates/main amd64 Packages
> Ignoredhttp://ftp.hk.debian.org/debian/stable/main Translation-en
> Failedhttp://ftp.hk.debian.org/debian/stable/main Translation-en
> Hithttp://security.debian.orgstable/updates/contrib amd64 Packages
> Hithttp://security.debian.orgstable/updates/non-free amd64 Packages
> Ignoredhttp://ftp.hk.debian.org/debian/stable/non-free Translation-
> en
> Failedhttp://ftp.hk.debian.org/debian/stable/non-free Translation-en
> Hithttp://ftp.hk.debian.orgstable Release
> Donehttp://ftp.hk.debian.orgstable Release
> Hithttp://ftp.hk.debian.orgstable/main Sources
> Hithttp://ftp.hk.debian.orgstable/contrib Sources
> Hithttp://ftp.hk.debian.orgstable/non-free Sources
> Hithttp://ftp.hk.debian.orgstable/main amd64 Packages
> Hithttp://ftp.hk.debian.orgstable/contrib amd64 Packages
> Hithttp://ftp.hk.debian.orgstable/non-free amd64 Packages
> Done downloading
>
> showing on the view output..
> How we can do this on web2py ?
> i'm still pretty newbie on python and web2py
>
> thanks

Reply via email to