def __init__(self): threading.Thread.__init__(self) self.setDaemon(True) # some default self.ip = "" self.port = 2468 self.password = "" # read config if config.has_option("daemon", "ip") and config.get("daemon", "ip"): self.ip = config.get("daemon", "ip") if config.has_option("daemon", "port") and config.get("daemon", "port"): self.port = config.getint("daemon", "port") if config.has_option("admin", "password") and \ config.get("admin", "password"): self.password = config.get("admin", "password") # These are used to catch startup errors of the asyncore server self.startError = None self.startedEvent = threading.Event() if sys.platform != "win32": signal.signal(signal.SIGUSR1, self.sig_usr1_handler)
def connectToDb(self): """ """ # FIXME: # set-variable=max_connections=500 # set-variable=wait_timeout=200 logging.debug("Connecting to database...") db = None try: if config.get("database", "type") == "mysql": logging.debug("Using MySQL driver") db = DB.connect( host = config.get("database", "host"), port = config.getint("database", "port"), user = config.get("database", "user"), passwd = config.get("database", "password"), db = config.get("database", "database") ) else: logging.debug("Using Firebird driver") db = DB.connect( host = config.get("database", "host"), user = config.get("database", "user"), password = config.get("database", "password"), database = config.get("database", "database") ) self.checkDbStatus(db) logging.debug("Connected to database") except DB.DatabaseError, exc: logging.error("DB connection: " + str(exc))
def sendCrossDomain(self): """ Crossdomain generated file """ strcross = "<cross-domain-policy>" cd = config.get("crossdomain", "alloweddomains") domains = cd.split(" ") for domain in domains: if len(domain) > 3: strcross += "<allow-access-from domain='"+domain+"' to-ports='"+config.get("daemon", "port")+"' />" strcross += "</cross-domain-policy>" self.clientSendMessage(strcross)
def __init__(self): self.pidfile = config.get("daemon", "pidfile") self.daemon = config.getboolean("daemon", "startdaemon") if not self.daemon: signal.signal(SIGINT, self.sig_handler)
from palabre import config, logging, version, escape_string #from util import generateSessionId, safeClose from util import * from Message import mtypes from err import ERRORS SilentCheckInterval = 3 # seconds DB_MYSQL = 0 DB_FIRE = 1 dbtype = -1 if config.get("database", "type") == "mysql": import MySQLdb as DB dbtype = DB_MYSQL elif config.get("database", "type") == "firebird": import kinterbasdb as DB dbtype = DB_FIRE else: raise Exception("Unknown database type in config") from datetime import datetime from palabreClient import PalabreClient class PalabreServer(asyncore.dispatcher): channel_class = PalabreClient