本文整理汇总了Python中cherrypy.wsgiserver.CherryPyWSGIServer.ssl_certificate方法的典型用法代码示例。如果您正苦于以下问题:Python CherryPyWSGIServer.ssl_certificate方法的具体用法?Python CherryPyWSGIServer.ssl_certificate怎么用?Python CherryPyWSGIServer.ssl_certificate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cherrypy.wsgiserver.CherryPyWSGIServer
的用法示例。
在下文中一共展示了CherryPyWSGIServer.ssl_certificate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options, settings):
"""
Start CherryPy server
"""
if options['daemonize'] and options['server_user'] and options['server_group']:
#ensure the that the daemon runs as specified user
change_uid_gid(options['server_user'], options['server_group'])
from cherrypy.wsgiserver import CherryPyWSGIServer as Server
from django.core.handlers.wsgi import WSGIHandler
from django.core.servers.basehttp import AdminMediaHandler
app = AdminMediaHandler(WSGIHandler())
server = Server(
(options['host'], int(options['port'])),
app,
int(options['threads']),
options['server_name']
)
if options['ssl_certificate'] and options['ssl_private_key']:
server.ssl_certificate = options['ssl_certificate']
server.ssl_private_key = options['ssl_private_key']
try:
server.start()
except KeyboardInterrupt:
server.stop()
示例2: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options):
"""
Start CherryPy server. DEPRICATED>>>>
Saving this function for future readers to use.
"""
if options['daemonize'] and options['server_user'] and options['server_group']:
#ensure the that the daemon runs as specified user
change_uid_gid(options['server_user'], options['server_group'])
from cherrypy.wsgiserver import CherryPyWSGIServer as Server
from django.core.handlers.wsgi import WSGIHandler
server = Server(
(options['host'], int(options['port'])),
WSGIHandler(),
int(options['threads']),
options['server_name']
)
if options['ssl_certificate'] and options['ssl_private_key']:
server.ssl_certificate = options['ssl_certificate']
server.ssl_private_key = options['ssl_private_key']
try:
server.start()
except KeyboardInterrupt:
server.stop()
示例3: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options):
"""
Start CherryPy server
"""
if options['daemonize'] and options['server_user'] and options['server_group']:
#ensure the that the daemon runs as specified user
change_uid_gid(options['server_user'], options['server_group'])
try:
from cherrypy.wsgiserver import CherryPyWSGIServer as Server
except ImportError:
try:
from wsgiserver import CherryPyWSGIServer as Server
except ImportError:
from cpserver.wsgiserver import CherryPyWSGIServer as Server
from django.core.handlers.wsgi import WSGIHandler
server = Server(
(options['host'], int(options['port'])),
WSGIHandler(),
int(options['threads']),
options['server_name'],
request_queue_size=int(options['request_queue_size'])
)
if options['ssl_certificate'] and options['ssl_private_key']:
server.ssl_certificate = options['ssl_certificate']
server.ssl_private_key = options['ssl_private_key']
try:
server.start()
except KeyboardInterrupt:
server.stop()
示例4: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options):
"""
Start CherryPy server
"""
if options['daemonize'] and options['server_user'] and options['server_group']:
#ensure the that the daemon runs as specified user
change_uid_gid(options['server_user'], options['server_group'])
from cherrypy.wsgiserver import CherryPyWSGIServer as Server
import cherrypy
from django.core.handlers.wsgi import WSGIHandler
if options['static']:
# If we want a static directory, wrap the regular app
# with cherrypy.tree.mount() to serve static dir.
app = WSGIHandler()
cherrypy.config.update({'global': {'log.screen': True}})
conf = {
'/' : {
'tools.wsgiapp.on': True,
'tools.wsgiapp.app': app
},
'/static' : {
'tools.staticdir.on': True,
'tools.staticdir.dir': options['static']
}
}
full_app = cherrypy.tree.mount(app, '/', config=conf)
else:
full_app = WSGIHandler()
server = Server(
(options['host'], int(options['port'])),
full_app,
int(options['threads']),
options['server_name']
)
if options['ssl_certificate'] and options['ssl_private_key']:
server.ssl_certificate = options['ssl_certificate']
server.ssl_private_key = options['ssl_private_key']
try:
server.start()
except KeyboardInterrupt:
server.stop()
示例5: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server (options):
if options['daemonize']:
if options['server_user'] and options['server_group']:
change_uid_gid(options['server_user'], options['server_group'])
if options['workdir']:
become_daemon(our_home_dir=options['workdir'])
else:
become_daemon()
fp = open(options['pidfile'], 'w')
fp.write("%d\n" % os.getpid())
fp.close()
d = WSGIPathInfoDispatcher({'/static': static, '/': WSGIHandler()})
SERVER = Server(
(options['host'], int(options['port'])),
d,
numthreads=int(options['threads']),
max=int(options['threads']),
server_name=options['server_name'],
shutdown_timeout = int(options['shutdown_timeout']),
request_queue_size = int(options['request_queue_size'])
)
if options['ssl_certificate'].lower() == 'none' or options['ssl_private_key'].lower() == 'none':
pass
else:
if not os.path.exists(options['ssl_certificate']) or not os.path.exists(options['ssl_private_key']):
if options['ssl_certificate'] == settings.SERVER_CERT and options['ssl_private_key'] == settings.SERVER_KEY:
generate_cert()
else:
raise Exception('Invalid Certificate or Key Path')
SERVER.ssl_certificate = options['ssl_certificate']
SERVER.ssl_private_key = options['ssl_private_key']
try:
SERVER.start()
except KeyboardInterrupt:
SERVER.stop()
示例6: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options):
"""
Start CherryPy server
Want SSL support?
a. The new (3.1 or 3.2) way: Just set server.ssl_adapter to an SSLAdapter instance.
b. The old way (deprecated way) is to set these attributes:
server.ssl_certificate = <filename>
server.ssl_private_key = <filename>
But this is the only way from the management command line
in the future I may need to adapt this to use a server.ssl_adapter
"""
if options['daemonize'] and options['server_user'] and options['server_group']:
# ensure the that the daemon runs as specified user
change_uid_gid(options['server_user'], options['server_group'])
# from django_wsgiserver.wsgiserver import CherryPyWSGIServer
from cherrypy.wsgiserver import CherryPyWSGIServer
from django.core.handlers.wsgi import WSGIHandler
app = WSGIHandler()
# if options['adminserve']: # serve the admin media too
# AdminMediaHandler is middleware for local use
# import django.core.servers.basehttp
# app = django.core.servers.basehttp.AdminMediaHandler(app)
server = CherryPyWSGIServer(
(options['host'], int(options['port'])),
app,
int(options['threads']),
options['server_name']
)
if options['ssl_certificate'] and options['ssl_private_key']:
server.ssl_certificate = options['ssl_certificate']
server.ssl_private_key = options['ssl_private_key']
try:
logging.debug('starting server with options:\n%s' % pformat(options))
server.start()
except KeyboardInterrupt:
server.stop()
示例7: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options):
"""
Start CherryPy server
"""
if options["daemonize"] and options["server_user"] and options["server_group"]:
# ensure the that the daemon runs as specified user
change_uid_gid(options["server_user"], options["server_group"])
from cherrypy.wsgiserver import CherryPyWSGIServer as Server
from django.core.handlers.wsgi import WSGIHandler
server = Server(
(options["host"], int(options["port"])), WSGIHandler(), int(options["threads"]), options["server_name"]
)
if options["ssl_certificate"] and options["ssl_private_key"]:
server.ssl_certificate = options["ssl_certificate"]
server.ssl_private_key = options["ssl_private_key"]
try:
server.start()
except KeyboardInterrupt:
server.stop()
示例8: main
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def main():
cherrypy.config.update({'error_page.404': err_pages.err_404})
# = Daemonizer(cherrypy.engine)
#d.subscribe()
AppDispatcher = WSGIPathInfoDispatcher({'/': cherrypy.tree.mount(Main(),'/',config=config),
#'/login': LoginApp,
'/file': FileApp
})
server = CherryPyWSGIServer(
(settings['ip'], settings['port']),
AppDispatcher,
server_name=render('__server_info__'),
numthreads=100,
request_queue_size=70
)
serverSSL = None
if settings.has_key('ssl_certificate') and settings.has_key('ssl_private_key'):
if os.path.exists(settings['ssl_certificate']) and os.path.exists(settings['ssl_private_key']):
serverSSL = CherryPyWSGIServer(
(settings['ip'], settings['sslport']),
AppDispatcher,
server_name=render('__server_info__'),
numthreads=100,
request_queue_size=70
)
serverSSL.ssl_certificate = settings['ssl_certificate']
serverSSL.ssl_private_key = settings['ssl_private_key']
s2 = ServerAdapter(cherrypy.engine, serverSSL)
s2.subscribe()
s1 = ServerAdapter(cherrypy.engine, server)
s1.subscribe()
check_create_db(settings['db_name'],settings['db_name'])
cherrypy.engine.timeout_monitor.unsubscribe()
cherrypy.engine.start()
cherrypy.engine.block()
示例9: start_server
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
def start_server(options):
"""
Start CherryPy server
"""
if options['daemonize'] and options['server_user'] and options['server_group']:
#ensure the that the daemon runs as specified user
change_uid_gid(options['server_user'], options['server_group'])
from cherrypy.wsgiserver import CherryPyWSGIServer as Server
from django.core.handlers.wsgi import WSGIHandler
import cherrypy
pth = os.path.join(os.path.abspath('..'), 'media')
pth_ext = os.path.exists(pth)
#MEDIA_ROOT = '/var/projects/%s:%s/media/' % (options['server_name'], int(options['port']) + 1)
'''
try:
if pth_ext:
MEDIA_ROOT = pth
else:
print "Media path is %s" % MEDIA_ROOT
except:
print "Could not create dynamic MEDIA_ROOT path"
print "%s is missing" % pth
cherrypy.config['tools.staticdir.on']= True
cherrypy.config['tools.staticdir.dir'] = pth
'''
server = Server(
(options['host'], int(options['port'])),
WSGIHandler(),
int(options['threads']),
options['server_name']
)
if options['ssl_certificate'] and options['ssl_private_key']:
server.ssl_certificate = options['ssl_certificate']
server.ssl_private_key = options['ssl_private_key']
#'tools.staticdir.on': True,
#'tools.staticdir.dir': os.path.join(os.path.abspath('..'), 'media'),
try:
p('Starting server')
server.start()
#media_server.start()
#from cherrypy.process.servers import ServerAdapter
#s1 = ServerAdapter(cherrypy.engine, server)
#s2 = ServerAdapter(cherrypy.engine, media_server)
#s1.subscribe()
#s2.subscribe()
#cherrypy.engine.start()
except KeyboardInterrupt:
p('Stopping server')
server.stop()
示例10: _
# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_certificate [as 别名]
sslAdapter.certbase = certbase
server.ssl_adapter = sslAdapter
server.certbase = certbase
server.serv_certbase = serv_certbase
server.rights = rights
server.group_rights = group_rights
server.sids = sids
server.pids = pids
server.sids_file = sids_file
server.pids_file = pids_file
server.data_path = data_path
server.cert_path = cert_path
server.ssl_certificate = cert
server.ssl_private_key = key
from OpenSSL.SSL import Error as SSLError
import socket
try:
if args.pidfile:
try:
open(args.pidfile,"w").write(str(os.getpid()))
except OSError:
sys.stderr.write(_("failed to create PID file %s") \
%args.pidfile+"\n")
sys.exit(1)
# For cleaning of sessions at server reboot
from clean import clean
clean(sids_file, pids_file, sids_pids, sids, pids)
print _("Server started")