[squeak-dev] CommandLineUIManager

Chris Muller asqueaker at gmail.com
Thu Nov 7 03:43:43 UTC 2019


Hi Christoph,


> 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.
>
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  2

Copy 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.


> ---
>
>
> 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.
>
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


> 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 <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",
>
>               "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
>
>
>
>>
>> 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> im
>> Auftrag von tim Rowledge <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> 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; 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/040c0059/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 287990 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191106/040c0059/attachment-0001.png>


More information about the Squeak-dev mailing list