Commit 6de43c9e authored by Roman Yurchak's avatar Roman Yurchak

Update Module.locateFile inside _loadPackage

parent 73e3898b
...@@ -38,7 +38,6 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -38,7 +38,6 @@ var languagePluginLoader = new Promise((resolve, reject) => {
let loadedPackages = window.pyodide.loadedPackages; let loadedPackages = window.pyodide.loadedPackages;
let queue = [].concat(names || []); let queue = [].concat(names || []);
let toLoad = new Array(); let toLoad = new Array();
window.pyodide._toLoadPackages = toLoad;
while (queue.length) { while (queue.length) {
let package_uri = queue.pop(); let package_uri = queue.pop();
...@@ -81,6 +80,20 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -81,6 +80,20 @@ var languagePluginLoader = new Promise((resolve, reject) => {
} }
} }
console.log(`Trying to load ${Object.keys(toLoad)}`);
window.pyodide._module.locateFile = (path) => {
// handle packages loaded from custom URLs
let package = path.replace(/\.data$/, "");
if (package in toLoad) {
let package_uri = toLoad[package];
if (package_uri != 'default channel') {
return package_uri.replace(/\.js$/, ".data");
};
};
return baseURL + path;
};
let promise = new Promise((resolve, reject) => { let promise = new Promise((resolve, reject) => {
if (Object.keys(toLoad).length === 0) { if (Object.keys(toLoad).length === 0) {
resolve('No new packages to load'); resolve('No new packages to load');
...@@ -162,6 +175,7 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -162,6 +175,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
// Rearrange namespace for public API // Rearrange namespace for public API
let PUBLIC_API = [ let PUBLIC_API = [
'loadPackage', 'loadPackage',
'loadedPackages',
'pyimport', 'pyimport',
'repr', 'repr',
'runPython', 'runPython',
...@@ -197,20 +211,7 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -197,20 +211,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
return {}; return {};
}; };
Module.locateFile = (path) => { Module.locateFile = (path) => baseURL + path;
if ((window.hasOwnProperty('pyodide')) &&
(window.pyodide.hasOwnProperty('_toLoadPackages'))) {
// handle packages loaded from custom URLs
let package = path.replace(/\.data$/, "");
if (package in window.pyodide._toLoadPackages) {
let package_uri = window.pyodide._toLoadPackages[package];
if (package_uri != 'default channel') {
return package_uri.replace(/\.js$/, ".data");
};
};
};
return baseURL + path;
};
var postRunPromise = new Promise((resolve, reject) => { var postRunPromise = new Promise((resolve, reject) => {
Module.postRun = () => { Module.postRun = () => {
delete window.Module; delete window.Module;
......
...@@ -112,7 +112,7 @@ class SeleniumWrapper: ...@@ -112,7 +112,7 @@ class SeleniumWrapper:
except TimeoutException as exc: except TimeoutException as exc:
_display_driver_logs(self.browser, self.driver) _display_driver_logs(self.browser, self.driver)
print(self.logs) print(self.logs)
raise TimeoutException() raise TimeoutException('wait_until_packages_loaded timed out')
@property @property
def urls(self): def urls(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment