On Jan 15, 11:43 pm, blackshirt <[email protected]> wrote:
> Thanks Massimo, you were great's people..
>
> 1. if we read from file resulted from redirected stdout, i think that
> we get complete output finally, not ongoing process output ??
> that was right, Massimo ?? correct me if i'm wrong ..

you read what has been flushed. If the process has completed you read
everything.

>
> 2. if we are using popen (popen2 or whatever), first arguments was
> cmd.. i think that cmd was external program or script, not function
> inside controller.. is true like that ?
> i don't want use external script/helper.. is it possible ?

you can probably do with the multiprocessing module. I am not sure how
it handles stdout.


> On Jan 15, 12:15 am, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > 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.orgstableRelease.gpg
> > > Hithttp://security.debian.orgstable/updatesRelease.gpg
> > > Ignoredhttp://security.debian.org/stable/updates/contribTranslation-
> > > en
> > > Failedhttp://security.debian.org/stable/updates/contribTranslation-
> > > en
> > > Ignoredhttp://security.debian.org/stable/updates/mainTranslation-en
> > > Failedhttp://security.debian.org/stable/updates/mainTranslation-en
> > > Ignoredhttp://security.debian.org/stable/updates/non-free
> > > Translation-en
> > > Failedhttp://security.debian.org/stable/updates/non-freeTranslation-
> > > en
> > > Hithttp://security.debian.orgstable/updatesRelease
> > > Donehttp://security.debian.orgstable/updatesRelease
> > > Ignoredhttp://ftp.hk.debian.org/debian/stable/contribTranslation-en
> > > Failedhttp://ftp.hk.debian.org/debian/stable/contribTranslation-en
> > > Hithttp://security.debian.orgstable/updates/mainamd64Packages
> > > Ignoredhttp://ftp.hk.debian.org/debian/stable/mainTranslation-en
> > > Failedhttp://ftp.hk.debian.org/debian/stable/mainTranslation-en
> > > Hithttp://security.debian.orgstable/updates/contribamd64Packages
> > > Hithttp://security.debian.orgstable/updates/non-freeamd64Packages
> > > Ignoredhttp://ftp.hk.debian.org/debian/stable/non-freeTranslation-
> > > en
> > > Failedhttp://ftp.hk.debian.org/debian/stable/non-freeTranslation-en
> > > Hithttp://ftp.hk.debian.orgstableRelease
> > > Donehttp://ftp.hk.debian.orgstableRelease
> > > Hithttp://ftp.hk.debian.orgstable/mainSources
> > > Hithttp://ftp.hk.debian.orgstable/contribSources
> > > Hithttp://ftp.hk.debian.orgstable/non-freeSources
> > > Hithttp://ftp.hk.debian.orgstable/mainamd64Packages
> > > Hithttp://ftp.hk.debian.orgstable/contribamd64Packages
> > > Hithttp://ftp.hk.debian.orgstable/non-freeamd64Packages
> > > 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