Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _run(self, cmd, **kwargs):
"""Run the command using our logger and abort callback.
Returns the exit code.
"""
if self.kill_event.is_set():
raise ValueError('Command was killed')
kwargs['logger'] = self.logger
kwargs['kill_event'] = self.kill_event
proc = Process(cmd, **kwargs)
return proc.wait()
def ensure_dev(logger=None):
"""Ensure that the dev assets are available.
"""
parent = pjoin(HERE, '..')
if not osp.exists(pjoin(parent, 'node_modules')):
yarn_proc = Process(['node', YARN_PATH], cwd=parent, logger=logger)
yarn_proc.wait()
if not osp.exists(pjoin(parent, 'dev_mode', 'build')):
yarn_proc = Process(['node', YARN_PATH, 'build'], cwd=parent,
logger=logger)
yarn_proc.wait()
def terminate(self):
"""Terminate the process and return the exit code.
"""
proc = self.proc
# Kill the process.
if proc.poll() is None:
os.kill(proc.pid, signal.SIGTERM)
# Wait for the process to close.
try:
proc.wait()
finally:
Process._procs.remove(self)
return proc.returncode
def watch_dev(logger=None):
"""Run watch mode in a given directory.
Parameters
----------
logger: :class:`~logger.Logger`, optional
The logger instance.
Returns
-------
A list of `WatchHelper` objects.
"""
parent = pjoin(HERE, '..')
if not osp.exists(pjoin(parent, 'node_modules')):
yarn_proc = Process(['node', YARN_PATH], cwd=parent, logger=logger)
yarn_proc.wait()
logger = logger or logging.getLogger('jupyterlab')
ts_dir = osp.realpath(osp.join(HERE, '..', 'packages', 'metapackage'))
# Run typescript watch and wait for compilation.
ts_regex = r'.* Compilation complete\. Watching for file changes\.'
ts_proc = WatchHelper(['node', YARN_PATH, 'run', 'watch'],
cwd=ts_dir, logger=logger, startup_regex=ts_regex)
# Run the metapackage file watcher.
tsf_regex = 'Watching the metapackage files...'
tsf_proc = WatchHelper(['node', YARN_PATH, 'run', 'watch:files'],
cwd=ts_dir, logger=logger, startup_regex=tsf_regex)
# Run webpack watch and wait for compilation.
def _load_outdated(self):
"""Get the latest compatible version"""
info = get_app_info(app_dir=self.app_dir, logger=self.log)
names = tuple(info['extensions'].keys())
data = yield self.executor.submit(
get_latest_compatible_package_versions,
names,
app_dir=self.app_dir,
logger=self.log,
)
raise gen.Return(data)
import sys
from jupyterlab.commands import get_app_info
from notebook.nbextensions import validate_nbextension
from notebook.serverextensions import validate_serverextension
if validate_nbextension('pywwt/extension') != []:
print("Issue detected with nbextension")
sys.exit(1)
print("nbextension OK")
info = get_app_info()
if 'pywwt' not in info['extensions'] or 'pywwt' in info['disabled']:
print("Issue detected with labextension")
sys.exit(1)
print("labextension OK")
if validate_serverextension('pywwt') != []:
print("Issue detected with serverextension")
sys.exit(1)
print("serverextension OK")
import logging
import sys
from jupyterlab.commands import get_app_info
from notebook.nbextensions import validate_nbextension
from notebook.serverextensions import validate_serverextension
# If there's a problem and we don't provide this, the validate function crashes :-(
logger = logging.getLogger('')
if validate_nbextension('pywwt/extension', logger=logger) != []:
print("Issue detected with nbextension")
sys.exit(1)
info = get_app_info()
if 'pywwt' not in info['extensions'] or 'pywwt' in info['disabled']:
print("Issue detected with labextension")
sys.exit(1)
if validate_serverextension('pywwt', logger=logger) != []:
print("Issue detected with serverextension")
sys.exit(1)
----------
logger: :class:`~logger.Logger`, optional
The logger instance.
Returns
-------
A list of `WatchHelper` objects.
"""
parent = pjoin(HERE, '..')
if not osp.exists(pjoin(parent, 'node_modules')):
yarn_proc = Process(['node', YARN_PATH], cwd=parent, logger=logger)
yarn_proc.wait()
logger = _ensure_logger(logger)
ts_dir = osp.realpath(osp.join(HERE, '..', 'packages', 'metapackage'))
# Run typescript watch and wait for the string indicating it is done.
ts_regex = r'.* Found 0 errors\. Watching for file changes\.'
ts_proc = WatchHelper(['node', YARN_PATH, 'run', 'watch'],
cwd=ts_dir, logger=logger, startup_regex=ts_regex)
return [ts_proc]
def watch_packages(logger=None):
"""Run watch mode for the source packages.
Parameters
----------
logger: :class:`~logger.Logger`, optional
The logger instance.
Returns
-------
A list of `WatchHelper` objects.
"""
parent = pjoin(HERE, '..')
if not osp.exists(pjoin(parent, 'node_modules')):
yarn_proc = Process(['node', YARN_PATH], cwd=parent, logger=logger)
yarn_proc.wait()
logger = _ensure_logger(logger)
ts_dir = osp.realpath(osp.join(HERE, '..', 'packages', 'metapackage'))
# Run typescript watch and wait for the string indicating it is done.
ts_regex = r'.* Found 0 errors\. Watching for file changes\.'
ts_proc = WatchHelper(['node', YARN_PATH, 'run', 'watch'],
cwd=ts_dir, logger=logger, startup_regex=ts_regex)
return [ts_proc]
description = "Enable labextension(s) by name"
def run_task(self):
[enable_extension(arg, self.app_dir, logger=self.log)
for arg in self.extra_args]
class DisableLabExtensionsApp(BaseExtensionApp):
description = "Disable labextension(s) by name"
def run_task(self):
[disable_extension(arg, self.app_dir, logger=self.log)
for arg in self.extra_args]
class CheckLabExtensionsApp(BaseExtensionApp):
description = "Check labextension(s) by name"
flags = check_flags
should_check_installed_only = Bool(False, config=True,
help="Whether it should check only if the extensions is installed")
def run_task(self):
all_enabled = all(
check_extension(
arg, self.app_dir,
self.should_check_installed_only,
logger=self.log)
for arg in self.extra_args)
if not all_enabled:
exit(1)