]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Demo/scripts/script.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Demo / scripts / script.py
CommitLineData
4710c53d 1#! /usr/bin/env python\r
2\r
3# script.py -- Make typescript of terminal session.\r
4# Usage:\r
5# -a Append to typescript.\r
6# -p Use Python as shell.\r
7# Author: Steen Lumholt.\r
8\r
9\r
10import os, time, sys, getopt\r
11import pty\r
12\r
13def read(fd):\r
14 data = os.read(fd, 1024)\r
15 script.write(data)\r
16 return data\r
17\r
18shell = 'sh'\r
19filename = 'typescript'\r
20mode = 'w'\r
21if os.environ.has_key('SHELL'):\r
22 shell = os.environ['SHELL']\r
23\r
24try:\r
25 opts, args = getopt.getopt(sys.argv[1:], 'ap')\r
26except getopt.error, msg:\r
27 print '%s: %s' % (sys.argv[0], msg)\r
28 sys.exit(2)\r
29\r
30for o, a in opts:\r
31 if o == '-a':\r
32 mode = 'a'\r
33 elif o == '-p':\r
34 shell = 'python'\r
35\r
36script = open(filename, mode)\r
37\r
38sys.stdout.write('Script started, file is %s\n' % filename)\r
39script.write('Script started on %s\n' % time.ctime(time.time()))\r
40pty.spawn(shell, read)\r
41script.write('Script done on %s\n' % time.ctime(time.time()))\r
42sys.stdout.write('Script done, file is %s\n' % filename)\r