Example #1
0
 def run(self):
      if not os.path.isdir("/tmp/tcos_share"): os.mkdir("/tmp/tcos_share")
      self.fauthz = ftp_server.anon_authorizer('/tmp/tcos_share')
      self.ftps = ftps_server.ftp_tls_server(self.fauthz, self.ssl_ctx, port=self.FTP_PORT)
      self.ftps.status()
      self.sh=status_handler.status_extension([self.ftps])
      M2Crypto.Rand.save_file('/tmp/randpooltcos.dat')
      asyncore.loop()
def start(port):
	global running

	# install signal handler for SIGTERM and SIGINT
	import signal

	def signalHandler(signum, frame):
		global running

		log.message("RECEIVED SIGNAL", signum)
		running = 0

	signal.signal(signal.SIGTERM, signalHandler)
	signal.signal(signal.SIGINT, signalHandler)

	# create server
	logger = emptyLogger()
	server = http_server.http_server('', int(port), logger_object = logger)

	fsys = filesys.os_filesystem ('website')
	default = default_handler.default_handler (fsys)
	server.install_handler(default)

	handler = igerpc()
	server.install_handler(handler)

	handler = xmlrpc()
	server.install_handler(handler)

	status = status_handler.status_extension([server])
	server.install_handler(status)

	running = 1

	# get poll function
	import select
	if hasattr(select, "poll"):
		poll = asyncore.poll3
	else:
		poll = asyncore.poll

	# main loop
	try:
		while running:
			for scheduler in schedulers.itervalues():
				scheduler.tick()
			poll(timeout = 1.0)
	except KeyboardInterrupt:
		log.message("KeyboardInterrupt")
	except asyncore.ExitNow:
		log.message("ExitNow")
	except:
		traceback.print_exc()
Example #3
0
    def __init__(self, addr, logHttp=True, logResponses=True, logRequests=True, status=False):
        if not logHttp:
            _level = logging.ERROR
        else:
            _level = logging.INFO

        self.httpSrv = http_server.http_server(addr[0], addr[1], logger_object=logger.python_logger(level=_level))
        self.httpSrv.channel_class = MedusaXmlRpcChannel
        self.xmlRpcDispatcher = MedusaXmlRpcHandler(logger_object=logger.python_logger(level=_level), logRequests=logRequests, logResponses=logResponses)
        self.httpSrv.install_handler(self.xmlRpcDispatcher)
        if status:
            sh = status_handler.status_extension([self.httpSrv, self.xmlRpcDispatcher])
            self.httpSrv.install_handler(sh)
Example #4
0
    def __init__(self,
                 addr,
                 logHttp=True,
                 logResponses=True,
                 logRequests=True,
                 status=False):
        if not logHttp:
            _level = logging.ERROR
        else:
            _level = logging.INFO

        self.httpSrv = http_server.http_server(
            addr[0], addr[1], logger_object=logger.python_logger(level=_level))
        self.httpSrv.channel_class = MedusaXmlRpcChannel
        self.xmlRpcDispatcher = MedusaXmlRpcHandler(
            logger_object=logger.python_logger(level=_level),
            logRequests=logRequests,
            logResponses=logResponses)
        self.httpSrv.install_handler(self.xmlRpcDispatcher)
        if status:
            sh = status_handler.status_extension(
                [self.httpSrv, self.xmlRpcDispatcher])
            self.httpSrv.install_handler(sh)
Example #5
0
# You may comment out any of these, or add more of your own.  The only
# requirement for a 'status-reporting' object is that it have a method
# 'status' that will return a producer, which will generate an HTML
# description of the status of the object.

status_objects = [
        hs,
        ftp,
        ms,
        cs,
        rs,
        lg
        ]

# Create a status handler.  By default it binds to the URI '/status'...
sh = status_handler.status_extension(status_objects)
# ... and install it on the web server.
hs.install_handler (sh)

# become 'nobody'
if os.name == 'posix':
    if hasattr (os, 'seteuid'):
        import pwd
        [uid, gid] = pwd.getpwnam ('nobody')[2:4]
        os.setegid (gid)
        os.seteuid (uid)

# Finally, start up the server loop!  This loop will not exit until
# all clients and servers are closed.  You may cleanly shut the system
# down by sending SIGINT (a.k.a. KeyboardInterrupt).
asyncore.loop()
Example #6
0
# You may comment out any of these, or add more of your own.  The only
# requirement for a 'status-reporting' object is that it have a method
# 'status' that will return a producer, which will generate an HTML
# description of the status of the object.

status_objects = [
        hs,
        ftp,
        ms,
        cs,
        rs,
        lg
        ]

# Create a status handler.  By default it binds to the URI '/status'...
sh = status_handler.status_extension(status_objects)
# ... and install it on the web server.
hs.install_handler (sh)

# become 'nobody'
if os.name == 'posix':
    if hasattr (os, 'seteuid'):
        import pwd
        [uid, gid] = pwd.getpwnam ('nobody')[2:4]
        os.setegid (gid)
        os.seteuid (uid)

# Finally, start up the server loop!  This loop will not exit until
# all clients and servers are closed.  You may cleanly shut the system
# down by sending SIGINT (a.k.a. KeyboardInterrupt).
asyncore.loop()