Hi all,
does Squeak already support something like a CommandLineUIManager?
For example, #inform: should print the argument on stdout, #request: could read a line from stdin, and #informUserDuring: could print an ascii-styled progress bar.
As far as I found out, Squeak only has a CommandLineToolSet. Am I missing a class? Do you think this would be a useful extension?
Best, Christoph
Carpe Squeak!
|
Hi Christoph, On Fri, Nov 1, 2019 at 7:29 PM Thiede, Christoph <[hidden email]> wrote:
I know about Squeak Shell: Check out its debugger integration. But that's different to what you are proposing.
Could you elaborate on your use case? Is this simply to be able to write interactive cmd scripts in Squeak? Best, Fabio
|
In reply to this post by Christoph Thiede
> On 2019-11-01, at 11:29 AM, Thiede, Christoph <[hidden email]> wrote: > > Hi all, > > does Squeak already support something like a CommandLineUIManager? We discussed some stuff around this topic back in May '19 relating to "Running Squeak fro ma unix shell script file with #! squeak..." (including the spilling mistook). And don't forget CommandShell (http://map.squeak.org/package/2c3b916b-75e2-455b-b25d-eba1bbc94b84), OSProcess (http://map.squeak.org/package/812c9d14-5236-4cad-82ea-cc3e3837e30d), and Eliot's simple exemplar REPL thing (https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/LoadReader.st & https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/StartReader.st) I also see that http://www.squeaksource.com/@azqxWT7-o5bjyYS2/vd0deS9q claims to include a REPL package (never tried it, see also http://gulik.pbworks.com/w/page/7760030/REPLServer) And I'm sure Craig has done something related but I simply cannot get google to find it right now tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Negligent (adj.), describes a condition in which you absentmindedly answer the door in your nightgown. |
Hi,
Thank you for all the interesting links, most of all to the SqueakShell! It is really cool, but however, it actually does not solve my corner.
@Fabio:
> > As far as I found out, Squeak only has a CommandLineToolSet. Am I missing a class? Do you think this would be a useful extension?
> Could you elaborate on your use case? Is this simply to be able to write interactive cmd scripts in Squeak?
Exactly. If you run a simple script such as [HelpIcons squeakIcon writeOnFileNamed: 'testicon.png'] in headless mode and testicon.png already exists, the execution will be halted and the VM is waiting for a user interaction that will never happen. It would be much nicer to get a prompt via stdout + stdin to answer.
And even if the VM is run in a read-only shell, you would at least know why it does not continue to execute. For example, this would be helpful on smalltalkCI - if you had not caught all ProvideAnswerNotifications in your tests, you would basically have no hint why you get a timeout.
I know Squeak is primarily made for use in a VM window, but nonetheless, I would love to have an implementation similar to this one for Pharo in Squeak.
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von tim Rowledge <[hidden email]>
Gesendet: Freitag, 1. November 2019 20:01:50 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] CommandLineUIManager > On 2019-11-01, at 11:29 AM, Thiede, Christoph <[hidden email]> wrote: > > Hi all, > > does Squeak already support something like a CommandLineUIManager? We discussed some stuff around this topic back in May '19 relating to "Running Squeak fro ma unix shell script file with #! squeak..." (including the spilling mistook). And don't forget CommandShell (http://map.squeak.org/package/2c3b916b-75e2-455b-b25d-eba1bbc94b84), OSProcess (http://map.squeak.org/package/812c9d14-5236-4cad-82ea-cc3e3837e30d), and Eliot's simple exemplar REPL thing (https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/LoadReader.st & https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/StartReader.st) I also see that http://www.squeaksource.com/@azqxWT7-o5bjyYS2/vd0deS9q claims to include a REPL package (never tried it, see also http://gulik.pbworks.com/w/page/7760030/REPLServer) And I'm sure Craig has done something related but I simply cannot get google to find it right now tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Negligent (adj.), describes a condition in which you absentmindedly answer the door in your nightgown.
Carpe Squeak!
|
On Mon, Nov 4, 2019 at 3:16 PM Thiede, Christoph <[hidden email]> wrote:
I agree. Maybe there could be two modes: `strict` and `interactive`. The former quits the image with an error and the latter prompts for user input via stdin as you suggest.
I agree, it'd be great if smalltalkCI builds fail in case a ProvideAnswerNotification is thrown. Contributions to smalltalkCI are welcome. ;)
Cool, didn't know something like this exists in Pharo. Best, Fabio
|
In reply to this post by Christoph Thiede
Hi Christoph, I don't know if you're actually looking for an interactive REPL, but if all you need is to run a script...
... then you only need to wrap your expression in a Smalltalk run: [ ... ] block. For example, if you wrap your expression and put it into some file, say, "script.st", "contents of script.st" Smalltalk run: [HelpIcons squeakIcon writeOnFileNamed: 'testicon.png'] then, it'll be ready for headless, you can: squeak -vm display=none my.image script.st > my.out 2>&1 and it'll redirect all stdout and stderr to file "my.out". All uncaught exceptions (except Halt, I think) are handled and printed. For servers, one thing I also put at the beginning my run block is: Smalltalk mitigateIfHeadless which starts the RFB server, only if it's in headless mode, so I can get in there if I need to. HTH, Chris
|
Hi Chris,
unfortunately, I cannot reproduce your command - in my shell, the VM only outputs that "pthread_setschedparam failed: Operation not permitted. This VM uses a separate heartbeat thread ..." warning and then hangs on, even if my script ends by calling Smalltalk quitPrimitive.
---
However, I made the example with #writePNGfileNamed: because if the file exists, it does not raise an Error or some other unhandled exception, but a FileExistsException which, by default, opens a UIManager. This happens just so often in Squeak that I would like to implement a CommandLIneUIManager for this case.
And of course, you might even combine this with the SqueakShell to avoid this inconsistent situation:
If I find some time, I will be happy to upload some proposal into the inbox :)
@Fabio: Yes, separately handling a ProvideAnswerNotification in the SCITestRunner sounds good. However, I would first focus on solving that problem for all CLI applications, but I will keep it in mind :)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Chris Muller <[hidden email]>
Gesendet: Mittwoch, 6. November 2019 00:27:27 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] CommandLineUIManager Hi Christoph,
I don't know if you're actually looking for an interactive REPL, but if all you need is to run a script...
... then you only need to wrap your expression in a Smalltalk run: [ ... ] block. For example, if you wrap your expression and put it into some file, say, "script.st",
"contents of script.st"
Smalltalk run: [HelpIcons squeakIcon writeOnFileNamed: 'testicon.png']
then, it'll be ready for headless, you can:
squeak -vm display=none my.image
script.st > my.out 2>&1
and it'll redirect all stdout and stderr to file "my.out". All uncaught exceptions (except Halt, I think) are handled and printed.
For servers, one thing I also put at the beginning my run block is:
Smalltalk mitigateIfHeadless
which starts the RFB server, only if it's in headless mode, so I can get in there if I need to.
HTH,
Chris
Carpe Squeak!
|
Hi Christoph,
I believe it has nothing to do with my command. Even if you try to just run squeak -version in that environment, I think you'll get the same error. There are two flavors of the Linux VM, you're using the version of the VM that's a little better, but requires you to install a file into your security limits that allows it to work. Create a text file called "squeak.conf" with these contents (between the horizontal lines): * hard rtprio 2 * soft rtprio 2Copy that file to /etc/security/limits.d/squeak.conf and you should now be able to launch the Squeak VM, and my command will work, even with FileExistsException.
You could consider refactoring writePNGfileNamed: and other places to dispatch to an interim-level method that takes the actual Stream you want to write to, that way, instead of having to worry about catching exceptions, you can simply create your own FileStream (with UI's, or not) and use the lower-level method. Even though I think it could be improved, asking for a file via UI is a real use-case for Squeak, and supporting that use-case in a way that allows overriding via exception handling is a good idea. Best, Chris
|
> On 2019-11-06, at 7:43 PM, Chris Muller <[hidden email]> wrote: > There are two flavors of the Linux VM, you're using the version of the VM that's a little better, but requires you to install a file into your security limits that allows it to work. > > Create a text file called "squeak.conf" with these contents (between the horizontal lines): > > * hard rtprio 2 > * soft rtprio 2 The daft thing is that this problem was purportedly fixed in linux kernels as of {mumble-mumble} years ago. Raspbian, for example, does not need it and Raspbian is based on a very conservative branch of Debian tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Strange OpCodes: IXM: Initiate X-rated error Messages |
On Thu, Nov 7, 2019 at 6:30 AM tim Rowledge <[hidden email]> wrote:
If your VM quits, then you should update it. We removed the exit call after the warning (see David's commit at [1]). We haven't actually observed any misbehavior in case the squeak.conf is not present. Fabio [1] https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/32f321583c69ca27e61ffaff6decc2a3e4b6ca5e > |
In reply to this post by timrowledge
On Wed, Nov 06, 2019 at 09:30:44PM -0800, tim Rowledge wrote:
> > > > On 2019-11-06, at 7:43 PM, Chris Muller <[hidden email]> wrote: > > There are two flavors of the Linux VM, you're using the version of the VM that's a little better, but requires you to install a file into your security limits that allows it to work. > > > > Create a text file called "squeak.conf" with these contents (between the horizontal lines): > > > > * hard rtprio 2 > > * soft rtprio 2 > > The daft thing is that this problem was purportedly fixed in linux kernels as of {mumble-mumble} years ago. Raspbian, for example, does not need it and Raspbian is based on a very conservative branch of Debian > Uhmm... it's not a "problem" that needs to be fixed. The Rasbian distribution of Debian Linux is typically intended as single-user system on which you can safely assume that if the user does something dumb, then it serves him/her right when the system locks up. In the general case of a multi-user system, you don't want someone to elevate their thread priorities and accidentally lock up the entire system. That's why you are not allowed to use real time scheduling priority in ordinary user applications. Some Linux distributions enforce this by default, and others do not. I think that it more or less depends on the intended audience for the distribution. Dave |
@Chris:
> I believe it has nothing to do with my command. Even if you try to just run > squeak -version
> in that environment, I think you'll get the same error.
No, this one works:
(Just wondering why the current Trunk image is delivered with a VM that has version 5.0 ...) Creating the squeak.conf did not change the behavior for me. I am using a Ubuntu WSL.
Von: Squeak-dev <[hidden email]> im Auftrag von David T. Lewis <[hidden email]>
Gesendet: Freitag, 8. November 2019 14:34 Uhr An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] CommandLineUIManager On Wed, Nov 06, 2019 at 09:30:44PM -0800, tim Rowledge wrote:
> > > > On 2019-11-06, at 7:43 PM, Chris Muller <[hidden email]> wrote: > > There are two flavors of the Linux VM, you're using the version of the VM that's a little better, but requires you to install a file into your security limits that allows it to work. > > > > Create a text file called "squeak.conf" with these contents (between the horizontal lines): > > > > * hard rtprio 2 > > * soft rtprio 2 > > The daft thing is that this problem was purportedly fixed in linux kernels as of {mumble-mumble} years ago. Raspbian, for example, does not need it and Raspbian is based on a very conservative branch of Debian > Uhmm... it's not a "problem" that needs to be fixed. The Rasbian distribution of Debian Linux is typically intended as single-user system on which you can safely assume that if the user does something dumb, then it serves him/her right when the system locks up. In the general case of a multi-user system, you don't want someone to elevate their thread priorities and accidentally lock up the entire system. That's why you are not allowed to use real time scheduling priority in ordinary user applications. Some Linux distributions enforce this by default, and others do not. I think that it more or less depends on the intended audience for the distribution. Dave
Carpe Squeak!
|
Hi Christoph, Le ven. 8 nov. 2019 à 22:24, Thiede, Christoph <[hidden email]> a écrit :
curious, which graphic environment? Xming or something?
|
In reply to this post by Christoph Thiede
> curious, which graphic environment? Xming or something?
Von: Squeak-dev <[hidden email]> im Auftrag von Nicolas Cellier <[hidden email]>
Gesendet: Freitag, 8. November 2019, 22:46 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] CommandLineUIManager Hi Christoph,
Le ven. 8 nov. 2019 à 22:24, Thiede, Christoph <[hidden email]> a écrit :
curious, which graphic environment? Xming or something?
Carpe Squeak!
|
Ah, obviously, it's CommandLine thread... So you use a regular windows VM when you want to switch to graphical I presume... I asked because i have tested launching xcfe in wsl directed to a windows X server (VcXserv). It works, but lacks of stability... Le sam. 9 nov. 2019 à 01:38, Thiede, Christoph <[hidden email]> a écrit :
|
No, I'm not using a Windows VM.
On my laptop, Windows 10 is installed (but not Windows Server). I activated the feature WSL which emulates a virtual Linux, where I chose Ubuntu. Afaik, WSL does not support graphical environment, and I did not even try to achieve this. Hope this helps :-) Von: Squeak-dev <[hidden email]> im Auftrag von Nicolas Cellier <[hidden email]>
Gesendet: Samstag, 9. November 2019 22:30:30 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] CommandLineUIManager Ah, obviously, it's CommandLine thread...
So you use a regular windows VM when you want to switch to graphical I presume...
I asked because i have tested launching xcfe in wsl directed to a windows X server (VcXserv). It works, but lacks of stability...
Le sam. 9 nov. 2019 à 01:38, Thiede, Christoph <[hidden email]> a écrit :
Carpe Squeak!
|
Free forum by Nabble | Edit this page |