Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-11265

Make STDOUT from validate_drp print_metrics readable in log file

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Won't Fix
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: validate_drp
    • Labels:
      None
    • Team:
      DM Science

      Description

      When the output of validate_drp print_metrics is captured by a log file, e.g., from STDOUT, the control characters that change the colors for interactive terminal use get stored as escape sequences. This makes the log file annoying to read.

      Either:

      1. Change default behavior to not print with colors
      2. Make it "smart" to detect whether it's writing to terminal or stdout (this seems like a potential rabbit hole, but maybe there's a simple solution).

      Example snippet:

      [...]
      Photometric scatter (median) - SNR > 100.0 : 11.5 mmag
      Median value of the astrometric scatter - all magnitudes: 57.686 marcsec
      Astrometric scatter (median) - snr > 100.0 : 10.1 marcsec
      No stars found that are 199.0 arcmin--201.0 arcmin apart.
      ESC[1mESC[95m=================================================================ESC[0m
      ESC[1mESC[95mr band metric measurementsESC[0m
      ESC[1mESC[95m=================================================================ESC[0m
      ESC[95mPA1 - LPM-17, p. 21, http://ls.st/lpm-17
      ESC[0mThe maximum rms of the unresolved source magnitude
      distribution around the mean value (repeatability).
      [...]
      

        Attachments

          Issue Links

            Activity

            Hide
            jsick Jonathan Sick added a comment -

            Ah, that's interesting. I like option 1, especially given that this code will be moving to verify (I realize that verify only has notebook-based reporting; a console printout is needed too.)

            Show
            jsick Jonathan Sick added a comment - Ah, that's interesting. I like option 1, especially given that this code will be moving to verify (I realize that verify only has notebook-based reporting; a console printout is needed too.)
            Hide
            wmwood-vasey Michael Wood-Vasey added a comment -

            I've been rearranging things a bit for DM-11215. So I've marked this ticket as blocked by that one for now.

            Show
            wmwood-vasey Michael Wood-Vasey added a comment - I've been rearranging things a bit for DM-11215 . So I've marked this ticket as blocked by that one for now.
            Hide
            tjenness Tim Jenness added a comment - - edited

            I think option 2 is pretty simple. You check to see if you are writing to a tty or not with if sys.stdout.isatty().

            Show
            tjenness Tim Jenness added a comment - - edited I think option 2 is pretty simple. You check to see if you are writing to a tty or not with if sys.stdout.isatty() .
            Hide
            tjenness Tim Jenness added a comment -

            Saying that, giving the caller of the code control over this directly rather than trying to intuit it, is probably best. For example, in my previous life, we wrote log files with color escapes but I also wrote some code to detect the escapes and convert them to local markup (such as HTML style annotations) and also wrote plugins for my GUIs so that the escape codes would be shown correctly in Tk Text widgets. What I'm really saying is, sometimes you want the color codes in your log files.

            Show
            tjenness Tim Jenness added a comment - Saying that, giving the caller of the code control over this directly rather than trying to intuit it, is probably best. For example, in my previous life, we wrote log files with color escapes but I also wrote some code to detect the escapes and convert them to local markup (such as HTML style annotations) and also wrote plugins for my GUIs so that the escape codes would be shown correctly in Tk Text widgets. What I'm really saying is, sometimes you want the color codes in your log files.
            Hide
            lguy Leanne Guy added a comment -

            validate_drp has been replaced by faro and is frozen. There will be no further development on the validate_drp package

            Show
            lguy Leanne Guy added a comment - validate_drp has been replaced by faro and is frozen. There will be no further development on the validate_drp package

              People

              Assignee:
              lguy Leanne Guy
              Reporter:
              wmwood-vasey Michael Wood-Vasey
              Watchers:
              Jonathan Sick, Leanne Guy, Michael Wood-Vasey, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.