comparison libervia/server/tasks/implicit/task_brython.py @ 1279:2d1ceb026d0e

tasks (brython): copy and load `brython_stdlib.js`
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 16:47:50 +0200
parents e628724530ec
children 0e4e413eb8db
comparison
equal deleted inserted replaced
1278:4385a75e3962 1279:2d1ceb026d0e
51 version='.'.join(str(v) for v in ver))) 51 version='.'.join(str(v) for v in ver)))
52 data_path = Path(brython.__file__).parent / 'data' 52 data_path = Path(brython.__file__).parent / 'data'
53 # shutil has blocking method, but the task is run before we start 53 # shutil has blocking method, but the task is run before we start
54 # the web server, so it's not a big deal 54 # the web server, so it's not a big deal
55 shutil.copyfile(data_path / "brython.js", brython_js) 55 shutil.copyfile(data_path / "brython.js", brython_js)
56 shutil.copy(data_path / "brython_stdlib.js", self.build_path)
56 else: 57 else:
57 log.debug("Brython is already installed") 58 log.debug("Brython is already installed")
58 59
59 self.WATCH_DIRS = [] 60 self.WATCH_DIRS = []
60 61
61 for dyn_data in self.resource.browser_modules["brython"]: 62 for dyn_data in self.resource.browser_modules["brython"]:
62 url_hash = dyn_data['url_hash'] 63 url_hash = dyn_data['url_hash']
63 import_url = f"/{C.BUILD_DIR}/{C.BUILD_DIR_DYN}/{url_hash}" 64 import_url = f"/{C.BUILD_DIR}/{C.BUILD_DIR_DYN}/{url_hash}"
64 dyn_data.setdefault('scripts', set()).update({ 65 dyn_data.setdefault('scripts', set()).update({
65 Script(src=f"/{C.BUILD_DIR}/brython.js"), 66 Script(src=f"/{C.BUILD_DIR}/brython.js"),
67 Script(src=f"/{C.BUILD_DIR}/brython_stdlib.js"),
66 }) 68 })
67 dyn_data.setdefault('template', {})['body_onload'] = self.getBodyOnload( 69 dyn_data.setdefault('template', {})['body_onload'] = self.getBodyOnload(
68 extra_path=[import_url]) 70 extra_path=[import_url])
69 self.WATCH_DIRS.append(dyn_data['path'].resolve()) 71 self.WATCH_DIRS.append(dyn_data['path'].resolve())
70 72