]> code.delx.au - bg-scripts/commitdiff
Removed more unused modules
authorGreg Darke <greg@tsukasa.net.au>
Mon, 7 Jul 2008 06:10:58 +0000 (16:10 +1000)
committerGreg Darke <greg@tsukasa.net.au>
Mon, 7 Jul 2008 06:10:58 +0000 (16:10 +1000)
ncat.py [deleted file]
python24_adapter.py [deleted file]

diff --git a/ncat.py b/ncat.py
deleted file mode 100755 (executable)
index b9314ea..0000000
--- a/ncat.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, os.path, socket 
-from optparse import OptionParser, Values
-
-VERSION = '''$Revision$'''
-
-try:
-       # These are my libraries...
-       import GregDebug, AsyncSocket
-
-       from GregDebug import debug, setDebugLevel, DEBUG_LEVEL_DEBUG, DEBUG_LEVEL_LOW, DEBUG_LEVEL_MEDIUM, DEBUG_LEVEL_HIGH, DEBUG_INCREMENT
-except ImportError, e:
-       print >>sys.stderr, "Missing libraries!\nExiting..."
-       sys.exit(1)
-
-
-class NetClient(object):
-       def __init__(self):
-               self.async_handler = AsyncSocket.AsyncSocketOwner()
-
-       def buildparser(self):
-               parser = OptionParser(version="%prog " + VERSION, 
-                       description = "Connects to a specific server",
-                       usage = "%prog [options] server [port]")
-               parser.add_option("-U", "--domain-socket",
-                       action="store_true", dest="isUnixDomainSocket", default="",
-                       help="Make the connection over a unix domain socket")
-               parser.add_option("-q", "--quiet", "--silent",
-                       action="count", dest="quiet", default=0,
-                       help="Make the script quiet (good for running from a shell script)")
-               parser.add_option("-v", '-d', "--verbose", "--debug",
-                       action="count", dest="verbose", default=0,
-                       help="Make the louder (good for debugging, or those who are curious)")
-               return parser
-
-       def createUnixSocket(self, domainSocketName):
-               sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-               sock.connect(domainSocketName)
-               return sock
-
-       def __handleStdin(self, fd):
-               data = fd.read()
-               if not data:
-                       debug('Seems that stdin has been closed (got no data from in on the last read) - exiting main loop')
-                       self.async_handler.exit() #XXX: I think this is the correct name
-               self.remoteSock.send(data) # Write the data to the socket
-               # TODO: Make sure that the data written to the socket has been completly written - Since
-               # self.sock is in non-blocking mode it may not have send everything
-
-       def __handleSock(self, fd):
-               data = fd.read()
-               if not data:
-                       debug('Seems that the socket has been closed (got no data from in on the last read) - exiting main loop')
-                       self.async_handler.doExit() #XXX: I think this is the correct name
-               sys.stdout.write(data) # Write the data to the screen
-               sys.stdout.flush()
-               # TODO: Turn sys.stdout into a non-blocking socket, since this call could block, and make things
-               # non-responsive
-
-       def main(self):
-               parser = self.buildparser()
-               useroptions, params = parser.parse_args(sys.argv[1:])
-
-               setDebugLevel(DEBUG_INCREMENT * (useroptions.quiet - useroptions.verbose))
-               debug("Just set GregDebug.DEBUG_LEVEL to %d" % GregDebug.DEBUG_LEVEL, DEBUG_LEVEL_LOW)
-
-               if useroptions.isUnixDomainSocket:
-                       self.remoteSock = self.createUnixSocket(params[0])
-               else:
-                       print >>sys.stderr, "No connection type specified"
-                       sys.exit(1)
-
-               self.async_handler.addFD(sys.stdin, self.__handleStdin)
-               self.async_handler.addSocket(self.remoteSock, self.__handleSock)
-               self.async_handler.mainLoop()
-
-if __name__ == "__main__":
-       NetClient().main()
diff --git a/python24_adapter.py b/python24_adapter.py
deleted file mode 100644 (file)
index 28951e1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#! python
-
-import collections
-
-class defaultdict(dict):
-       def __init__(self, default_factory):
-               self.default_factory = default_factory
-       def __missing__(self, key):
-               if self.default_factory is None:
-                       raise KeyError(key)
-               self[key] = value = self.default_factory()
-               return value
-       def __getitem__(self, key):
-               try:
-                       return dict.__getitem__(self, key)
-               except KeyError:
-                       return self.__missing__(key)
-
-if not hasattr(collections, 'defaultdict'):
-       collections.defaultdict = defaultdict