示例#1
0
    def __init_log(self, path, step, errlog=None):
        # arguments:
        #   path:	Log file path (str).
        #   step:	Execution step (RST.BLD or RST.RUN).
        #   errlog:	Error log or not (RST.ERR or None).

        if path is None:
            return None

        # file header info
        testids = {
            TESTID.STUB: 'スタブ',
            TESTID.EMBPYTHON: 'EmbPython',
            TESTID.TESTS: '',
            TESTID.SAMPLES: 'サンプル',
            TESTID.OTHER: 'その他'
        }
        steps = {RST.BLD: 'ビルド', RST.RUN: '実行'}
        datestr = '日付 : %s' % Util.date()
        err = 'エラー' if errlog == RST.ERR else ''
        header = '--- %s%s%sのログ ---' % \
         (testids[self.testid], steps[step], err)

        # write header
        f = TextFio(path, 'w', encoding=self.encoding)
        if f.open() < 0:
            msg = '__init_log: open error "%s"', path
            Error(self.clsname).error(msg)
            return
        f.writeline(datestr)
        f.writeline(header)
        f.writeline('')
        f.close()
        print('init logfile: "%s"' % path)
示例#2
0
if options.version:
	E.print('Version %s' % version, prompt=None)
	sys.exit(0)
#
if len(args) != 1:
	E.print("incorrect number of arguments")

# output file name
outfile = args[0]

# ----------------------------------------------------------------------
#  Open output file
#
f = TextFio(outfile, 'a')
if f.open() < 0:
	E.print(f.error())
	
# ----------------------------------------------------------------------
#  Copy from stdin to outfile
#
while True:
	line = sys.stdin.read()
	if line == '':
		break
	f.writeline(line)
f.close()

sys.exit(0)

# dnd: log_append.py