Repository navigation
flexget history crashes when piping to less or redirecting to a file #1223
Description
Activity
Maybe try to upgrade.
I test on my setup with version 2.1.1 and don't face this issue.I've been constantly upgrading to newest versions and am now on 2.1.1 and still getting the same error.
flexget history | lessno longer gives a stack trace, it just stops producing output, so if you scroll to end you see the history output just cuts short. But if you redirect the output you can still see the problem exists:$ flexget history > /tmp/flex.out Could not start manager: 'ascii' codec can't encode character u'\u2013' in position 47: ordinal not in range(128)This has something to do with system encoding, It was asked before.
Note that you can use the API for this as well:
curl -X GET --header "Accept: application/json" "http://host:5050/api/history/?page=1&max=50" < /tmp/flex.outand the encoding issue has been fixed in other commands in the past. the api only works if you run the daemon and many of us don't. i only run flexget via cron or the command line.
This works for me:
$ git diff flexget/logger.py diff --git a/flexget/logger.py b/flexget/logger.py index fc6524b..626c948 100644 --- a/flexget/logger.py +++ b/flexget/logger.py @@ -114,7 +114,8 @@ def console(text, *args, **kwargs): Accepts arguments like the `print` function does. """ if not isinstance(text, str): - text = str(text).encode(io_encoding, 'replace') + text = str(text) + text = text.encode(io_encoding, 'replace') kwargs['file'] = getattr(local_context, 'output', sys.stdout) print(text, *args, **kwargs) kwargs['file'].flush() # flush to make sure the output is printed right awayCool, wanna push a pr?
why was this labeled "Pending information"? ok, i'll answer the question- no i don't wanna push a pr, cause i only have access via phone these days. i gave you a 2-line patch, how is that insufficient?
This actually has been fixed on
nextbranch with dcce2b5
Will mark this as resolved when we merge that branch.Fixed with dcce2b5
@grr can you confirm it's fixed?
yes, mostly. it doesn't crash now, but the new ascii colorization causes visual artifacts when piping through less. it should do something like this instead:
if sys.stdout.isatty(): colorize()That's a good idea, we'll see about adding it
This issue is happening again. Tried with
flexget history | lessandflexget series list all | less. #1407 is the same issue.- added a commit that references this issue
on Oct 19, 2016
Expected behaviour:
print history when piping output to less or redirecting to a file
Actual behaviour:
crashes with:
Could not start manager: 'ascii' codec can't encode character u'\u2013' in position 47: ordinal not in range(128)Steps to reproduce:
flexget history | lessor
flexget history > history.txtAdditional information: