예제 #1
0
def testTask(site_name=None, table_name=None, command=None, parameters=None):
    from gnr.web.gnrwsgisite import GnrWsgiSite
    from webob import Request, Response
    
    site = GnrWsgiSite(site_name)
    request = Request.blank('/sys/heartbeat')
    response = Response()
    page = site.resource_loader(['sys','heartbeat'], request, response)
    site.db.table('sys.task').runTask(dict(table_name=table_name, command=command, parameters=parameters,log_result=None), page=page)
    site.cleanup()
예제 #2
0
def testTask(site_name=None, table_name=None, command=None, parameters=None):
    from gnr.web.gnrwsgisite import GnrWsgiSite
    from webob import Request, Response

    site = GnrWsgiSite(site_name)
    request = Request.blank('/sys/heartbeat')
    response = Response()
    page = site.resource_loader(['sys', 'heartbeat'], request, response)
    site.db.table('sys.task').runTask(dict(table_name=table_name,
                                           command=command,
                                           parameters=parameters,
                                           log_result=None),
                                      page=page)
    site.cleanup()
예제 #3
0
 def __init__(self, site_name=None):
     self.options = attrDict()
     self.load_gnr_config()
     self.set_environment()
     self.site_name = site_name
     if self.site_name:
         if not self.gnr_config:
             raise ServerException('Error: no ~/.gnr/ or /etc/gnr/ found')
         self.site_path, self.site_template = self.site_name_to_path(
             self.site_name)
         self.site_script = os.path.join(self.site_path, 'root.py')
         if not os.path.isfile(self.site_script):
             raise ServerException(
                 'Error: no root.py in the site provided (%s)' %
                 self.site_name)
     else:
         self.site_script = os.path.join('.', 'root.py')
     self.init_options()
     self.gnr_site = GnrWsgiSite(self.site_script,
                                 site_name=self.site_name,
                                 _config=self.siteconfig,
                                 _gnrconfig=self.gnr_config,
                                 counter=self.options.get('counter'),
                                 noclean=self.options.get('noclean'),
                                 options=self.options)
예제 #4
0
 def __init__(self, site_name=None):
     self.options = attrDict()
     self.gnr_config = getGnrConfig(set_environment=True)
     self.config_path = gnrConfigPath()
     self.site_name = site_name
     if self.site_name:
         if not self.gnr_config:
             raise ServerException('Error: no ~/.gnr/ or /etc/gnr/ found')
         self.site_handler = getSiteHandler(site_name)
         self.site_path = self.site_handler['site_path']
         self.site_template = self.site_handler['site_template']
         self.site_script = self.site_handler['site_script']
         if not os.path.isfile(self.site_script):
             raise ServerException(
                 'Error: no root.py in the site provided (%s)' %
                 self.site_name)
     else:
         self.site_script = os.path.join('.', 'root.py')
     self.init_options()
     self.gnr_site = GnrWsgiSite(self.site_script,
                                 site_name=self.site_name,
                                 _config=self.siteconfig,
                                 _gnrconfig=self.gnr_config,
                                 counter=self.options.get('counter'),
                                 noclean=self.options.get('noclean'),
                                 options=self.options)
예제 #5
0
 def serve(self):
     try:
         gnrServer = GnrWsgiSite(self.site_script,
                                 site_name=self.site_name,
                                 _config=self.siteconfig,
                                 _gnrconfig=self.gnr_config,
                                 counter=getattr(self.options, 'counter',
                                                 None),
                                 noclean=self.options.noclean,
                                 options=self.options)
         GnrReloaderMonitor.add_reloader_callback(
             gnrServer.on_reloader_restart)
         httpserver.serve(gnrServer,
                          host=self.options.host,
                          port=self.options.port)
     except (SystemExit, KeyboardInterrupt), e:
         if self.options.verbose > 1:
             raise
         if str(e):
             msg = ' ' + str(e)
         else:
             msg = ''
         print 'Exiting%s (-v to see traceback)' % msg
예제 #6
0
파일: root.py 프로젝트: poppogbr/genropy
import sys

sys.stdout = sys.stderr
from gnr.web.gnrwsgisite import GnrWsgiSite

site = GnrWsgiSite(__file__)

def application(environ, start_response):
    return site(environ, start_response)


if __name__ == '__main__':
    from gnr.web.server import NewServer

    server = NewServer(__file__)
    server.run()