[squeak-dev] CommandLineUIManager

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Wed Nov 6 08:36:49 UTC 2019


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:

[cid:242b0e87-3937-4dd8-b85a-dc07e23fbb5c]


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 <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Chris Muller <asqueaker at gmail.com>
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...

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.

... 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<http://script.st>",

              "contents of script.st<http://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<http://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




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<https://github.com/StephanEggermont/pharo/blob/development/src/UIManager/CommandLineUIManager.class.st#L104> in Squeak.


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org<mailto:squeak-dev-bounces at lists.squeakfoundation.org>> im Auftrag von tim Rowledge <tim at rowledge.org<mailto:tim at rowledge.org>>
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 <Christoph.Thiede at student.hpi.uni-potsdam.de<mailto:Christoph.Thiede at student.hpi.uni-potsdam.de>> 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; tim at rowledge.org<mailto:tim at rowledge.org>; http://www.rowledge.org/tim
 Negligent (adj.), describes a condition in which you absentmindedly answer the door in your nightgown.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191106/fb5ae803/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 287990 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191106/fb5ae803/attachment-0001.png>


More information about the Squeak-dev mailing list