Running code on image startup

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

Running code on image startup

Luke Gorrie-4
Howdy!

I'd like some morphs to update themselves when the image is started,
but I don't see a convenient "image started" hook to attach to.
Can someone suggest a way?

(The morphs are supposed to present a directory based on the files in
some directory and I want to be able to maintain those files
separately from the image.)

Hacking SmalltalkImage>>snapshot:andQuit:embedded: is tempting but
perhaps excessively kludgy. :-)

Cheers,
-Luke



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Edgar J. De Cleene



El 1/28/08 5:47 AM, "Luke Gorrie" <[hidden email]> escribió:

> Howdy!
>
> I'd like some morphs to update themselves when the image is started,
> but I don't see a convenient "image started" hook to attach to.
> Can someone suggest a way?
>
> (The morphs are supposed to present a directory based on the files in
> some directory and I want to be able to maintain those files
> separately from the image.)
>
> Hacking SmalltalkImage>>snapshot:andQuit:embedded: is tempting but
> perhaps excessively kludgy. :-)
>
> Cheers,
> -Luke

You could have some class named MyStart, with class method startUp with your
code.
Then do Smalltalk addToStartUpList: MyStart in Workspace.

Ready !



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

johnmci
Sure and don't forget you should use the method to indicate where in  
the StartUpList: you want your class to start up. There is a method to
indicate which class you should be before, or is that after?   We know  
this by heart because we got burned with it in Sophie early on. Yes we  
do
want to start the FreeType/Rome subsystem *before* Morphic starts....

Otherwise your Class startup gets added somewhere in the sequential  
starutp  list, maybe not where you expect.

On Jan 28, 2008, at 1:57 AM, Edgar J. De Cleene wrote:

> You could have some class named MyStart, with class method startUp  
> with your
> code.
> Then do Smalltalk addToStartUpList: MyStart in Workspace.
>
> Ready !

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Luke Gorrie-4
In reply to this post by Edgar J. De Cleene
"Edgar J. De Cleene" <[hidden email]> writes:

> You could have some class named MyStart, with class method startUp with your
> code.
> Then do Smalltalk addToStartUpList: MyStart in Workspace.

Thanks!

Is there a simple way that I could make this happen automatically upon
either loading my code from Monticello or loading my Project file? I
know that ChangeSets have a mechanism along these lines and I could
use a pointer to an example or somesuch.

Cheers,
-Luke



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Luke Gorrie-4
Luke Gorrie <[hidden email]> writes:

> Is there a simple way that I could make this happen automatically upon
> either loading my code from Monticello or loading my Project file?

OK, now I reckon I see how 'postscript's work in ChangeSets and
Monticello repositories.

Unfortunately when I use the Monticello feature 'Edit postscript' with
Monticello version kph-434 in the OLPC XO image I end up in the
debugger with "MessageNotUnderstood: PackageInfo>>postscript"

Any ideas? Or is that too XO-specific for this list?

Cheers,
-Luke



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

keith1y
Luke Gorrie wrote:

> Luke Gorrie <[hidden email]> writes:
>
>  
>> Is there a simple way that I could make this happen automatically upon
>> either loading my code from Monticello or loading my Project file?
>>    
>
> OK, now I reckon I see how 'postscript's work in ChangeSets and
> Monticello repositories.
>
> Unfortunately when I use the Monticello feature 'Edit postscript' with
> Monticello version kph-434 in the OLPC XO image I end up in the
> debugger with "MessageNotUnderstood: PackageInfo>>postscript"
>
> Any ideas? Or is that too XO-specific for this list?
>
> Cheers,
> -Luke
>  
Try an upto date version of PackageInfo from http://www.squeaksource.com/mc

You might also consider trying updating all of the package loading stuff
via the LevelPlayingField script at http://installer.pbwiki.com/

best regards

Keith

Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Bert Freudenberg
In reply to this post by Luke Gorrie-4
On Jan 28, 2008, at 11:44 , Luke Gorrie wrote:

> "Edgar J. De Cleene" <[hidden email]> writes:
>
>> You could have some class named MyStart, with class method startUp  
>> with your
>> code.
>> Then do Smalltalk addToStartUpList: MyStart in Workspace.
>
> Thanks!
>
> Is there a simple way that I could make this happen automatically upon
> either loading my code from Monticello or loading my Project file?

Sure. That's why everyone puts that call into a class initialize  
method. You know about "browse senders", don't you? ;)

- Bert -

Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Edgar J. De Cleene
In reply to this post by Luke Gorrie-4



El 1/28/08 8:16 AM, "Luke Gorrie" <[hidden email]> escribió:

> OK, now I reckon I see how 'postscript's work in ChangeSets and
> Monticello repositories.
>
> Unfortunately when I use the Monticello feature 'Edit postscript' with
> Monticello version kph-434 in the OLPC XO image I end up in the
> debugger with "MessageNotUnderstood: PackageInfo>>postscript"
>
> Any ideas? Or is that too XO-specific for this list?
 "Normal" Monticello don't have preamble or postcript.
For Normal I meant the version on 3.10 , which Ralph modify for we in
release team use.
But Monticello have several flavors and Impara have versions which manage
preamble and postcript.
Another posibility is your have your own how to.
Add a class method #processMonticello which in turns call your own #preamble
and #postcript.

Steal of ChangeSets , your codes should be some like
processMonticello
self preamble.
self load: myExternalThing.
self postcript

and in Workspace you do

Mystuff processMonticello

Next question ? :=)

Edgar



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Jon Hylands
In reply to this post by Edgar J. De Cleene
On Mon, 28 Jan 2008 06:57:21 -0300, "Edgar J. De Cleene"
<[hidden email]> wrote:

> You could have some class named MyStart, with class method startUp with your
> code.
> Then do Smalltalk addToStartUpList: MyStart in Workspace.

Actually, the class side method you need to implement is #startUp:

The argument is a boolean, to say whether the image is a fresh start or
resuming from an image save.

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      [hidden email]      http://www.huv.com/jon

  Project: Micro Raptor (Small Biped Velociraptor Robot)
           http://www.huv.com/blog

Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Bert Freudenberg
On Jan 28, 2008, at 14:03 , Jon Hylands wrote:

> On Mon, 28 Jan 2008 06:57:21 -0300, "Edgar J. De Cleene"
> <[hidden email]> wrote:
>
>> You could have some class named MyStart, with class method startUp  
>> with your
>> code.
>> Then do Smalltalk addToStartUpList: MyStart in Workspace.
>
> Actually, the class side method you need to implement is #startUp:
>
> The argument is a boolean, to say whether the image is a fresh  
> start or
> resuming from an image save.

Actually actually, the inherited implementation of #startUp: sends  
#startUp.

So if you do not care if it is a fresh start or snapshot, implement  
#startUp.

- Bert -



Reply | Threaded
Open this post in threaded view
|

nintendo - es

Reinhard Handl
In reply to this post by keith1y
Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Luke Gorrie-4
In reply to this post by Bert Freudenberg
Bert Freudenberg <[hidden email]> writes:

> Sure. That's why everyone puts that call into a class initialize
> method. You know about "browse senders", don't you? ;)

Thanks smart-pants. :-)



Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Janko Mivšek
In reply to this post by Luke Gorrie-4
Hi Luke,

Luke Gorrie wrote:

> Is there a simple way that I could make this happen automatically upon
> either loading my code from Monticello or loading my Project file? I
> know that ChangeSets have a mechanism along these lines and I could
> use a pointer to an example or somesuch.

You can simply put a startup registration code into class method
#initialize of one of your classes. This method will be called every
time you load a package consisting that class.

Best regards
JAnko



--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Jon Hylands
In reply to this post by Bert Freudenberg
On Mon, 28 Jan 2008 14:25:32 +0100, Bert Freudenberg <[hidden email]>
wrote:

> Actually actually, the inherited implementation of #startUp: sends  
> #startUp.

Wow, that's pretty funny - I've been doing this (using startUp:) for years
without realizing that.

> So if you do not care if it is a fresh start or snapshot, implement  
> #startUp.

I guess it depends on what you're doing... For me, what happens at image
startup (launching a mission) is different from what happens resuming a
save (nothing).

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      [hidden email]      http://www.huv.com/jon

  Project: Micro Raptor (Small Biped Velociraptor Robot)
           http://www.huv.com/blog

Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

keith1y
In reply to this post by Edgar J. De Cleene
Edgar J. De Cleene wrote:

>
> El 1/28/08 8:16 AM, "Luke Gorrie" <[hidden email]> escribió:
>
>  
>> OK, now I reckon I see how 'postscript's work in ChangeSets and
>> Monticello repositories.
>>
>> Unfortunately when I use the Monticello feature 'Edit postscript' with
>> Monticello version kph-434 in the OLPC XO image I end up in the
>> debugger with "MessageNotUnderstood: PackageInfo>>postscript"
>>
>> Any ideas? Or is that too XO-specific for this list?
>>    
>  "Normal" Monticello don't have preamble or postcript.
> For Normal I meant the version on 3.10 , which Ralph modify for we in
> release team use.
>  
Monticello in 3.10 DOES have preamble and postcript support. However the
version of packageInfo in 3.10 does not. The same is probably true of
the OLPC images.

LevelPlayingField is designed to work on all images including the XO. I
havent tried it yet but Matthew has.

Keith


Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

Tapple Gao
On Mon, Jan 28, 2008 at 07:15:24PM +0000, Keith Hodges wrote:
> LevelPlayingField is designed to work on all images including the XO. I
> havent tried it yet but Matthew has.

Works great. Etoys-2.3 with LPF is the only image I am using
right now, and the one I am building DeltaStreams with. I made a
couple of fixes to Installer and Monticello so that LPF loads
cleanly on etoys images. It still asks if you want to update
SqueakMap, though.

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808

Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

David Zmick
i want to do a similar thing, except, i want my image to run roundUpStrays on startup, how do i do that?

On Jan 28, 2008 10:14 PM, Matthew Fulmer <[hidden email]> wrote:
On Mon, Jan 28, 2008 at 07:15:24PM +0000, Keith Hodges wrote:
> LevelPlayingField is designed to work on all images including the XO. I
> havent tried it yet but Matthew has.

Works great. Etoys-2.3 with LPF is the only image I am using
right now, and the one I am building DeltaStreams with. I made a
couple of fixes to Installer and Monticello so that LPF loads
cleanly on etoys images. It still asks if you want to update
SqueakMap, though.

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808




Reply | Threaded
Open this post in threaded view
|

Re: nintendo - es

David Zmick
In reply to this post by Reinhard Handl
im not, but it looks really cool!

On Jan 28, 2008 7:28 AM, <[hidden email]> wrote:
anybody involved in this?

http://www.gamasutra.com/php-bin/news_index.php?story=16503

cheers, rfh






Reply | Threaded
Open this post in threaded view
|

Re: Running code on image startup

tblanchard
In reply to this post by David Zmick
You have to add your class to the startup list.

search for senders of addToStartUpList:

You'll find they are usually class side initialize methods and that those classes also implement class method startUp - which is called after an image is opened.

There is a corresponding shutDown list as well.

On Jan 29, 2008, at 2:52 PM, David Zmick wrote:

i want to do a similar thing, except, i want my image to run roundUpStrays on startup, how do i do that?

On Jan 28, 2008 10:14 PM, Matthew Fulmer <[hidden email]> wrote:
On Mon, Jan 28, 2008 at 07:15:24PM +0000, Keith Hodges wrote:
> LevelPlayingField is designed to work on all images including the XO. I
> havent tried it yet but Matthew has.

Works great. Etoys-2.3 with LPF is the only image I am using
right now, and the one I am building DeltaStreams with. I made a
couple of fixes to Installer and Monticello so that LPF loads
cleanly on etoys images. It still asks if you want to update
SqueakMap, though.

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808