Changeset 39
- Timestamp:
- 07/19/07 19:51:20 (1 year ago)
- Files:
-
- projects/twisted-goodies/trunk/MANIFEST.in (modified) (1 diff)
- projects/twisted-goodies/trunk/misc/etc_simpleserver_server.conf (modified) (1 diff)
- projects/twisted-goodies/trunk/postsetup.py (modified) (2 diffs)
- projects/twisted-goodies/trunk/setup.py (modified) (2 diffs)
- projects/twisted-goodies/trunk/twisted_goodies/simpleserver/service.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/twisted-goodies/trunk/MANIFEST.in
r2 r39 1 misc/* 1 graft misc projects/twisted-goodies/trunk/misc/etc_simpleserver_server.conf
r38 r39 1 1 # SimpleServer Configuration File 2 2 3 # User and group 4 user = simpleserver 5 group = simpleserver 6 3 7 # Services provided 4 services = HTTP POP38 services = HTTP, POP3 5 9 6 10 # Passwords file for authenticated access projects/twisted-goodies/trunk/postsetup.py
r12 r39 1 1 """ 2 2 Post setup operations 3 4 Copyright (C) 2006-2007 by Edwin A. Suominen, http://www.eepatents.com 5 6 This program is free software; you can redistribute it and/or modify it under 7 the terms of the GNU General Public License as published by the Free Software 8 Foundation; either version 2 of the License, or (at your option) any later 9 version. 10 11 This program is distributed in the hope that it will be useful, but WITHOUT ANY 12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 PARTICULAR PURPOSE. See the file COPYING for more details. 14 15 You should have received a copy of the GNU General Public License along with 16 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 17 Street, Fifth Floor, Boston, MA 02110-1301, USA 18 3 19 """ 4 20 … … 27 43 28 44 def prepareDirectory(self, dirParts): 29 for k in xrange(len(dirParts) -1):45 for k in xrange(len(dirParts)): 30 46 thisDir = os.path.join(*dirParts[:k+1]) 31 47 if not os.path.exists(thisDir): projects/twisted-goodies/trunk/setup.py
r20 r39 25 25 26 26 ### Imports and support 27 import ez_setup 27 import ez_setup, postsetup 28 28 ez_setup.use_setuptools() 29 29 from setuptools import setup, find_packages … … 94 94 ### Finally, run the setup 95 95 setup(name=NAME, **kw) 96 96 postsetup.run(NAME, 'simpleserver', 'simpleserver') projects/twisted-goodies/trunk/twisted_goodies/simpleserver/service.py
r38 r39 1 1 2 2 import pwd, grp, os, os.path, imp 3 import configobj 3 import configobj, pkg_resources 4 4 from twisted.internet import ssl, defer 5 from twisted.cred import checkers 5 6 from twisted.application import internet, service 6 7 … … 60 61 package path and return a function named 'factory' within that module. 61 62 """ 63 def getModuleInfo(resourceName): 64 path = pkg_resources.resource_filename(__name__, resourceName) 65 if os.path.isdir(path): 66 pkg = imp.load_module(name, None, '', ('', '', 5)) 67 path = os.path.join(path, '__init__.py') 68 fd = open(path) 69 return fd, '', ('.py', 'U', 1) 70 62 71 name = name.lower() 63 myPath = os.path.dirname(__file__) 64 fp, pathname, description = imp.find_module(name, myPath) 65 try: 66 module = imp.load_module(name, fp, pathname, description) 67 except: 68 return 69 return getattr(module, 'factory', None) 72 if pkg_resources.resource_exists(__name__, name): 73 info = getModuleInfo(name) 74 else: 75 info = getModuleInfo(name + '.py') 76 print info 77 module = imp.load_module(name, *info) 78 print name, dir(module) 79 result = getattr(module, 'factory', None) 80 if info[0] is not None: 81 info[0].close() 82 return result 70 83 71 84 def _serviceGenerator(self): … … 79 92 if not callable(factoryFunction): 80 93 continue 94 serviceConfig = self.config[key] 95 print key, serviceConfig 81 96 factory = factoryFunction(self, serviceConfig) 82 serviceConfig = self.config[key]83 97 for portName in ('tcp', 'ssl'): 84 98 if portName not in serviceConfig: 85 99 continue 86 port = serviceConfig[portName]100 port = int(serviceConfig[portName]) 87 101 if portName == 'tcp': 88 102 serviceObject = internet.TCPServer(port, factory) … … 93 107 self.config['certificate']) 94 108 serviceObject = internet.SSLServer(port, factory, ctx) 95 serviceObject.setName( 96 "%s-%s" % tuple([x.upper() for x in (key, portName)])) 109 serviceName = "%s-%s" % \ 110 tuple([x.upper() for x in (key, portName)]) 111 print serviceName 112 serviceObject.setName(serviceName) 97 113 yield serviceObject 98 114
