Skip to content

Commit

Permalink
Replace ipython_genutils.py3compat. getcwd with os.cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Mar 18, 2022
1 parent 749ac53 commit 09ca302
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions voila/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@

from jupyter_core.paths import jupyter_config_path, jupyter_path

from ipython_genutils.py3compat import getcwd

from .paths import ROOT, STATIC_ROOT, collect_template_paths, collect_static_paths
from .handler import VoilaHandler
from .treehandler import VoilaTreeHandler
Expand Down Expand Up @@ -322,7 +320,7 @@ def _default_root_dir(self):
if self.notebook_path:
return os.path.dirname(os.path.abspath(self.notebook_path))
else:
return getcwd()
return os.getcwd()

def _init_asyncio_patch(self):
"""set default asyncio policy to be compatible with tornado
Expand Down
12 changes: 12 additions & 0 deletions voila/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ def inner():
for k, v in json.loads(request_info).items():
os.environ[k] = v

def get_query_string(url: str = None) -> str:
"""Helper function to pause the execution of notebook and wait for
the query string.
Args:
url (str, optional): Address to get user query string, if it is not
provided, `voila` will figure out from the environment variables.
Defaults to None.
Returns: The query string provided by `QueryStringSocketHandler`.
"""

wait_for_request(url)
return os.getenv(ENV_VARIABLE.QUERY_STRING)

def make_url(template_name, base_url, path):
# similar to static_url, but does not assume the static prefix
Expand Down

0 comments on commit 09ca302

Please sign in to comment.