I have a startup script that loads the libraries and project I mostly use, including my own, but I want that script to target specific folders and its subfolders , is this possible ?
|
On 12/02, Dimitris Chloupis wrote:
> I have a startup script that loads the libraries and project I mostly use, > including my own, but I want that script to target specific folders and its > subfolders , is this possible ? You can test values of `SmalltalkImage current`... for example (SmalltalkImage current shortImageName includesSubstring: 'SomePartOfImageName') ifTrue: [ "execute only for that image" ] for folders you could check `SmalltalkImage current imagePath`, etc. -- Peter |
In reply to this post by kilon.alios
Le 02/12/2015 11:35, Dimitris Chloupis a écrit :
> I have a startup script that loads the libraries and project I mostly > use, including my own, but I want that script to target specific folders > and its subfolders , is this possible ? Hi, You can use "FileSystem workingDirectory" to get the directory of the image. Then you can use some condition to execute or not a block that contains your startup script. -- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France signature.asc (836 bytes) Download Attachment |
Thank you both, checking the image name sounds like a great idea to limit the execution of my startup script. On Wed, Dec 2, 2015 at 12:52 PM Ferlicot D. Cyril <[hidden email]> wrote: Le 02/12/2015 11:35, Dimitris Chloupis a écrit : |
In reply to this post by CyrilFerlicot
What's wrong about using FileLocator? I am a late-bound reference. I refer to a file or directory in relation to a well-known location on the filesystem, called an origin. When asked to perform concrete operation, I look up the current location of my origin, and resolve my path against it. Usage ---------- FileLocator vmDirectory parent pathString > '/Applications' FileLocator desktop. FileLocator desktop basename. FileLocator home basename. FileLocator image. FileLocator vmBinary asAbsolute pathString > '/Applications/CogVM.app/Contents/MacOS/CogVM' FileLocator vmBinary pathString > '/Applications/CogVM.app/Contents/MacOS/CogVM' On Wed, Dec 2, 2015 at 11:51 AM, Ferlicot D. Cyril <[hidden email]> wrote: Le 02/12/2015 11:35, Dimitris Chloupis a écrit : |
thanks phil that is very useful too, I will use it for managing my external pharo files :)
|
Dimitris...a bit off topic... but... isn't it a bit too much to load all your packages every time you start your image? I am sure it takes some seconds if not minutes (depending what to load). Since Smalltalk gives us persistency for free (image), why isn't it enough to simply build and save an image and use that one? And when needed, build another one. What I mean is....instead of loading everything in every image startup, load your packages and dependency only when creating new images... On Wed, Dec 2, 2015 at 9:33 AM, Dimitris Chloupis <[hidden email]> wrote:
|
Mariano does not work like that for me. The startup script executes only one time for each image that has not already executed the startup script. So as soon as it installs the libraries and I save then image it does not reinstall them the next time I open the image and I have not noticed any delays to the image startup. To do that I use the runOnce:True message. As a matter of fact I think I learned that from your blog post so I am a bit surprised you ask me that . On Wed, Dec 2, 2015 at 2:56 PM Mariano Martinez Peck <[hidden email]> wrote:
|
here is the script for anyone curious how it works https://www.dropbox.com/s/w88umn72kx2tw6s/startupPharo.st?dl=0 On Wed, Dec 2, 2015 at 3:12 PM Dimitris Chloupis <[hidden email]> wrote:
|
Ah, cool. Here is one I have around (was for Pharo2-3, fails in 4.0 somewhere) on my windows box. Nice little things in there, even if it would need some rework (I am using Linux most of the time now). Phil "Put this in ~/Library/Preferences/pharo/ " "or C:\Users\User\AppData\Roaming\pharo\pharo-preferences.st" Smalltalk isHeadless ifFalse: [ StartupLoader default executeAtomicItems: { StartupAction name: 'Image Setup' code: [ | color red green yellow white isIssueImage backgroundColor | "=============================================================================" "some helper blocks for error printing" color := [:colorCode :text| FileStream stderr "set the color" nextPut: Character escape; nextPut: $[; print: colorCode; nextPut: $m; nextPutAll: text; crlf; "reset the color" nextPut: Character escape; nextPutAll: '[0m'. ]. red := [:text| color value: 31 value: text ]. green := [:text| color value: 32 value: text ]. yellow := [:text| color value: 33 value: text ]. white := [:text| FileStream stderr nextPutAll: text; crlf ]. "Check whether we use an image for issue reporting" isIssueImage := Smalltalk imageFile basename first isDigit. "=============================================================================" Author fullName: 'PhilippeBack'. "=============================================================================" "[" yellow value: 'Loading custom preferences'. Smalltalk tools debugger alwaysOpenFullDebugger: true; filterCommonMessageSends: true. white value: '- set default fonts'. "StandardFonts defaultFont: (LogicalFont familyName: 'Source Code Pro' pointSize: 11)." GraphicFontSettings resetAllFontToDefault. white value: '- preparing tools'. "backgroundColor := Color r: 0.287 g: 0.228 b: 0.338." "PolymorphSystemSettings desktopColor: backgroundColor; showDesktopLogo: false." "UITheme currentSettings fastDragging: true." TextEditorDialogWindow autoAccept: true. SHPreferences setStyleTableNamed: 'Tango'. UITheme currentSettings preferGradientFill: false; preferRoundCorner: false; menuColor: Color white. isIssueImage ifFalse: [ (SystemVersion current major >= 3) ifTrue: [ " No need anymore as they are default in 3.0 white value: '- loading Eclipse icons...'. Gofer new smalltalkhubUser: 'estebanlm' project: 'EclipsePack'; package: 'EclipsePack'; load. white value: '- setting theme to Eclipse theme icons'. ThemeIcons current: EclipseUIThemeIcons new. white value: '- resetting world menu'. World resetWorldMenu. white value: '- reset icon caches of Nautilus'. NautilusUI resetIconCaches. white value: '- Eclipse icons update done.'. " ] ]. (isIssueImage and: [ Smalltalk isInteractive ]) ifTrue: [ | slice | "open a slice inspector" slice := (Smalltalk imageFile basename copyUpTo: $-). (MCFileRepositoryInspector repository: (MCHttpRepository inboxRepository) workingCopy: nil) versionSearchAccept: slice; show. ]. white value: '- adding repositories'. MCRepositoryGroup default addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'DripfeedIt'); addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'HighOctane'); addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'HOWebStack'); addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'HOSeaside'); addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'HOExperiments'); addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'DeepIntoPharo'); addRepository: (MCSmalltalkhubRepository owner: 'laurentlaffont' project: 'TilingWindowManager'); addRepository: (MCSmalltalkhubRepository owner: 'philippeback' project: 'HOExtras'). "Pharo Extras Team Projects" #( 'BitmapCharacterSet' 'CollectionArithmetic' 'Coral' 'EventRecorder' 'FFICompatibility' 'FileSystemLegacy' 'Flotr' 'Gettext' 'ImageWorker' 'JSON' 'LDAP' 'LEDMorph' 'MorphExamplesAndDemos' 'NBOpenGL' 'OPAX' 'OrderPreservingDictionary' 'Pastell' 'Phexample' 'PlotMorph' 'PostgresV2' 'Postmark' 'ProfStef' 'RFB' 'ROE' 'SCouchDBViewServer' 'SMark' 'Smacc' 'Sound' 'Soup' 'Spotlight2' 'Tanker' 'XMLParser' 'XMLSupport' 'XMLWriter' 'XPath' 'readline') do: [ :projectName | MCRepositoryGroup default addRepository: ( MCSmalltalkhubRepository owner: 'PharoExtras' project: projectName) ]. "Customizations" (SystemVersion current major = 3) ifTrue: [ white value: '- specific customizations for 3.0'. white value: '- adding metarepo for 3.0'. MCHttpRepository user: 'philippeback' password: ''. ]. (SystemVersion current major = 2) ifTrue: [ white value: '- specific customizations for 2.0'. ]. "] fork." white value: '- enabling TrueType fonts'. FreeTypeSystemSettings loadFt2Library: true. "=============================================================================" white value: 'Loading Tiling Window Manager'. Gofer new smalltalkhubUser: 'LaurentLaffont'project: 'TilingWindowManager'; package: 'ConfigurationOfTilingWindowManager'; load. ((Smalltalk at: #ConfigurationOfTilingWindowManager) project version: #stable) load. (Smalltalk at: #TWMBar) perform: #showTWMBar: with: true. "=============================================================================" white value: 'Loading slices'. "=============================================================================" (Workspace new contents: 'Welcome Philou'; openLabel: 'Startup') width: 600; height: 230 ";" "setToAdhereToEdge: #bottomLeft;" "makeUnclosable". MCWorkingCopyBrowser new show window width: 700; height: 230 ";" "setToAdhereToEdge: #topLeft;" "makeUnclosable". ] runOnce: true}]. On Wed, Dec 2, 2015 at 2:14 PM, Dimitris Chloupis <[hidden email]> wrote:
|
In reply to this post by kilon.alios
On Wed, Dec 2, 2015 at 10:12 AM, Dimitris Chloupis <[hidden email]> wrote:
UHHHH hahahah ;) On your face! Good point about #runOnce:. I forgot about that. And yeah, you can also manually check if the libs are already loaded or not. I was just curious on how you build your scripts. I have gone another way. Basically, I have build scripts which I use to build different images (for different clients, apps or tools). I use this scripts explicitly each time I want to build a new image. These built scripts end up using Metacello at some point. Then I have startup preferences but are normally related to settings, preferences, look and feel, and some other. Some of those settings are already setup by my build scripts, but these startup helps when I am exploring new Pharo fresh images. Anyway, I just wanted to know how you were handling that. Keep using what works best for you!
|
"color := [:colorCode :text| FileStream stderr "set the color" nextPut: Character escape; nextPut: $[; print: colorCode; nextPut: $m; nextPutAll: text; crlf; "reset the color" nextPut: Character escape; nextPutAll: '[0m'. ]." Nice ideas in that startup , thanks Phil, can you explain this part ? "UHHHH hahahah ;) On your face!" hehe I forget all the time :D "I was just curious on how you build your scripts. " Thats why I asked I was curious how you guys make your startup scripts too " have gone another way. Basically, I have build scripts which I use to build different images (for different clients, apps or tools). I use this scripts explicitly each time I want to build a new image. These built scripts end up using Metacello at some point. " What you mean when you say "build scripts" do you mean makefiles ? I also use a makefile too "Ephestos/Ephestos.image: mkdir Ephestos cd Ephestos; wget -O- get.pharo.org/alpha+vmLatest | bash mv Ephestos/Pharo.image Ephestos/Ephestos.image Ephestos/pharo-ui Ephestos/Ephestos.image clean: rm -rf Ephestos/ run: Ephestos/Ephestos.image Ephestos/pharo-ui Ephestos/Ephestos.image" I like the idea of a startup that detects the image name and if finds a keyword follows a specific set of actions. Diffirent keywords , different image setups :) On Wed, Dec 2, 2015 at 3:45 PM Mariano Martinez Peck <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |