Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Progress bar works on Windows #4182

Closed
davelab6 opened this issue Jun 14, 2023 · 10 comments
Closed

Ensure Progress bar works on Windows #4182

davelab6 opened this issue Jun 14, 2023 · 10 comments
Assignees
Labels
Tool improvement Desirable but not crucial for the tool

Comments

@davelab6
Copy link
Contributor

In https://typedrawers.com/discussion/comment/62849/#Comment_62849 a user writes,

there’s no way to make the progress bar work [on windows]. So I always have to use -s to deactivate it.

I'm sure that is annoying :)

@davelab6 davelab6 added the Tool improvement Desirable but not crucial for the tool label Jun 14, 2023
@ftCLI
Copy link

ftCLI commented Jun 14, 2023

I wrote the comment on typedrawers. Sorry, I misspelled: I have to use -n and not -s.

Here's the full error:

Traceback (most recent call last):
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\Scripts\fontbakery.exe\__main__.py", line 7, in <module>
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\cli.py", line 55, in main
    run_profile_check(subcommand_module[6:])
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\cli.py", line 28, in run_profile_check
    sys.exit(check_profile_main(module.profile))
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\commands\check_profile.py", line 355, in main
    distribute_generator(status_generator, [reporter.receive for reporter in reporters])
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\checkrunner.py", line 595, in distribute_generator
    target(item)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\__init__.py", line 132, in receive
    self._output(event)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 189, in _output
    text = self._render_event(event)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 601, in _render_event
    self._render_event_async(print, event)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 593, in _render_event_async
    self._render_event_sync(print, event)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 400, in _render_event_sync
    self.stdout.write(text)
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 125, in write
    self.flush()
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 131, in flush
    progressbar, reset_progressbar = self._draw_progressbar()
  File "C:\Users\Cesare\AppData\Local\Programs\Python\Python310\lib\site-packages\fontbakery\reporters\terminal.py", line 305, in draw_progressbar
    columns = int(columns_entry[0].split()[1])
IndexError: list index out of range

@davelab6
Copy link
Contributor Author

@ftCLI thanks for the traceback!! That's very helpful

@ftCLI
Copy link

ftCLI commented Jun 15, 2023

If can be of any help, using shutil.get_terminal_size() to get the number of columns prevents the script from crashing

def draw_progressbar(self):
    from shutil import get_terminal_size
    columns = get_terminal_size()[0]

    ...

But the output is this
image

Maybe click.progressbar could help? https://github.com/pallets/click/blob/d0af32d8e7d78f4fdaf9c3d1559e1ffaac1b2569/src/click/termui.py#L285

@graphicore
Copy link
Collaborator

Hi @ftCLI I just answered in #4189 (comment) and it seems like your latest screenshot is related.

Could you try to turn off colors with -C? And if you are brave, try to get ANSI escape codes working in PowerShell using this documentation: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.3

@ftCLI
Copy link

ftCLI commented Jun 16, 2023

Here's a screen of both PowerShell and CMD.exe side by side with -C (and the edit I made to prevent crashes):

image

click seems able to print colored output in both, but I have to test other colors:

image

@graphicore
Copy link
Collaborator

Yeah, the progressbar also uses ANSI escape codes, thus, so far -n is also required if these are not working.

@domija
Copy link

domija commented Jun 17, 2023

I was actually able to get it work by using the new windows terminal app.
obrazek

@simoncozens
Copy link
Collaborator

I reckon #4447 will fix this, but I can't test on windows.

@ftCLI
Copy link

ftCLI commented Jan 25, 2024

I reckon #4447 will fix this, but I can't test on windows.

Works on Windows 10 21H2

image

image

@simoncozens
Copy link
Collaborator

Nice, thanks for the test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tool improvement Desirable but not crucial for the tool
Projects
None yet
Development

No branches or pull requests

7 participants
@simoncozens @felipesanches @davelab6 @graphicore @domija @ftCLI and others