Skip to content

Commit dc35a68

Browse files
committed
How to deploy with gcloud instead of the graphical GAE Launcher
1 parent 9f35550 commit dc35a68

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

dispatch.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dispatch:
2+
- url: "glowscript.org/"
3+
service: default

docs/GlowScriptDocs/local.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@ <h1 class="Heading-1"> <font color="#0000A0">Running locally</font></h1>
5151
2)
5252
click the Download button for &quot;Install and initialize Google Cloud SDK&quot;.<br>
5353
3)
54-
In a command-line terminal, execute the gcloud statement.<br>
54+
In a command-line terminal, execute the statement &quot;gcloud init&quot;.<br>
5555
4) If you intend to use GitHub, click &quot;Download and Install Git&quot;.<br>
5656
<br>
5757
If you had already installed the Google Cloud SDK, follow the instructions on the page for updating it. </p>
5858
<p class="Normal"><strong>* Using gcloud with Google App Engine</strong><br>
5959
At
6060
<a href="https://cloud.google.com/appengine/docs/python/" target="_blank"><strong>cloud.google.com/appengine/docs/python</strong></a> choose the Standard environment Python 2 Docs. Presumably you have already installed the Cloud SDK; follow the rest of the instructions, except that you need not install Git if you don't intend to use GitHub. You do need to execute &quot;gcloud components install app-engine-python&quot; to add Google App Engine support to the Cloud SDK.<br>
6161
<br>
62-
To run GlowScript, execute dev_appserver.py /..../glowscript/app.yaml, where the location of the GlowScript code is at /..../glowscript (on Windows, use backslashes instead of slashes). This starts up the Google App Engine machinery. Open a browser tab and enter &quot;localhost:8080&quot; to run.</p>
62+
To run GlowScript, execute dev_appserver.py /..../glowscript/app.yaml, where the location of the GlowScript code is at /..../glowscript (on Windows, use backslashes instead of slashes). This starts up the Google App Engine machinery. Open a browser tab and enter &quot;localhost:8080&quot; to run.<br>
63+
<br>
64+
More precisely, 8080 is the default port number. At the start of ide/api.py, if the variable &quot;localport&quot; is XXXX instead of 8080, to start up the application you must execute dev_appserver.py --port=XXXX /..../glowscript/app.yaml and the browser must point to &quot;localhost:XXXX&quot;.</p>
6365
<p class="Normal"><strong>* Testing your changes</strong><br />
64-
Suppose the current version of GlowScript is 2.7. Change the version number in a program to 2.8dev; that is, 0.1 greater than the current 2.7, plus dev. When you run the program, it will use your latest JavaScript changes. If you make further changes to the JavaScript code, just reload the program edit page to get the latest changes. <br />
66+
Suppose the current version of GlowScript is 2.7. Change the version number in a program to 2.8dev; that is, 0.1 greater than the current 2.7, plus dev. When you run the program, it will use your latest JavaScript changes. If you make further changes to the JavaScript code, just re-execute a test program to get the latest changes. You don't have to restart the application.<br />
6567
<br />
6668
If you want to remake/update the existing version 2.7, or create a new version 2.8, see MakingNewVersion.txt in the docs folder of the GlowScript GitHub repository. Note that use of the build program requires that there be an appropriate version of node in the build-tools folder.<br />
6769
<br />

docs/GlowScriptOverview.txt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ the application in app.yaml, and at the start of ide/ide.js, ide/api.py, and unt
1313
COMPILATION
1414

1515
The main compilation program is lib/compiling/GScompiler.js. Additional comments
16-
on GScompiler.js are included in the file itself.
16+
on GScompiler.js are included in the file itself. Also, at the start of the file
17+
are instructions on how to obtain others' libraries, such as RapydScript-NG.
1718

1819
Triggered by a "Run" event in ide/index.html, the sandboxed untrusted/run.js calls
1920
the appropriate compiler and run-time package corresponding to the version number
@@ -27,6 +28,8 @@ Replace delete with remove, as delete is a JavaScript reserved word.
2728
Parse import statements, including making list of objects imported.
2829
Except for vpython, the Python random library is currently the only Python library
2930
that can be imported thanks to a JavaScript implementation by RapydScript-NG.
31+
The random library is not complete but contains seed_state, get_random_byte, seed,
32+
random, randrange, randint, uniform, choice, shuffle, and sample.
3033
Look for function declarations and function calls that are outside strings.
3134
If inside a string, change the name to name+'~!#' so that this mention will
3235
not be found in a later search for "name(".
@@ -43,7 +46,7 @@ Insert preamble to transpiled JavaScript code.
4346
Insert statements to deal with various kinds of import statements.
4447
Insert statements such as "box = vp_box" so that box invokes the VPython version of a box.
4548
Add some Array.prototype functionality to mimic Python lists.
46-
papercompile(program) calls a library that converts A+B to A['+'](B), which makes possible
49+
papercompile() calls a library that converts A+B to A['+'](B), which makes possible
4750
"operator overloading": that is, 2+3 evaluates to 5, but vec(1,2,3)+vec(10,20,30)
4851
evaluates to vec(11,22,33). In lib/glow/vectors.js is a set of Number and vec
4952
prototype methods that alter the behavior of the arithmetic operators.
@@ -58,7 +61,7 @@ which includes references to run-time libraries stored at Amazon S3, which is an
5861
which makes the libraries accessible to https sites containing embedded GlowScript programs.
5962
(Originally, glowscript.org was an http site, which an https site could not access.)
6063
Note the sizable amount of code that comes from RapydScript-NG, as well as the preamble
61-
geneated by GScompiler.js. It is interesting to see the changes that result in this case:
64+
generated by GScompiler.js. It is interesting to see the changes that result in this case:
6265
GlowScript X.Y VPython
6366
from vpython import box
6467
box()
@@ -67,6 +70,11 @@ Also observe what is generated in these cases:
6770
import vpython # or import vpython as vp
6871
vpython.box() # or vp.box()
6972

