Code Monkey home page Code Monkey logo

scale's Introduction

Build Status

Scale

Scale aims to take Pharo into the shell. That is, to write shell scripts in Pharo, use its power, and have a better syntax instead of the ugly bash one :).

DISCLAIMER: Scale is tested only in Linux.

Installing

For installing Scale you have to be SUDOER and to have internet connection.

Development vs Usage

We have two flavors for installing Scale. ZeroConf, and Classic. If you want to see what is happening during the installation, or if you want to do your own modifications, you want to follow the classic guide. If you just want to use it, ZeroConf is your deal.

ZeroConf

Because nobody likes to do it in more than one line:

wget -O- https://raw.githubusercontent.com/guillep/Scale/master/setupScale.sh | bash

The Classic installation

git clone https://github.com/guillep/Scale
cd Scale
./build/build.sh
./build/scale-bootstrap ./build/install.st

Then please add the Scale binaries to your $PATH:

export PATH="$HOME/.scale/scale:$PATH"

Checking the installation

$> scale --version
Scale 0.1 for Pharo5.0
$> scale --help
Scale - Executing pharo scripts
=========================================================

scale [ options | script-path  [ script-options]  ] 

[options] 
	--version	prints the version
	--help		prints this help 

[ example ] 
	$> scale /path/to/script.st  --script-option=1

Scale-UI (For debugging and code edition)
=========================================================

scale-ui [ script-path  [ script-options]  | folder ] 

[ script-example ] 
	$>scale-ui /path/to/script.st  --script-option=1

[ folder-example ]
	$>scale-ui /path/to/my-script/folder 

Installation folders

Scale installs itself in $HOME/.scale/ folder, adding the following files and directories:

$HOME/.scale/
├─── pharo
│    ├──pharo-ui
│    └─ pharo-vm
│       ├── libB3DAcceleratorPlugin.so
│       ├── libFT2Plugin.so
│       ├── libgit2.so.0
│       ├── libInternetConfigPlugin.so
│       ├── libJPEGReaderPlugin.so
│       ├── libJPEGReadWriter2Plugin.so
│       ├── libRePlugin.so
│       ├── libSDL2-2.0.so.0
│       ├── libSDL2-2.0.so.0.2.1
│       ├── libSDL2DisplayPlugin.so
│       ├── libSqueakSSL.so
│       ├── libssh2.so.1
│       ├── libSurfacePlugin.so
│       ├── pharo
│       ├── PharoV50.sources
│       ├── vm-display-null
│       ├── vm-display-X11
│       ├── vm-sound-ALSA
│       └── vm-sound-null
└── scale
    ├── scale
    ├── scale-ui
    ├── Pharo.image
    ├── Pharo.changes
    └── uninstall.st

Uninstall Scale

$HOME/.scale/scale/uninstall.st

Examples

You can find a lot more examples in the examples directory.

Writing a program that interacts with stdin and stdout:

#!/usr/bin/env scale

system stdout << 'I will echo everything you type. Type exit to exit';cr;cr.

got := system stdin upTo: Character lf.
[ got = 'exit' ] whileFalse: [
	system stdout << got; cr.
	got := system stdin upTo: Character lf.
]

Writing a program that calls ls -l

#!/usr/bin/env scale

(system call: 'ls -l') lines do: [ :line |
	system stdout << line.
	system stdout cr.
].

Or doing the same directly in Pharo :D

#!/usr/bin/env scale

system pwd entries do: [ :entry |
	system stdout << entry asString.
	system stdout cr.
].

Asking for an asynchrouns call!

#!/usr/bin/env scale

| futurels |
 futurels := system callAsync: 'sleep 2 && ls -l'.
 futurels onSuccessDo: [ :ls | system stdout << ls ].
 system stdout << 'just after the future call';cr.

Downloading new images, and using options :)

#!/usr/bin/env scale

| version  |
	
  version := (system arguments optionAt: #v ifAbsent: [ 50 ]) asInteger.
  system stdout << 'Downloading ' << version asString << ' into: ' << system pwd fullName; flush.
  system loadPharo: version into: system pwd.

The System variable

The system variable, that is available in any scale script, is an Instance of SCSystemFacade

Here a directory for watching the available methods:

Util-Streams

system stdout " It returns the instance of the stdout stream"
system stderr " It returns the instance of the stderr stream"
system stdin " It returns the instance of the stdin stream"

Util-Bash

system chmod: aPermissionString to: aFileReferenceOrStringPattern "Chmod command for basic usage."
system ln: aTargetReference to: aLinkReference "ln command for symlink usage."
system untargz: aFileReference to: aDestinationReference "Typical command for decompressing
a regular tar+gunzip file"
system untargz: aFileReference  "Typical command for decompressing a regular tar+gunzip
file on a temp directory"
system unzip: aFileReference to: aDestinationReference "Typical command for decompressing a
regular zip file"
system unzip: aFileReference "Typical command for decompressing a regular tar+gunzip file on
a temp directory on a temp directory"
system wget: anUrl to: outFileReference "fetch a file from an url by using wget. and saving
it in a given destination"
system wget: anUrl "fetch a file from an url by using wget. and saving it in a temporal
destination"
system wget: anURL andUntargz: aDestination "fetch a file from an url by using wget.And saving
it in a temporal destination and it tries to decompress it from a tar-gz format"
system wget: anURL andUnzip: aDestination " fetch a file from an url by using wget. And saving
it in a temporal destination and it tries to decompress it from a zip format"

Util-Execute third pharo

system execute: aString into: anImageBundle "Executes a given string content into an given
image."
system execute: aString into: anImageBundle andSaveItAt: aDestination "Executes a given
string content into an given image. then saves this image in the given destination"

Util-Load pharo

system loadPharo: aVersion into: aFileReference " Downloads a pharo image+bundle of the given
version into a given destination. It returns an image bundle object"
system loadBaseline: aPackageName from: aRepository into: anImageBundle andSaveItAt: aDirectory
" It loads the pointed baseline from the pointed repository and saves the image into
the given destination. It returns an image bundle object "
system loadUIBaseline: aPackageName from: aRepository into: anImageBundle andSaveItAt: aDirectory
" It loads the pointed baseline from the pointed repository in GRAPHICAL mode,
then it saves the image into the given destination. It returns an image bundle object "

Util-Call commands

system bash: aString " It executes synchronously a given string in a fresh bash instance "
system call: aString " It executes synchronously a given string in a fresh default-interpreter
instance "
system callAsync: aString " It executes Asynchronously a given string in a fresh
default-interpreter instance "
system scale: aScript " It executes synchronously a given scale script FILE in a fresh
scale instance "

Util-Environment

system environment: aString "It returns the value of the given environment variable name"
system home " It returns the home of the current user"
system workingDirectory " It returns the pharo-working directory (the vm folder)"
system pwd "It returns directory where the user was at the moment of the execution of
the script (the PWD environment variable) "

Util-Finalization

system exit: anErrorCode " It finishes scale given the error code to the operative system. "

Util-Image

system saveAfterRun  " It set the mode of running to save after the execution of the
system script and the end of any parallel process registered for join by this script"
system saveImageAs: aFileReference " It saves the running image into a given destination"

Convenience

system registerProcessToJoin: aFuture "In your script you may want to use the force of
TaskIT that is integrated into this application. This method allows you to register
processes that you need to be finished before the image exits, but after the end
of the script ".
system messageSend: aSelector "It returns a message send with the selector and the system
object as receiver. Useful for building callbacks"
system uimanager "It returns the uimanager"

Doing your scripts

So for writing down your own scripts you can do it by editing a file with your favorite editor or you can use scale-ui.

user$ scale-ui <scripts-folder-path>

Scale-ui will open the image of the scale tool in graphic mode, with a script browser as shown in the following images.

Please add an issue. Image is not loading!

This browser allows you to edit your scripts while browsing the system façade code, for knowing what's there ready to use.

This browser as well allows you to create a new script,

Please add an issue. Image is not loading! Please add an issue. Image is not loading!

delete an existing script and run or debug scripts on your folder. Please add an issue. Image is not loading!.

During this session you may close the browser or want to open many others for different browsers (Future implementations will be happier in this aspect)

For accessing this browser from the world menu, go WorldMenu> Tools> Scale> Script Browser

Please add an issue. Image is not loading!

Loading

Wanting to code? Loading this project in a development image is really easy. Just execute the build script, it will give you as output an image in the directory called 'cache'. If you just want to install scale in an existing image, you just need to execute in this image the content of the building script installScale.st, located into the build folder.

Metacello new
  baseline: 'Scale';
  repository: 'github://guillep/Scale';
  load.

Or you may want to peek an eye to Iceberg project: https://github.com/npasserini/iceberg. :)

scale's People

Contributors

atykhonov avatar cdlm avatar estebanlm avatar guillep avatar psvensson avatar sbragagnolo avatar stephaneggermont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scale's Issues

ROLL has some conflicts

ROLL was created time ago, some of the proposed changes for roll are in the basic image and they have already changes on top of them.

define a way to add interpreters

Now if I need a new interpreter but the scale basic one, i need to make a new image with the installation of the interpretation.

I should define a way to hook up interpreters from fuel files maybe, and define dynamically what's possible.

Scale browser; Truncate files

When the script is saved again into the file, the EOF is not marked. So if the new content is smaller than the older one it makes a mess

setupScale.sh has a fixed version

This makes it difficult to make new releases: changing the stable version requires not only tagging but also changing installation scripts... By default we should install master and master should always be stable and work.

Versionate

As soon as we have some tests, versionate the stable version. and a dev branch

Could not resolve baseline of TaskItShell - installation fails

I've tried all the different ways of installing I've found, but all fails the same way;

Downloading the latest 80 Image:
http://files.pharo.org/get-files/80/pharo64.zip
Pharo.image
Downloading the latest pharoVM:
http://files.pharo.org/get-files/80/pharo64-linux-headless-latest.zip
pharo-vm/pharo
Creating starter scripts pharo and pharo-ui
Loading Scale and Dependencies...
MetacelloNotification: Fetched -> BaselineOfScale-cypress.1 --- filetree:///tmp/scale/cache/../src [:] --- filetree:///tmp/scale/cache/../src
MetacelloNotification: Loaded -> BaselineOfScale-cypress.1 --- filetree:///tmp/scale/cache/../src [:] --- filetree:///tmp/scale/cache/../src
MetacelloNotification: Loading baseline of BaselineOfScale...
MetacelloNotification: ...RETRY->BaselineOfTaskItShell
MetacelloNotification: ...RETRY->BaselineOfTaskItShell
MetacelloNotification: ...FAILED->BaselineOfTaskItShell
Could not resolve: BaselineOfTaskItShell [BaselineOfTaskItShell] in /tmp/scale/cache/pharo-local/package-cache [email protected]:sbragagnolo/taskit.git[master]

...

And later there are problems with copying files, but this is most probably the reason for that.

I'm running a Linux Mint 20; 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux.

Any help appreciated

Error: Could not find accessor for variable named "aProcessId"

Error occurs when uninstalling Scale by means of uninstall.st:

$HOME/.scale/scale/uninstall.st

Full error log:

Uninstalling scale
Removing scale folder...
Error: Could not find accessor for variable named "aProcessId"
FFICallout>>loaderForArgNamed:
FFICallout>>loaderForArgNamed:indirectIndex:
FFICallout>>argName:indirectIndex:type:ptrArity:
FFIFunctionParser>>parseArgument
FFIFunctionParser>>parseArguments
FFIFunctionParser>>parseNamedFunction:
FFICalloutMethodBuilder>>parseSignature:
FFICalloutMethodBuilder>>generate
FFICalloutMethodBuilder>>build:
FFICalloutAPI>>function:module:
OSSUnixSystemAccessor(Object)>>ffiCall:
OSSUnixSystemAccessor>>primitiveWaitpid:statusPointer:options:
[ tmp3 := self
        primitiveWaitpid: arg1
        statusPointer: tmp1
        options: WNOHANG.
tmp3 = -1
        ifTrue: [ self strerror: tmp3 message: 'waitpid()' ].
tmp3 = 0
        ifTrue: [ ^ nil ].
tmp3 = arg1
        ifTrue: [ tmp4 := tmp1 signedLongAt: 1.
                ^ tmp4 ] ] in OSSUnixSystemAccessor>>waitpidNoHang: in Block: [ tmp3 := self...
BlockClosure>>ensure:
OSSUnixSystemAccessor>>waitpidNoHang:
OSSUnixSubprocess>>queryExitStatus
[ :arg1 |
| tmp2 |
tmp2 := arg1 queryExitStatus.
tmp2 ifNotNil: [ arg1 processHasExitNotification ] ] in OSSVMProcess>>updateActiveChildrenAndNotifyDead in Block: [ :arg1 | ...
OrderedCollection>>do:
OSSVMProcess>>updateActiveChildrenAndNotifyDead
[ self sigChldSemaphore waitTimeoutMSecs: 1000.
tmp1 wait.
self updateActiveChildrenAndNotifyDead ] in [ [ self sigChldSemaphore waitTimeoutMSecs: 1000.
tmp1 wait.
self updateActiveChildrenAndNotifyDead ] repeat ] in OSSVMProcess>>initializeChildWatcher in Block: [ self sigChldSemaphore waitTimeoutMSecs: 1000....
BlockClosure>>repeat
[ [ self sigChldSemaphore waitTimeoutMSecs: 1000.
tmp1 wait.
self updateActiveChildrenAndNotifyDead ] repeat ] in OSSVMProcess>>initializeChildWatcher in Block: [ [ self sigChldSemaphore waitTimeoutMSecs: 1000....
[ self value.
Processor terminateActive ] in BlockClosure>>newProcess in Block: [ self value....

Issue with !/usr/bin env scale in GUI

I am using scale but the scale-ui is giving me trouble.
pasted image at 2017_02_14 16_41

This is working on the CLI
like ./etchostadditions.st
but in the scale-ui it complains because of the #!/usr/bin/env scale I guess

New script

Create newscripts from the graphical interface.

setupScale.sh fails because it does not find relative paths

Scale is not using the real working directory as a base for the files it looks for. This makes the following code fail:

./build/scale-bootstrap build/uninstall.st

Either scale manages right the directory, or we should change the installation script to do:

${SCRIPT_DIR}/scale-bootstrap ${SCRIPT_DIR}/uninstall.st

scale should install un /usr/local

Hi,

I just read the documentation :)
scale should install in /usr/local otherwise it will be considered dangerous in some systems and even forbidden in some others (like macOS).
I also suggest to install undefr /usr/local/scale (everything there: /bin, etc.) and then just create symlinks in /usr/local/bin.

:)

Cannot install on Ubuntu MATE 64 bits

With ZeroConf, I've that:


  • Copying files!

Deploying scale command
ERROR:Errors in script loaded from /tmp/scale/build/install.st
ERROR:primitive #createDirectory: in UnixStore failed
'Errors in script loaded from /tmp/scale/build/installScale.st'
PrimitiveFailed: primitive #createDirectory: in UnixStore failed

And with the classic installation with ./build/build.sh :

Downloading the latest 50 Image:
http://files.pharo.org/get-files/50/pharo.zip
Pharo.image
Downloading the latest pharoVM:
http://files.pharo.org/get-files/50/pharo-linux-stable.zip
pharo-vm/pharo
Downloading PharoV50.sources:
http://files.pharo.org/get-files/50/sources.zip
Creating starter scripts pharo and pharo-ui
Loading Scale and Dependencies...

Fetched -> BaselineOfScale-SantiagoBragagnolo.5 --- filetree:///home/dkm/Scale/src [:] --- filetree:///home/dkm/Scale/src
Loaded -> BaselineOfScale-SantiagoBragagnolo.5 --- filetree:///home/dkm/Scale/src [:] --- filetree:///home/dkm/Scale/src
Loading baseline of BaselineOfScale...
...RETRY->BaselineOfTaskItShell
...RETRY->BaselineOfTaskItShell'Errors in script loaded from /home/dkm/Scale/build/installScale.st'
An attempt to use interactive tools detected, while in non-interactive mode
FileDoesNotExistException: '/home/Scale/cache/github--sbragagnolotaskitv021476266682395258391045864651802.zip'

Scale points to wrong TaskIt version

Scales wrongly points to taskit dev-0.2.1. That version did exist but there was no BaselineOfTaskItShell in there. The baseline exists in dev-0.3.

Reference to missing variable breaks installation script of Scale

Hi Guile! Welcome back from vacations. I had actually found another problem, which I hope you can shed some light on. I am running the installation script the way the README tells me, I get the following output;

NewUndeclaredWarning: SCScaleCodeManager>>content (content is Undeclared)
NewUndeclaredWarning: SCSystemCall>>taskClass (TKTOSVerboseTask is Undeclared)
NewUndeclaredWarning: SCSystemCall>>taskClass (TKTOSTask is Undeclared)
MetacelloNotification: Loaded -> Scale-cypress.1 --- filetree:///tmp/scale/cache/../src [:] --- cache
MetacelloNotification: ...finished baseline


  • checking if there is any old installation

/usr/bin/env: ‘scale’: No such file or directory


  • Copying files!

/usr/bin/env: ‘scale’: No such file or directory


  • Cleaning the mess :)

And when I open Scale in a Pharo 8 image, I see that the ScaleCodeManager#content method refer to a variable that is not declared;

image

Maybe this is not a problem, but I am trying to understand why the install fails.

I am running this on a Linux mint 20; 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

scale-bootstrap illustrates the problem with workingDirectory…

As per the README file, the scale-bootstrap wrapper script is invoked from the project root, like so:

sudo ./build/scale-bootstrap ./build/install.st

That wrapper then runs the the install script like so:

./cache/pharo cache/Pharo.image scale "../$@"

From the point of view of build/scale-bootstrap, $PWD is the project root, and since it passes .././build/install.st to scale, that should resolve to a build directory one level up, besides the project directory. If the code in the image relies on FileLocator imageDirectory, then OK, but I'd change that to FileLocator workingDirectory, which should be equal to $PWD.

More a FileSystem than a Scale bug, but a nice illustration of it.

[idea] Scale local directory in your home

Scale could set at its very start .scale directory in home as the pharo-local.
Then, all caches such playground caches, package caches, are created in there, are really cached and reused.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.