Progress bar for ZnClient>>#downloadTo:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Progress bar for ZnClient>>#downloadTo:

Ben Coman
I see ZnClient >> downloadTo:
calls  ZnClient >> downloadEntityTo:
which uses #withProgressDo: 
which indicates a progress bar might appear.

But...
    ZnClient new 
        url: ' https://download.libsodium.org/libsodium/releases/libsodium-1.0.16-msvc.zip' ;
        downloadTo: FileLocator imageDirectory.
doesn't show a progress bar.  What is the recommended way to display one?

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: Progress bar for ZnClient>>#downloadTo:

Sven Van Caekenberghe-2
Ben,

You disappoint me, as I would expect you to trace senders/users of #signalProgress: ;-)

ZnClient only signals certain Notifications which a UI around it should deal with.

For example,

[ :bar |
  bar title: 'Downloading Sources...'.
  [
    ZnClient new
      url: 'http://files.pharo.org/sources/PharoV30.sources'; 
      signalProgress: true;
      downloadTo: FileLocator temp ]
    on: HTTPProgress
    do: [ :progress |
      progress isEmpty ifFalse: [ bar current: progress percentage ].
      progress resume ] ] asJob run.

But there are other UI approaches as well.

Sven

> On 12 Apr 2018, at 11:25, Ben Coman <[hidden email]> wrote:
>
> I see ZnClient >> downloadTo:
> calls  ZnClient >> downloadEntityTo:
> which uses #withProgressDo:
> which indicates a progress bar might appear.
>
> But...
>     ZnClient new
>         url: ' https://download.libsodium.org/libsodium/releases/libsodium-1.0.16-msvc.zip' ;
>         downloadTo: FileLocator imageDirectory.
> doesn't show a progress bar.  What is the recommended way to display one?
>
> cheers -ben


Reply | Threaded
Open this post in threaded view
|

Re: Progress bar for ZnClient>>#downloadTo:

Ben Coman


On 12 April 2018 at 18:15, Sven Van Caekenberghe <[hidden email]> wrote:
Ben,

You disappoint me, as I would expect you to trace senders/users of #signalProgress: ;-)

:P 
Yeah I knew I was being slack.  I couldn't really follow its operation and was a bit tired.
Actually maybe part of my confusion is that #signalProgress feels more like a command than a status.
I've a slight feeling it would be better as #signallingProgress.

 
ZnClient only signals certain Notifications which a UI around it should deal with.

For example,

[ :bar |
  bar title: 'Downloading Sources...'.
  [
    ZnClient new
      url: 'http://files.pharo.org/sources/PharoV30.sources';
      signalProgress: true;
      downloadTo: FileLocator temp ]
    on: HTTPProgress
    do: [ :progress |
      progress isEmpty ifFalse: [ bar current: progress percentage ].
      progress resume ] ] asJob run.

Thanks, that worked, but its a bit convoluted for my goldfish memory to remember each time.
I'd expect having that as a convenience method would be useful to many.

ZnClient 
showProgress: 'Downloading sources...'
during: [ :znClient | 
znClient downloadTo: FileLocator imageDirectory ]. 

ZnClient class >> showProgress: title during: clientBlock
|client|
client := ZnClient new.
client signallingProgress: true.
[ :bar |
  bar title: title.
  [clientBlock value: client]
      on: HTTPProgress
    do: [ :progress |
      progress isEmpty ifFalse: [ bar current: progress percentage ].
      progress resume ] ] asJob run.

Easily discoverable as the only class-side method of ZnClient, 
and this would also make a useful howto reference. 

 
But there are other UI approaches as well. 

Sven

Thanks for you prompt response.
cheers -ben
 


> On 12 Apr 2018, at 11:25, Ben Coman <[hidden email]> wrote:
>
> I see ZnClient >> downloadTo:
> calls  ZnClient >> downloadEntityTo:
> which uses #withProgressDo:
> which indicates a progress bar might appear.
>
> But...
>     ZnClient new
>         url: ' https://download.libsodium.org/libsodium/releases/libsodium-1.0.16-msvc.zip' ;
>         downloadTo: FileLocator imageDirectory.
> doesn't show a progress bar.  What is the recommended way to display one?
>
> cheers -ben



Reply | Threaded
Open this post in threaded view
|

Re: Progress bar for ZnClient>>#downloadTo:

Ben Coman
You may have guessed I hadn't used Jobs much before.
Then I was surprised that I couldn't find much about Jobs in either 
Pharo By Example, Deep Into Pharo or Enterprise Pharo.

From digging around I made a minimal example I report 
to help others' searches, and open it for improvement.

x := 1.
[
[x < 100] whileTrue:
[ x := x + 10. 
0.1 seconds wait.
]
] forkAt: 30 named: 'worker'. 

[ :job |
[ x < 100 ] whileTrue: 
[ job current: x.
0.1 seconds wait.
]
] asJob 
  title: 'Work progress...';
  min: 0;
max: 100;
run.

cheers -ben


On 12 April 2018 at 23:02, Ben Coman <[hidden email]> wrote:


On 12 April 2018 at 18:15, Sven Van Caekenberghe <[hidden email]> wrote:
Ben,

You disappoint me, as I would expect you to trace senders/users of #signalProgress: ;-)

:P 
Yeah I knew I was being slack.  I couldn't really follow its operation and was a bit tired.
Actually maybe part of my confusion is that #signalProgress feels more like a command than a status.
I've a slight feeling it would be better as #signallingProgress.

 
ZnClient only signals certain Notifications which a UI around it should deal with.

For example,

[ :bar |
  bar title: 'Downloading Sources...'.
  [
    ZnClient new
      url: 'http://files.pharo.org/sources/PharoV30.sources';
      signalProgress: true;
      downloadTo: FileLocator temp ]
    on: HTTPProgress
    do: [ :progress |
      progress isEmpty ifFalse: [ bar current: progress percentage ].
      progress resume ] ] asJob run.

Thanks, that worked, but its a bit convoluted for my goldfish memory to remember each time.
I'd expect having that as a convenience method would be useful to many.

ZnClient 
showProgress: 'Downloading sources...'
during: [ :znClient | 
znClient downloadTo: FileLocator imageDirectory ]. 

ZnClient class >> showProgress: title during: clientBlock
|client|
client := ZnClient new.
client signallingProgress: true.
[ :bar |
  bar title: title.
  [clientBlock value: client]
      on: HTTPProgress
    do: [ :progress |
      progress isEmpty ifFalse: [ bar current: progress percentage ].
      progress resume ] ] asJob run.

Easily discoverable as the only class-side method of ZnClient, 
and this would also make a useful howto reference. 

 
But there are other UI approaches as well. 

Sven

Thanks for you prompt response.
cheers -ben
 


> On 12 Apr 2018, at 11:25, Ben Coman <[hidden email]> wrote:
>
> I see ZnClient >> downloadTo:
> calls  ZnClient >> downloadEntityTo:
> which uses #withProgressDo:
> which indicates a progress bar might appear.
>
> But...
>     ZnClient new
>         url: ' https://download.libsodium.org/libsodium/releases/libsodium-1.0.16-msvc.zip' ;
>         downloadTo: FileLocator imageDirectory.
> doesn't show a progress bar.  What is the recommended way to display one?
>
> cheers -ben




Reply | Threaded
Open this post in threaded view
|

Re: Progress bar for ZnClient>>#downloadTo:

Sven Van Caekenberghe-2
In reply to this post by Ben Coman


> On 12 Apr 2018, at 17:02, Ben Coman <[hidden email]> wrote:
>
>
>
> On 12 April 2018 at 18:15, Sven Van Caekenberghe <[hidden email]> wrote:
> Ben,
>
> You disappoint me, as I would expect you to trace senders/users of #signalProgress: ;-)
>
> :P
> Yeah I knew I was being slack.  I couldn't really follow its operation and was a bit tired.
> Actually maybe part of my confusion is that #signalProgress feels more like a command than a status.
> I've a slight feeling it would be better as #signallingProgress.
>
>  
> ZnClient only signals certain Notifications which a UI around it should deal with.
>
> For example,
>
> [ :bar |
>   bar title: 'Downloading Sources...'.
>   [
>     ZnClient new
>       url: 'http://files.pharo.org/sources/PharoV30.sources';
>       signalProgress: true;
>       downloadTo: FileLocator temp ]
>     on: HTTPProgress
>     do: [ :progress |
>       progress isEmpty ifFalse: [ bar current: progress percentage ].
>       progress resume ] ] asJob run.
>
> Thanks, that worked, but its a bit convoluted for my goldfish memory to remember each time.
> I'd expect having that as a convenience method would be useful to many.
>
> ZnClient
> showProgress: 'Downloading sources...'
> during: [ :znClient |
> znClient url: 'http://files.pharo.org/sources/PharoV30.sources'.
> znClient downloadTo: FileLocator imageDirectory ].
>
> ZnClient class >> showProgress: title during: clientBlock
> |client|
> client := ZnClient new.
> client signallingProgress: true.
> [ :bar |
>   bar title: title.
>   [clientBlock value: client]
>       on: HTTPProgress
>     do: [ :progress |
>       progress isEmpty ifFalse: [ bar current: progress percentage ].
>       progress resume ] ] asJob run.
>
> Easily discoverable as the only class-side method of ZnClient,
> and this would also make a useful howto reference.

All good and well, I understand your point, but as a general rule, I don't want to add UI code to Zn, it is too fundamental for minimal/kernel//headless images.

> But there are other UI approaches as well.
>
> Sven
>
> Thanks for you prompt response.
> cheers -ben
>  
>
>
> > On 12 Apr 2018, at 11:25, Ben Coman <[hidden email]> wrote:
> >
> > I see ZnClient >> downloadTo:
> > calls  ZnClient >> downloadEntityTo:
> > which uses #withProgressDo:
> > which indicates a progress bar might appear.
> >
> > But...
> >     ZnClient new
> >         url: ' https://download.libsodium.org/libsodium/releases/libsodium-1.0.16-msvc.zip' ;
> >         downloadTo: FileLocator imageDirectory.
> > doesn't show a progress bar.  What is the recommended way to display one?
> >
> > cheers -ben


Reply | Threaded
Open this post in threaded view
|

Re: Progress bar for ZnClient>>#downloadTo:

CyrilFerlicot
On 13/04/2018 13:50, Sven Van Caekenberghe wrote:
>
> All good and well, I understand your point, but as a general rule, I don't want to add UI code to Zn, it is too fundamental for minimal/kernel//headless images.
>
>

Hi,

It could be useful to add this kind of methods via extensions in an UI
package not in the default group of Zinc configuration maybe?

And Pharo 7 could integrate the core of zinc in a low level layer during
the bootstrap and the UI stuff in the tooling layer.

--
Cyril Ferlicot
https://ferlicot.fr