def startServices(): for service in settings['services']: name = service['name'] type = service['type'] service_class = misc.getCallableByName(service['class']) if type == 'TCPListener': address = misc.getAddressFromString(service['address']) worker_threads = int(service['worker_threads']) services[name] = service_class(name, address, worker_threads) elif type == 'ScheduledTask': interval = int(service['interval']) services[name] = service_class(name, interval) # add parameters if service.has_key('parameters'): services[name].parameters = service['parameters'] # start service services[name].start()
# 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 Porcupine; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #=============================================================================== "Validates miscelanous server parameters" from porcupine import serverExceptions from porcupine.config.settings import settings from porcupine.utils import misc # [server] section try: serverAddress = misc.getAddressFromString(settings.server.address) except AttributeError: raise serverExceptions.ConfigurationError, (('address', 'server'),) except: raise serverExceptions.ConfigurationError, 'Invalid server bind address: %s' % settings.server.address try: worker_threads = int(settings.server.worker_threads) except AttributeError: raise serverExceptions.ConfigurationError, (('worker_threads', 'server'),) except ValueError: raise serverExceptions.ConfigurationError, 'Invalid workder_threads setting: %s' % settings.server.worker_threads try: allow_guests = int(settings.server.allow_guests) except AttributeError:
# 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. # Porcupine 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 Porcupine; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # =============================================================================== "Server replication settings" from porcupine import serverExceptions from porcupine.config.settings import settings from porcupine.utils import misc try: host_priority = int(settings.replication.priority) except AttributeError: raise serverExceptions.ConfigurationError, (("priority", "replication"),) except ValueError: raise serverExceptions.ConfigurationError, "Invalid replication host priority setting: %s" % settings.replication.priority try: hostaddr = misc.getAddressFromString(settings.replication.host_address) except ValueError: raise serverExceptions.ConfigurationError, "Invalid host address setting: %s" % settings.replication.host_address except AttributeError: hostaddr = None
elif opt in ('-r', '--restore'): command = 'DB_RESTORE' elif opt in ('-h', '--shrink'): command = 'DB_SHRINK' elif opt in ('-s', '--server'): address = arg elif opt in ('-f', '--file'): file = arg else: usage() if not command or not address: usage() try: address = misc.getAddressFromString(address) except: sys.exit('Invalid server address...') # construct request object if command in ('DB_BACKUP', 'DB_RESTORE'): if not(file): usage() msg = management.MgtMessage(command, file) else: msg = management.MgtMessage(command, '') request = management.MgtRequest(msg.serialize()) try: response = request.getResponse(address)