question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Still can't pipe console output (#1065 not fixed)

See original GitHub issue

This is basically re-opening #1065; the patch in 28a9895 did not fix the problem.

Prerequisites

  • Did you read FAQ section in readme.md?
  • Did you test with the latest releases or commit ? (Yes, git master)
  • Did you search for existing issues in Issues?

Description

AttributeError: 'NoneType' object has no attribute 'set_title'.

The patch that closed #1065 did not actually fix the issue.

Steps to Reproduce

  1. $ PixivUtil2 --help |cat (on Unix)

Expected behavior: help text should print to standard output.

Actual behavior:

Traceback (most recent call last):
  File "/home/fake-user-name/bin/PixivUtil2", line 1566, in <module>
    main()
  File "/home/fake-user-name/bin/PixivUtil2", line 1359, in main
    set_console_title()
  File "/home/fake-user-name/bin/PixivUtil2", line 1044, in set_console_title
    PixivHelper.set_console_title(set_title)
  File "/home/fake-user-name/development/PixivUtil2/PixivHelper.py", line 389, in set_console_title
    sys.stdout.write(f'\33]0;{title}\a')
  File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 41, in write
    self.__convertor.write(text)
  File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 162, in write
    self.write_and_convert(text)
  File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 184, in write_and_convert
    text = self.convert_osc(text)
  File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 256, in convert_osc
    winterm.set_title(params[1])
AttributeError: 'NoneType' object has no attribute 'set_title'

Also, you have embedded xterm-specific escape sequences into the program. These sequences do not render correctly on anything but xterm. A real VT100 or VT220, or any number of other terminals, would exhibit undefined behavior.

Log file: [Attach the pixivutil.log file in the application folder, recommended to delete the old file, reproduce the issue, and upload the newly generated file here]

Log file is blank.

Versions

Git master. Commit 3495f52.

PixivDownloader2 version 20211104

Changing the function to:

def set_console_title(title):
    if platform.system() == "Windows":
        try:
            subprocess.call('title' + ' ' + title, shell=True)
        except FileNotFoundError:
            print_and_log("error", f"Cannot set console title to {title}")
        except AttributeError:
            # Issue #1065
            pass
    else:
        if "xterm" in os.getenv("TERM"):
            try:
                sys.stdout.write(f'\33]0;{title}\a')
                sys.stdout.flush()
            except AttributeError:
                pass

Fixes the issue, and also makes it only attempt to set the title string with xterm escape codes on xterm and similar terminals.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cglmrfreemancommented, Jan 18, 2022

Can confirm on my system python3 PixivUtil2.py --help | cat produces an identical error.

0reactions
Nandakacommented, Feb 6, 2022

merged 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I echo directly on standard output inside a shell ...
Redirect in the function then echo "message content" >&2 . @EtanReisner - Sounds like they want it on standard out and standard error....
Read more >
How do I save terminal output to a file? - command line
Yes it is possible, just redirect the output (AKA stdout ) to a file: SomeCommand > SomeFile.txt. Or if you want to append...
Read more >
2 Server Error Message Reference - MySQL :: Developer Zone
Possible causes: Permissions problem for source file; destination file already exists but is not writeable. Error number: 1005 ; Symbol: ER_CANT_CREATE_TABLE ; ...
Read more >
2022 Publication 225 - IRS
If you have a tax question not answered by this publication or the How To Get Tax ... the tax year in which...
Read more >
How to redirect shell command output | Enable Sysadmin
There are multiple ways to redirect output from shell scripts and commands. 1. Redirect STDOUT. For the following examples, I will use this ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found