Revision 7d93221a5c159ce506b2a557777d1a1751c7f743 authored by R. David Murray on 05 May 2010, 17:31:03 UTC, committed by R. David Murray on 05 May 2010, 17:31:03 UTC
Yukihiro Nakadaira noticed a typo in encode_7or8bit that was trying
to special case iso-2022 codecs.  It turns out that the code in
question is never used, because whereas it was designed to trigger
if the payload encoding was eight bit but its output encoding was
7 bit, in practice the payload is always converted to the 7bit
encoding before encode_7or8bit is called.  Patch by Shawat Anand.
1 parent b26dc46
Raw File
script.py
#! /usr/bin/env python

# script.py -- Make typescript of terminal session.
# Usage:
#       -a      Append to typescript.
#       -p      Use Python as shell.
# Author: Steen Lumholt.


import os, time, sys, getopt
import pty

def read(fd):
    data = os.read(fd, 1024)
    script.write(data)
    return data

shell = 'sh'
filename = 'typescript'
mode = 'w'
if os.environ.has_key('SHELL'):
    shell = os.environ['SHELL']

try:
    opts, args = getopt.getopt(sys.argv[1:], 'ap')
except getopt.error, msg:
    print '%s: %s' % (sys.argv[0], msg)
    sys.exit(2)

for o, a in opts:
    if o == '-a':
        mode = 'a'
    elif o == '-p':
        shell = 'python'

script = open(filename, mode)

sys.stdout.write('Script started, file is %s\n' % filename)
script.write('Script started on %s\n' % time.ctime(time.time()))
pty.spawn(shell, read)
script.write('Script done on %s\n' % time.ctime(time.time()))
sys.stdout.write('Script done, file is %s\n' % filename)
back to top