Save the current values of System.out, System.err and configure output
streams for FsShell.
14080
protected void pushContext() {
    antOut = System.out;
    antErr = System.err;
    System.setOut(new PrintStream(out));
    System.setErr(out == err ? System.out : new PrintStream(err));
  }
919120
def save(self, output=''):
        
        self.file = self._get_output_file(output)
        with open(self.file, 'w', encoding='utf-8') as f:
            self.write(f)
767224
function outputErrors( errors, fnOut ) {
	if ( Array.isArray( errors ) && typeof fnOut === 'function' ) {
		errors.forEach( function( error ){
			fnOut( error );
		});
	} // if
}
1054087
def do_save(self, fp=None):
        
        if fp is None:
            fp = sys.stdout
        data = {
            'settings': self.settings,
            'nodes': self.nodes,
            'backward': self.backward
        }
        json.dump(data, fp, ensure_ascii=False)
1224372
def capture_sys_output():
    """"""
    capture_out, capture_err = StringIO(), StringIO()
    current_out, current_err = sys.stdout, sys.stderr
    try:
        sys.stdout, sys.stderr = capture_out, capture_err
        yield capture_out, capture_err
    finally:
        sys.stdout, sys.stderr = current_out, current_err
1353682
public static function resetStd()
    {
        if (!static::$daemonize || static::$_OS !== OS_TYPE_LINUX) {
            return;
        }
        global $STDOUT, $STDERR;
        $handle = fopen(static::$stdoutFile, "a");
        if ($handle) {
            unset($handle);
            set_error_handler(function(){});
            fclose($STDOUT);
            fclose($STDERR);
            fclose(STDOUT);
            fclose(STDERR);
            $STDOUT = fopen(static::$stdoutFile, "a");
            $STDERR = fopen(static::$stdoutFile, "a");
            // change output stream
            static::$_outputStream = null;
            static::outputStream($STDOUT);
            restore_error_handler();
        } else {
            throw new Exception('can not open stdoutFile ' . static::$stdoutFile);
        }
    }
1165176
def output_file(self):
        
        out_files = self.output_files
        if len(out_files) != 1:
            err_msg = "output_file property is only valid if there is a single"
            err_msg += " output file. Here there are "
            err_msg += "%d output files." %(len(out_files))
            raise ValueError(err_msg)
        return out_files[0]
1031580
public synchronized static void setStdout(OutputStream os)
  {
    if (_stdoutStream == null) {
      initStdout();
    }

    if (os == _systemErr || os == _systemOut) {
      return;
    }

    if (os instanceof WriteStream) {
      WriteStream out = (WriteStream) os;

      /*
      if (out.getSource() == StdoutStream.create()
          || out.getSource() == StderrStream.create()) {
        return;
      }
      */
    }
    
    _stdoutStream.setStream(os);
  }
1276625
def save(filename=ConfigPath):
    """"""
    default_values = defaults()
    parser = configparser.RawConfigParser()
    parser.optionxform = str # Force case-sensitivity on names
    try:
        save_types = basestring, int, float, tuple, list, dict, type(None)
        for k, v in sorted(globals().items()):
            if not isinstance(v, save_types) or k.startswith("_") \
            or default_values.get(k, parser) == v: continue # for k, v
            try: parser.set("DEFAULT", k, json.dumps(v))
            except Exception: pass
        if parser.defaults():
            with open(filename, "wb") as f:
                f.write("# %s %s configuration written on %s.\n" % (Title, Version,
                        datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
                parser.write(f)
        else: # Nothing to write: delete configuration file
            try: os.unlink(filename)
            except Exception: pass
    except Exception:
        logging.warn("Error writing config to %s.", filename, exc_info=True)
1060528
def wrap_io_os_err(e):
    ''''''
    msg = ''
    if e.strerror:
        msg = e.strerror
    if e.message:
        msg = ' '.join([e.message, msg])
    if e.filename:
        msg = ': '.join([msg, e.filename])
    return msg
555827
def save(self, outpath):
        

        with open(outpath, "w") as outfile:
            outfile.write(self.dump())
731323
def save_output_value(name, value)
      set_field(CONTEXT_OUTPUTS_META, {}) if get_field(CONTEXT_OUTPUTS_META).nil?
      get_field(CONTEXT_OUTPUTS_META)[name] = value
    end
955035
public void dump(final PrintStream ps) {
    String str =
      "Reported error: \"" + message + "\"";

    if (lineNumber != -1) {
      str += " at line " + lineNumber + " column " + colNumber;
    }
    ps.println(str);

    if (exception != null) {
      exception.printStackTrace(ps);
    }
  }
1002671
def _write_to_error(self, s, truncate=False):
        """"""
        # if truncate is True, set write mode to truncate
        with open(self._errorfile, 'w' if truncate else 'a') as fp:
            fp.writelines((to_text(s)), )
909350
def save(self, out_path):
        

        out = {
            'selectors': [str(x) for x in self.selectors],
            'trace': [{'stream': str(DataStream.FromEncoded(x.stream)), 'time': x.raw_time, 'value': x.value, 'reading_id': x.reading_id} for x in self]
        }

        with open(out_path, "wb") as outfile:
            json.dump(out, outfile, indent=4)
171197
def on_IOError(self, e):
        

        sys.stderr.write("Error: %s: \"%s\"\n" % (e.strerror, e.filename))
1346642
public void save(ObjectOutputStream out) throws IOException
    {
        out.writeObject(base);
        out.writeObject(check);
        out.writeObject(fail);
        out.writeObject(output);
        out.writeObject(l);
    }