mirror of
https://github.com/python/cpython.git
synced 2025-07-13 14:25:18 +00:00
Get rid of freeze (now its own directory).
Added some new demos. Fixed a few others.
This commit is contained in:
parent
011813444c
commit
07c9645413
6 changed files with 345 additions and 25 deletions
33
Demo/scripts/script.py
Executable file
33
Demo/scripts/script.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /usr/local/bin/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
|
||||
import pty
|
||||
|
||||
def read(fd):
|
||||
data = os.read(fd, 1024)
|
||||
file.write(data)
|
||||
return data
|
||||
|
||||
shell = 'sh'
|
||||
filename = 'typescript'
|
||||
mode = 'w'
|
||||
if os.environ.has_key('SHELL'):
|
||||
shell = os.environ['SHELL']
|
||||
if '-a' in sys.argv:
|
||||
mode = 'a'
|
||||
if '-p' in sys.argv:
|
||||
shell = 'python'
|
||||
|
||||
file = open(filename, mode)
|
||||
|
||||
sys.stdout.write('Script started, file is %s\n' % filename)
|
||||
file.write('Script started on %s\n' % time.ctime(time.time()))
|
||||
pty.spawn(shell, read)
|
||||
file.write('Script done on %s\n' % time.ctime(time.time()))
|
||||
sys.stdout.write('Script done, file is %s\n' % filename)
|
Loading…
Add table
Add a link
Reference in a new issue