summaryrefslogtreecommitdiff
path: root/pynslcd/debugio.py
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2011-02-14 21:08:45 +0000
committerArthur de Jong <arthur@arthurdejong.org>2011-02-14 21:08:45 +0000
commitf3cca68a9016d7f043950a7ef3d41e628ebd1135 (patch)
tree21a46ad646137f510f39e525e4f30dd7d3910b05 /pynslcd/debugio.py
parenta7f26c1c2e8bf52675ec9e5e3ab22172b038106d (diff)
clean up and add missing files to installation
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1371 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd/debugio.py')
-rw-r--r--pynslcd/debugio.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/pynslcd/debugio.py b/pynslcd/debugio.py
deleted file mode 100644
index dbb5b02..0000000
--- a/pynslcd/debugio.py
+++ /dev/null
@@ -1,65 +0,0 @@
-
-# debugio.py - module for debugging an I/O stream
-#
-# Copyright (C) 2008, 2009 Arthur de Jong
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 USA
-
-class DebugIO():
- """This class is a file-like object that writes from one file and
- writes to another. It is mainly used for debugging the serial protocol
- without a serial connection."""
-
- def __init__(self, name):
- import os
- if not os.path.exists(name+'.in'): os.mkfifo(name+'.in')
- if not os.path.exists(name+'.out'): os.mkfifo(name+'.out')
- r = open(name+'.in', 'r', 0)
- w = open(name+'.out', 'w', 0)
- self._r = r
- self._w = w
- self.write = w.write
- self.portstr = 'debuging to %s.in and %s.out' % ( name, name )
- self._timeout = None
-
- def close(self):
- self._r.close()
- self._w.close()
-
- def inWaiting(self):
- # we are never out of data and 100 should be enough for everybody
- return 100
-
- def setTimeout(self, seconds):
- self._timeout = seconds
-
- def getTimeout(self):
- return self._timeout
-
- def read(self, size):
- import select
- read = ''
- if size > 0:
- while len(read) < size:
- ready, _, _ = select.select([self._r.fileno()], [], [], self._timeout)
- if not ready:
- break #timeout
- buf = self._r.read(size-len(read))
- read = read + buf
- if self._timeout >= 0 and not buf:
- break #early abort on timeout
- return read
-