Convert port number into config and fix rpc_paths for XML-RPC
This commit is contained in:
+8
-3
@@ -8,11 +8,11 @@ class ConfigManager(object):
|
||||
self.options = {
|
||||
'interface': '',
|
||||
'netrpc': True,
|
||||
'netport': '8070',
|
||||
'netport': 8070,
|
||||
'xmlrpc': False,
|
||||
'xmlport': '8069',
|
||||
'xmlport': 8069,
|
||||
'webdav': False,
|
||||
'webdavport': '8080',
|
||||
'webdavport': 8080,
|
||||
'db_host': False,
|
||||
'db_port': False,
|
||||
'db_name': False,
|
||||
@@ -124,6 +124,11 @@ class ConfigManager(object):
|
||||
value = True
|
||||
if value == 'False' or value == 'false':
|
||||
value = False
|
||||
if name in ('netport', 'xmlport', 'webdavport'):
|
||||
try:
|
||||
value = int(value)
|
||||
except:
|
||||
continue
|
||||
self.options[name] = value
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
+1
-15
@@ -12,17 +12,6 @@ import traceback
|
||||
import select
|
||||
import BaseHTTPServer
|
||||
from trytond.protocols.sslsocket import SSLSocket
|
||||
|
||||
_SERVICE = {}
|
||||
_GROUP = {}
|
||||
_RES = {}
|
||||
|
||||
LOG_DEBUG = 'debug'
|
||||
LOG_INFO = 'info'
|
||||
LOG_WARNING = 'warn'
|
||||
LOG_ERROR = 'error'
|
||||
LOG_CRITICAL = 'critical'
|
||||
|
||||
from config import CONFIG
|
||||
|
||||
# convert decimal to float before marshalling:
|
||||
@@ -65,7 +54,7 @@ class GenericXMLRPCRequestHandler:
|
||||
|
||||
class SimpleXMLRPCRequestHandler(GenericXMLRPCRequestHandler,
|
||||
SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
|
||||
rpc_paths = map(lambda s: '/xmlrpc/%s' % s, _SERVICE)
|
||||
rpc_paths = None
|
||||
|
||||
|
||||
class SecureXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||
@@ -124,9 +113,6 @@ class HttpDaemon(threading.Thread):
|
||||
server_class = SimpleThreadedXMLRPCServer6
|
||||
self.server = server_class((interface, port), handler_class, 0)
|
||||
|
||||
def attach(self, path, gateway):
|
||||
pass
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
if os.name != 'nt':
|
||||
|
||||
+14
-40
@@ -142,54 +142,28 @@ class TrytonServer(object):
|
||||
|
||||
# Launch Server
|
||||
if CONFIG['xmlrpc']:
|
||||
interface = CONFIG["interface"]
|
||||
try:
|
||||
port = int(CONFIG["xmlport"])
|
||||
except:
|
||||
self.logger.error("invalid port '%s'!" % (CONFIG["xmlport"],))
|
||||
logging.shutdown()
|
||||
sys.exit(1)
|
||||
|
||||
httpd = netsvc.HttpDaemon(interface, port, CONFIG['secure_xmlrpc'])
|
||||
|
||||
xml_gw = netsvc.XmlRpc.RpcGateway('web-service')
|
||||
httpd.attach("/xmlrpc", xml_gw )
|
||||
httpd = netsvc.HttpDaemon(CONFIG['interface'], CONFIG['xmlport'],
|
||||
CONFIG['secure_xmlrpc'])
|
||||
logging.getLogger("web-service").info(
|
||||
"starting XML-RPC" + \
|
||||
(CONFIG['secure_xmlrpc'] and ' Secure' or '') + \
|
||||
" services, port " + str(port))
|
||||
"starting XML-RPC%s protocol, port %d" % \
|
||||
(CONFIG['secure_xmlrpc'] and ' Secure' or '',
|
||||
CONFIG['xmlport']))
|
||||
|
||||
if CONFIG['netrpc']:
|
||||
interface = CONFIG["interface"]
|
||||
try:
|
||||
port = int(CONFIG["netport"])
|
||||
except:
|
||||
self.logger.error("invalid port '%s'!" % (CONFIG["netport"],))
|
||||
logging.shutdown()
|
||||
sys.exit(1)
|
||||
|
||||
netrpcd = NetRPCServerThread(interface, port,
|
||||
netrpcd = NetRPCServerThread(CONFIG['interface'], CONFIG['netport'],
|
||||
CONFIG['secure_netrpc'])
|
||||
logging.getLogger("web-service").info(
|
||||
"starting netrpc" + \
|
||||
(CONFIG['secure_netrpc'] and ' Secure' or '') + \
|
||||
" service, port " + str(port))
|
||||
"starting NetRPC%s protocol, port %d" % \
|
||||
(CONFIG['secure_netrpc'] and ' Secure' or '',
|
||||
CONFIG['netport']))
|
||||
|
||||
if CONFIG['webdav']:
|
||||
interface = CONFIG['interface']
|
||||
try:
|
||||
port = int(CONFIG['webdavport'])
|
||||
except:
|
||||
self.logger.error("invalid port '%s'!" % (CONFIG['webdavport'],))
|
||||
logging.shutdown()
|
||||
sys.exit(1)
|
||||
|
||||
webdavd = netsvc.WebDAVServerThread(interface, port,
|
||||
CONFIG['secure_webdav'])
|
||||
webdavd = netsvc.WebDAVServerThread(CONFIG['interface'],
|
||||
CONFIG['webdavport'], CONFIG['secure_webdav'])
|
||||
logging.getLogger("web-service").info(
|
||||
'starting webdav' + \
|
||||
(CONFIG['secure_webdav'] and ' Secure' or '') + \
|
||||
' service, port ' + str(port))
|
||||
"starting WebDAV%s protocol, port %d" % \
|
||||
(CONFIG['secure_webdav'] and ' Secure' or '',
|
||||
CONFIG['webdavport']))
|
||||
|
||||
threads = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user