~ubuntu-branches/ubuntu/trusty/pexpect/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/platform_tests/pexqa.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio, Thomas Kluyver, Jakub Wilk, Jackson Doak, Andrew Starr-Bochicchio
  • Date: 2013-12-06 20:20:26 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131206202026-9k9oixbv7e8ke30q
Tags: 3.0-1
* Team upload.

[ Thomas Kluyver ]
* New upstream release. Closes: #729518
* Add packaging for Python 3.
* Use pybuild for packaging.

[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Jackson Doak ]
* Create debian/python3-pexpect.docs

[ Andrew Starr-Bochicchio ]
* Remove empty debian/patches dir.
* Move documentation and examples into a new python-pexpect-doc
  package. They are shared between the Python 2 and Python 3 packages,
  so there is no need to install them with both.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os, sys
 
2
import select
 
3
import signal
 
4
import traceback
 
5
import time
 
6
import re
 
7
import struct
 
8
from types import *
 
9
import posix
 
10
 
 
11
import pty
 
12
import tty
 
13
import termios
 
14
import fcntl
 
15
class s:
 
16
    def __init__(self, command, args=None, timeout=30):
 
17
 
 
18
        self.pid = self.child_fd = None
 
19
        try:
 
20
            #self.pid, self.child_fd = posix.forkpty()
 
21
            self.pid, self.child_fd = pty.fork()
 
22
        except OSError as e:
 
23
            raise Exception('pty fork() failed: ' + str(e))
 
24
 
 
25
        if self.pid == 0: # Child
 
26
            os.execvp(command, args)
 
27
 
 
28
        # Parent
 
29
 
 
30
 
 
31
print '1'
 
32
x = s('ls', ['ls'])
 
33
time.sleep(5)
 
34
print '2'
 
35
result = os.read (x.child_fd, 5555)
 
36
print '3'
 
37
print result
 
38
print '4'
 
39