- Timestamp:
- 07/05/10 13:57:37 (11 years ago)
- Location:
- trunk/factory
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/factory/conf/config.default.ini
r184 r379 7 7 log_level = debug 8 8 log_format = %(asctime)s %(levelname)s: %(message)s 9 10 pidfile = /var/run/officeshots.pid 9 11 10 12 xmlrpc_endpoint = https://www.officeshots.org:443/xmlrpc -
trunk/factory/src/backends/oooserver.py
r357 r379 17 17 from backends import Backend, BackendException 18 18 from com.sun.star.io import IOException 19 from com.sun.star.uno import RuntimeException, IllegalArgumentException 19 from com.sun.star.uno import RuntimeException 20 from com.sun.star.lang import IllegalArgumentException 20 21 from com.sun.star.beans import PropertyValue 21 22 from com.sun.star.connection import NoConnectException -
trunk/factory/src/factory.py
r370 r379 27 27 import socket 28 28 import logging 29 import traceback 29 30 import ConfigParser 30 31 … … 33 34 from xmlrpclib import ServerProxy, Error, Fault 34 35 from xml.parsers.expat import ExpatError 36 from daemon import Daemon 35 37 36 38 LOGLEVELS = {'debug': logging.DEBUG, … … 40 42 'critical': logging.CRITICAL} 41 43 42 class Factory :44 class Factory(Daemon): 43 45 """ 44 46 The core factory class communicates with the Officeshots server and passes … … 50 52 self.config = ConfigParser.RawConfigParser() 51 53 self.config.read(os.path.abspath(self.options.config_file)) 54 self.daemon = True 52 55 53 56 # Configure logging 54 57 if self.options.debug: 55 58 logging.basicConfig(format = self.config.get('global', 'log_format'), level = logging.DEBUG) 59 self.daemon = False 56 60 else: 57 61 level = LOGLEVELS.get(self.config.get('global', 'log_level'), logging.NOTSET) … … 67 71 sys.exit(1) 68 72 73 # Set the pidfile 74 self.pidfile = self.config.get('global', 'pidfile') 75 69 76 # Load factory name 70 77 self.name = self.config.get('global', 'factory_name') 71 78 72 79 # Configure the XMLRPC proxy 73 transport_name = self.config.get('global', 'transport') 74 transport = self.load('transports.' + transport_name, 'SSLTransport') 80 self.transport_name = self.config.get('global', 'transport') 81 82 # Make sure we're not using encrypted certificated in daemon mode with PySSL 83 if self.transport_name == 'pyssl' and self.daemon: 84 encrypted = ( 85 self.is_encrypted(self.config.get('global', 'tls_key_file')) or 86 self.is_encrypted(self.config.get('global', 'tls_certificate_file')) 87 ) 88 89 if encrypted: 90 logging.critical("You cannot use encrypted PEM certificates in the PySSL transport when running as a daemon") 91 return False 92 93 return True 94 95 def load_components(self): 96 transport = self.load('transports.' + self.transport_name, 'SSLTransport') 75 97 if transport is None: 76 print "Transport %s could not be loaded" % transport_name98 print "Transport %s could not be loaded" % self.transport_name 77 99 sys.exit(1) 78 100 … … 127 149 return getattr(module, class_name) 128 150 129 151 def is_encrypted(self, key): 152 """ 153 Check if a PEM file is encrypted 154 """ 155 infile = open(key, "r") 156 keytext = infile.read() 157 infile.close() 158 159 if keytext.find("ENCRYPTED") > -1: 160 del keytext 161 return True 162 163 del keytext 164 return False 130 165 131 166 def systemload(self): … … 219 254 """ 220 255 logging.info('Starting factory server.') 221 while self.loop(): 222 pass 256 try: 257 while self.loop(): 258 pass 259 except: 260 logging.critical(traceback.format_exc()) 261 sys.exit(1) 223 262 224 263 … … 233 272 234 273 factory = Factory() 235 if factory.configure(options): 236 factory.run() 274 if not factory.configure(options): 275 logging.critical("Failed to load and parse the configuration") 276 sys.exit(1) 277 278 if len(args) == 0 or args[0] == 'start': 279 if not factory.load_components(): 280 sys.exit(1) 281 282 if factory.daemon: 283 factory.start() 284 else: 285 factory.run() 286 287 elif args[0] == 'stop': 288 logging.info('Stopping factory server.') 289 factory.stop() 290 291 elif args[0] == 'restart': 292 logging.info('Retarting factory server.') 293 if not factory.load_components(): 294 sys.exit(1) 295 296 factory.restart() 297 else: 298 print "Unknown command: %s" % args[0] 299 sys.exit(2)
Note: See TracChangeset
for help on using the changeset viewer.