Skip to content

Commit 8a54327

Browse files
better startup sequence
1 parent e5a59dc commit 8a54327

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

webapp_start.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,41 @@ async def delay(time):
1313
files = ['bigrat', 'extensions', 'turtleduck', 'sundry/cards', 'sundry/demo', 'sundry/fsm', 'sundry/heapsort']
1414

1515
for file in files:
16+
print(f'Downloading {file}.qky... ', end='')
1617
# N. B. top-level await is only allowed in Pyodide
1718
resp = await pyfetch(f'@@ORIGIN@@/{file}.qky')
18-
print(f'Downloading {file}.qky')
1919
text = await resp.string()
2020
with open(f'{file}.qky', 'w') as f: f.write(text)
21+
delay(10)
22+
print('done')
2123

22-
print('Downloading quackery_OOP_ASYNC.py')
24+
print('Downloading quackery_OOP.py... ', end='')
2325
resp = await pyfetch('@@ORIGIN@@/quackery_OOP.py')
2426
quackerytext = await resp.string()
2527
with open('quackery.py', 'w') as f: f.write(quackerytext)
26-
27-
js.term.clear()
28+
print('done')
2829

2930
async def ainput(prompt):
3031
term = js.term
3132
term.resume()
3233
print('\u200c', end='') # ‌
33-
result = await term.read(prompt)
34+
promise = term.read(prompt)
35+
term.history().enable()
36+
result = await promise
3437
term.pause()
3538
return result
3639

37-
from quackery import quackery, QuackeryContext
40+
print('Compiling builtins... ', end='')
41+
from quackery import *
3842
qc = QuackeryContext()
43+
print('done')
44+
45+
quackery(r'''$ 'extensions.qky' dup name? not dip sharefile and iff [ say 'Compiling extensions... ' cr quackery say 'done' cr ] else drop''', qc)
46+
47+
print('Starting...')
48+
delay(1000)
49+
js.term.clear()
50+
3951
print(r'''
4052
___ _ ___ _ _
4153
/ _ \ _ _ __ _ ___| | _____ _ __ _ _ / _ \ _ __ | (_)_ __ ___
@@ -46,8 +58,6 @@ async def ainput(prompt):
4658
Welcome to Quackery running on the Pyodide virtual machine.
4759
Don't type 'leave' or you'll break something.''')
4860

49-
quackery(r'''$ 'extensions.qky' dup name? not dip sharefile and iff [ cr say 'Building extensions...' cr quackery ] else drop''', qc)
50-
5161
async def shell_loop():
5262
while True:
5363
prompt = '/O> '

0 commit comments

Comments
 (0)