summaryrefslogtreecommitdiff
path: root/tools/wasptool
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-17 16:18:27 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-04-17 16:18:27 (GMT)
commit1fe06029957c23eebd2bd6cbf705d33a8044cd4d (patch)
treef2fc2e7248ae4e4baf47b2a4df01fcefb9524c0a /tools/wasptool
parentfe43091bcfd2756fe9cab0dc47b7e4da73d8166c (diff)
tools: wasptool: Introduce simple chunking
This reduces the memory overhead required to --exec a file (although we will still have problems with big classes). For now we have avoided matching "^def" since we need additional handling for decorators!
Diffstat (limited to 'tools/wasptool')
-rwxr-xr-xtools/wasptool23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/wasptool b/tools/wasptool
index 34fc97d..d611735 100755
--- a/tools/wasptool
+++ b/tools/wasptool
@@ -46,7 +46,7 @@ def unsync(c):
c.expect('Watch is running, use Ctrl-C to stop')
c.send('\x18')
-def paste(c, f, verbose=False):
+def paste(c, f, verbose=False, chunk=None):
docstring = False
tosend = []
@@ -66,11 +66,17 @@ def paste(c, f, verbose=False):
if ln.lstrip().startswith('#'):
continue
+ if ln.strip() == '':
+ continue
+
tosend.append(ln)
for ln in pbar(tosend, verbose):
- c.sendline(ln)
- c.expect('=== ')
+ if chunk and ln.startswith('class'):
+ chunk()
+
+ c.sendline(ln)
+ c.expect('=== ')
def handle_eval(c, cmd):
verbose = bool(c.logfile)
@@ -89,6 +95,15 @@ def handle_eval(c, cmd):
def handle_exec(c, fname):
verbose = bool(c.logfile)
+ def chunk():
+ c.logfile = sys.stdout
+ c.send('\x04')
+ c.expect('>>> ')
+ if not verbose:
+ c.logfile = None
+ c.send('\x05')
+ c.expect('=== ')
+
with open(fname) as f:
if not verbose:
print(f'Preparing to run {fname}:')
@@ -96,7 +111,7 @@ def handle_exec(c, fname):
c.send('\x05')
c.expect('=== ')
- paste(c, f, verbose)
+ paste(c, f, verbose, chunk)
c.logfile = sys.stdout
c.send('\x04')