73+
If using (say) version 2.7, you can see the generated JavaScript program by choosing
74+
"Share or export this program" from the edit page. However, if using an experimental
75+
version such as 2.8dev, to see the code you need to uncomment console.log(program)
76+
at the end of GScompiler.js, and when running use shift-ctrl-j to see console output.
77+
7078
---------------------------------------------
7179
EXECUTION
7280

@@ -172,7 +180,7 @@ an attribute vector is changed, the parent object is marked as changed, which wi
172180
trigger at render time calling the object's __update() function. Axis, size, and up
173181
attribute vectors deal with connections among these attributes, due to the VPython
174182
definition that axis and size affect each other, and under rotation axis and up
175-
must be force always to be perpendicular to each other. There is also special
183+
must be forced always to be perpendicular to each other. There is also special
176184
treatment of individual vector components, to make sure that changing only one
177185
component of a vector is noticed as a change.
178186

@@ -189,9 +197,9 @@ situations. They are of two kinds. The "vertex" shaders have the task of mapping
189197
in 3D to a point projected onto the 2D screen. A hidden component of the GPU, the "rasterizer",
190198
determines the location of all pixels that are inside a triangle defined by three vertex
191199
locations projected onto the 2D screen. The "fragment" shaders set the color of each pixel, based
192-
on the color of the object and the locations and colors of lights. The key to GPU rendering speed is
193-
that the a large number of vertex shaders can work in parallel, and a large number of
194-
fragment shaders can work in parallel. Also, the non-display of hidden objects is possible
200+
on the color of the object and the locations and colors of lights. The key to GPU rendering speed
201+
is that the a large number of vertex shaders can work in parallel, and a large number of
202+
fragment shaders can work in parallel. Also, the non-display of hidden objects is assured
195203
because when the fragment shader stores a color into a pixel location, the "z-depth" of the
196204
pixel is also stored in the memory. When another fragment shader attempts to store a
197205
color into that same pixel location, the hardware ignores the attempt if the associated
@@ -238,12 +246,12 @@ existing user data.
238246
---------------------------------------------
239247
TESTING CHANGES
240248

241-
Currently (August 2019), it is possible to run a test program locally by starting up the
242-
Google App Engine launcher, and here are the details:
243-
https://www.glowscript.org/docs/GlowScriptDocs/local.html
249+
Until July 30, 2020, it is possible to run a test program locally by using the
250+
graphical-interface Google App Engine launcher, but after that date it will be
251+
necessary to launch from a terminal (command-line interface or "CLI"). The
252+
following link describes both schemes:
244253

245-
However, this launcher is being phased out, and in the future it will be necessary to
246-
launch from a terminal (command prompt).
254+
https://www.glowscript.org/docs/GlowScriptDocs/local.html
247255

248256
To test a new version of GlowScript, change a program header from X.Y to X.Ydev and
249257
run the program, which will use the latest, modified code. Make another change in the code
@@ -303,7 +311,7 @@ of glowscript.org.
303311
There is one more web entity. In Amazon S3 is a glowscript bucket that contains
304312
the libraries, fonts, and textures used by exported GlowScript programs. They are
305313
stored there in part because it wasn't clear how to deal with CORS-enabling these
306-
files within the http://glowscript.org web site, whereas at Amazon S3 it's a
314+
files within the original http://glowscript.org web site, whereas at Amazon S3 it's a
307315
one-click action (click a file listing in glowscript/package, then click "Make Public").
308316
Also, https://s3.amazonaws.com/glowscript is an https site, whereas glowscript.org
309317
was until Feb. 2019 an http site, so references to S3 from a program exported to an

docs/MakingNewVersion.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ This has not actually been done so far.
8787
(This includes vectors_no_overload.js instead of vectors.js.)
8888
*********************************************************************************************
8989

90-
Deploy in GAE launcher; note that at this point property.js should have version 0.5dev.
90+
Note that at this point property.js should have version 0.5dev.
91+
92+
If using the graphical Google App Engine launcher, click "Deploy" to upload the new version.
93+
94+
After July 30, 2020, the graphical Google App Engine launcher will not work, and one must
95+
use the gcloud machinery in a terminal. See www.glowscript.org/docs/GlowScriptDocs/local.html
96+
for instructions on installing gcloud. To deploy the new version, in a terminal cd to the
97+
glowscript project and execute "gcloud app deploy". (If this is the first time that you are
98+
deploying to a test site, execute "gcloud app deploy app.yaml dispatch.yaml".)
9199

92100
Test that version 0.3 programs still work, that version 0.4 programs work,
93101
that 0.4dev programs give an error, that 0.4 is the default version for a new program,

lib/glow/canvas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313

314314
capture: async function(filename) { // send image of canvas to Download directory
315315
if (filename.constructor !== String) throw new Error('A capture file name must be a string.')
316-
if (filename.indexOf('.png') < 0) filename += '.png'
316+
if (filename.slice(-4) != '.png') filename += '.png'
317317
var img = await this.__renderer.screenshot()
318318
var a = document.createElement("a")
319319
a.href = img.src

0 commit comments

Comments
 (0)