Skip to content

Commit

Permalink
fix: block dialog while installing from requirements #2193
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Jan 4, 2024
1 parent b1b852a commit d3ef4d6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions studio/studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ async def show_finish_message(q: Q, type: Literal['error', 'success'], title: st
await q.page.save()


async def block_dialog(q: Q):
q.page['meta'].dialog.closable = False
q.page['meta'].dialog.blocking = True
await q.page.save()


async def on_pip_finish(q: Q):
q.page['meta'].dialog.blocking = False
q.page['meta'].dialog.closable = True
Expand All @@ -324,6 +330,7 @@ async def pip(q: Q, command: str, flag: str or None, package_name: str, package_
args = [sys.executable, '-m', 'pip', command, flag, f'{package_name}{version}']
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = ''
await block_dialog(q)
await show_progress(q, progress_message)
while True:
if p.poll() is not None:
Expand Down Expand Up @@ -514,8 +521,6 @@ async def serve(q: Q):
if not q.args.package_name:
q.page['meta'].dialog.items[2].inline.items[0].textbox.error = 'Package name cannot be empty.'
else:
q.page['meta'].dialog.closable = False
q.page['meta'].dialog.blocking = True
package = f'{q.args.package_name}{q.args.package_version}'
q.client.task = asyncio.create_task(pip(
q,
Expand All @@ -529,8 +534,6 @@ async def serve(q: Q):
on_install_success
))
elif q.args.remove_package:
q.page['meta'].dialog.closable = False
q.page['meta'].dialog.blocking = True
package = f'{q.args.package_name}{q.args.package_version}'
q.client.task = asyncio.create_task(pip(
q,
Expand Down

0 comments on commit d3ef4d6

Please sign in to comment.