Code Monkey home page Code Monkey logo

Comments (2)

jgehrcke avatar jgehrcke commented on June 17, 2024

Thanks for the feedback again.

A little background on this
Timegaps almost always needs to write something to stdout. Since stdout is a byte stream, Python needs to encode unicode data before it writes it to stdout. But which codec do we use for this? The goal is that the receiving end understands the encoded data. Python automatically determines the codec based on the value of the LC_CTYPE environment variable, but only if stdout is a tty, i.e. when stdout is displayed to the user in a terminal. If the program is not run in an interactive shell or if the output is piped to another process, the output encoding is not defined, i.e. sys.stdout.encoding is None. In this case, we (the timegaps program) can make an educated guess or leave the decision up to the user. Educated guesses with respect to encoding in my opinion, and in opinion of others, are a quite mean source of error, whereas a clear request to the user to choose the right encoding for his/her system is the only way to achieve reliability of the software itself. Relying on the user-given environment variable PYTHONIOENCODING therefore is a reasonable choice. This opinion is shared for example here: http://stackoverflow.com/a/4374457/145400 and here: http://stackoverflow.com/a/6361471/145400

Your case
Now it should be clear that in your case the encoding to be used for writing to stdout was unclear to the program, because you ran timegaps non-interactively as a cron job.

The error message has nothing to do with command line argument parsing, because luckily there is a generic solution (I think) to this problem, which is implemented in timegaps. Since the error message does not mention command line arguments, I think this should not be an issue.

Since mentioning stdin in the error message confused you, we could implement two different error messages:

  • If stdin is not used at all, then the error message should only say that timegaps does not know how to write data to stdout.
  • If stdin is used, then the error message should say that timegaps does neither know how to read from stdin, nor does it know how to write to stdout.

Does this make sense or is it still too user unfriendly?:)

from timegaps.

murphyke avatar murphyke commented on June 17, 2024

Yes, that makes perfect sense, thanks!

from timegaps.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.