def __init__(self): pwd = os.getcwd() CONFIG_FILE = opj(pwd, "conf/webserver.conf") from optparse import OptionParser from webconfig import webconfigManager parser = OptionParser(version="1.0", description="Web Server of global system resource planned") parser.add_option("-c", "--config", type="string", dest="config_file", help="Config file", default=CONFIG_FILE) options, arguments = parser.parse_args() if "config_path" in options.__dict__: if options.__dict__["config_path"] != CONFIG_PATH: CONFIG_PATH = options.__dict__["config_path"] webconfig = webconfigManager(CONFIG_FILE) if webconfig["globals"]["mode"] == "external": import local from remote.webdispatcher import RemoteDispatcher as Dispatcher self._dispatcher = Dispatcher( local.manager.Manager.__metaclass__.__list_managers__, webconfig["globals"]["gsrp_root"], webconfig["globals"]["mode"], ) self._dispatcher.app._connect( webconfig["globals"]["interface"], webconfig[webconfig["globals"]["interface"]] ) else: sys.path.insert(1, webconfig["globals"]["gsrp_root"]) from remote.webdispatcher import RemoteDispatcher as Dispatcher import local import managers self._dispatcher = Dispatcher( dict( list(managers.manager.MetaManager.__list_managers__.items()) + list(local.manager.MetaManager.__list_managers__.items()) ), webconfig["globals"]["gsrp_root"], "internal", ) self._dispatcher.env = env
def __init__(self): pwd = os.getcwd() CONFIG_FILE = opj(pwd,'conf/webserver.conf') from optparse import OptionParser from webconfig import webconfigManager parser = OptionParser(version = '1.0', description = 'Web Server of global system resource planned') parser.add_option('-c','--config',type='string', dest = 'config_file',help ='Config file', default = CONFIG_FILE) options,arguments=parser.parse_args() if 'config_path' in options.__dict__: if options.__dict__['config_path'] != CONFIG_PATH: CONFIG_PATH = options.__dict__['config_path'] webconfig = webconfigManager(CONFIG_FILE) if webconfig['globals']['mode'] == 'external': import local from remote.webdispatcher import RemoteDispatcher as Dispatcher self._dispatcher = Dispatcher(managers=local.manager.MetaManager.__list_managers__, gsrp_root=webconfig['globals']['gsrp_root'], mode=webconfig['globals']['mode'], service=webconfig['globals']['interface'],options=webconfig[webconfig['globals']['interface']]) #self._dispatcher._connect(webconfig['globals']['interface'], webconfig[webconfig['globals']['interface']]) else: sys.path.insert(1,webconfig['globals']['gsrp_root']) from remote.webdispatcher import RemoteDispatcher as Dispatcher import local import managers self._dispatcher = Dispatcher(dict(list(managers.manager.MetaManager.__list_managers__.items()) + list(local.manager.MetaManager.__list_managers__.items())),webconfig['globals']['gsrp_root'],'internal') self._dispatcher.env = env
class Root(object): def __init__(self): pwd = os.getcwd() CONFIG_FILE = opj(pwd,'conf/webserver.conf') from optparse import OptionParser from webconfig import webconfigManager parser = OptionParser(version = '1.0', description = 'Web Server of global system resource planned') parser.add_option('-c','--config',type='string', dest = 'config_file',help ='Config file', default = CONFIG_FILE) options,arguments=parser.parse_args() if 'config_path' in options.__dict__: if options.__dict__['config_path'] != CONFIG_PATH: CONFIG_PATH = options.__dict__['config_path'] webconfig = webconfigManager(CONFIG_FILE) if webconfig['globals']['mode'] == 'external': import local from remote.webdispatcher import RemoteDispatcher as Dispatcher self._dispatcher = Dispatcher(managers=local.manager.MetaManager.__list_managers__, gsrp_root=webconfig['globals']['gsrp_root'], mode=webconfig['globals']['mode'], service=webconfig['globals']['interface'],options=webconfig[webconfig['globals']['interface']]) #self._dispatcher._connect(webconfig['globals']['interface'], webconfig[webconfig['globals']['interface']]) else: sys.path.insert(1,webconfig['globals']['gsrp_root']) from remote.webdispatcher import RemoteDispatcher as Dispatcher import local import managers self._dispatcher = Dispatcher(dict(list(managers.manager.MetaManager.__list_managers__.items()) + list(local.manager.MetaManager.__list_managers__.items())),webconfig['globals']['gsrp_root'],'internal') self._dispatcher.env = env @cherrypy.expose def index(self): if cherrypy.request.method == "GET": #print('headers:',cherrypy.request.headers) print('Logging:',self._dispatcher._execute(['web.db.auth.Login'],{'database':'tst','user':'******','password':'******','host':'localhost','port':5432})) return env.get_template("web/index.html").render() @cherrypy.expose @cherrypy.tools.gzip() @cherrypy.tools.json_in() @cherrypy.tools.json_out() def auth(self): if cherrypy.request.method == "POST": RLOCK = threading.RLock() RLOCK.acquire() if is_xhr(): jq = cherrypy.request.json area = jq['args'][0].split('.')[0] #print('headers:',cherrypy.request.headers) #print('JQ: %s' % jq) if area == 'auth': if 'args' in jq and 'kwargs' in jq: return self._dispatcher._execute(jq[u'args'], jq[u'kwargs']) elif 'args' in jq: return self._dispatcher._execute(jq[u'args']) else: raise AttributeError elif area == 'app': herrypy.lib.cptools.redirect(url='/web', internal=True, debug=False) elif area == 'dbm': herrypy.lib.cptools.redirect(url='dbm', internal=True, debug=False) else: raise KeyError('Area must be in %s present %s' % ("'app','auth','dbm'",area)) else: print('HEADERS:',cherrypy.request.headers) print('JSON:',cherrypy.request.json) RLOCK.release() @cherrypy.expose @cherrypy.tools.gzip() @cherrypy.tools.json_in() @cherrypy.tools.json_out() def db(self): if cherrypy.request.method == "POST": RLOCK = threading.RLock() RLOCK.acquire() if is_xhr(): jq = cherrypy.request.json area = jq['args'][0].split('.')[0] #print('headers:',cherrypy.request.headers) #print('JQ: %s' % jq) if area == 'dbm': if 'args' in jq and 'kwargs' in jq: return self._dispatcher._execute(jq[u'args'], jq[u'kwargs']) elif 'args' in jq: return self._dispatcher._execute(jq[u'args']) else: raise AttributeError elif area == 'app': herrypy.lib.cptools.redirect(url='/web', internal=True, debug=False) elif area == 'auth': herrypy.lib.cptools.redirect(url='auth', internal=True, debug=False) else: raise KeyError('Area must be in %s present %s' % ("'app','auth','dbm'",area)) else: print('HEADERS:',cherrypy.request.headers) print('JSON:',cherrypy.request.json) RLOCK.release() @cherrypy.expose @cherrypy.tools.gzip() @cherrypy.tools.json_in() @cherrypy.tools.json_out() def web(self): if cherrypy.request.method == "POST": RLOCK = threading.RLock() RLOCK.acquire() if is_xhr(): jq = cherrypy.request.json area = jq['args'][0].split('.')[0] #print('headers:',cherrypy.request.headers) #print('JQ: %s' % jq) if area == 'app': if 'args' in jq and 'kwargs' in jq: return self._dispatcher._execute(jq[u'args'], jq[u'kwargs']) elif 'args' in jq: return self._dispatcher._execute(jq[u'args']) else: raise AttributeError elif area == 'auth': herrypy.lib.cptools.redirect(url='/auth', internal=True, debug=False) elif area == 'dbm': herrypy.lib.cptools.redirect(url='dbm', internal=True, debug=False) else: raise KeyError('Area must be in %s present %s' % ("'app','auth','dbm'",area)) else: print('HEADERS:',cherrypy.request.headers) print('JSON:',cherrypy.request.json) RLOCK.release()
class Root(object): def __init__(self): pwd = os.getcwd() CONFIG_FILE = opj(pwd, "conf/webserver.conf") from optparse import OptionParser from webconfig import webconfigManager parser = OptionParser(version="1.0", description="Web Server of global system resource planned") parser.add_option("-c", "--config", type="string", dest="config_file", help="Config file", default=CONFIG_FILE) options, arguments = parser.parse_args() if "config_path" in options.__dict__: if options.__dict__["config_path"] != CONFIG_PATH: CONFIG_PATH = options.__dict__["config_path"] webconfig = webconfigManager(CONFIG_FILE) if webconfig["globals"]["mode"] == "external": import local from remote.webdispatcher import RemoteDispatcher as Dispatcher self._dispatcher = Dispatcher( local.manager.Manager.__metaclass__.__list_managers__, webconfig["globals"]["gsrp_root"], webconfig["globals"]["mode"], ) self._dispatcher.app._connect( webconfig["globals"]["interface"], webconfig[webconfig["globals"]["interface"]] ) else: sys.path.insert(1, webconfig["globals"]["gsrp_root"]) from remote.webdispatcher import RemoteDispatcher as Dispatcher import local import managers self._dispatcher = Dispatcher( dict( list(managers.manager.MetaManager.__list_managers__.items()) + list(local.manager.MetaManager.__list_managers__.items()) ), webconfig["globals"]["gsrp_root"], "internal", ) self._dispatcher.env = env @cherrypy.expose def index(self): if cherrypy.request.method == "GET": return env.get_template("web-j.html").render() @cherrypy.expose @cherrypy.tools.gzip() @cherrypy.tools.json_in() @cherrypy.tools.json_out() def web(self): if cherrypy.request.method == "POST": if is_xhr(): jq = cherrypy.request.json print("JQ: %s" % jq) if "args" in jq and "kwargs" in jq: return self._dispatcher._execute(jq[u"args"], jq[u"kwargs"]) elif "args" in jq: return self._dispatcher._execute(jq[u"args"]) else: raise AttributeError @cherrypy.expose def test(self): if cherrypy.request.method == "GET": form = DropTablespace() return env.get_template("test-j.html").render(form=form) return tmpl.render(form=form) elif cherrypy.request.method == "POST": print(dir(cherrypy.request))