-
Notifications
You must be signed in to change notification settings - Fork 19
/
jskit.py
executable file
·30 lines (21 loc) · 759 Bytes
/
jskit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
import zipfile
import json
import sys
import javascript.runtime
from runner.terminal import TerminalRunner
def run_script(qemu, src):
js = javascript.runtime.JSRuntime(qemu, {'appKeys': {}, 'capabilities': ['location'], 'uuid': '00000000-0000-0000-0000-000000000001'})
js.run(src)
def run_pbw(qemu, pbw_path):
with zipfile.ZipFile(pbw_path) as z:
appinfo = z.open('appinfo.json').read()
src = z.open('pebble-js-app.js').read().decode('utf-8')
manifest = json.loads(appinfo)
js = javascript.runtime.JSRuntime(qemu, manifest)
js.run(src)
if __name__ == "__main__":
runner = TerminalRunner(sys.argv[1], sys.argv[2:], "data")
runner.run()