示例#1
0
def getSiteHandler(site_name, gnr_config=None):
    gnr_config = gnr_config or getGnrConfig()
    path_list = []
    gnrenv = gnr_config['gnr.environment_xml']
    sites = gnrenv['sites']
    projects = gnrenv['projects']
    if sites:
        sites = sites.digest('#a.path,#a.site_template')
        path_list.extend([(expandpath(path), site_template) for path, site_template in sites 
                                                            if os.path.isdir(expandpath(path))])
    if projects:
        projects = projects.digest('#a.path,#a.site_template') 
        projects = [(expandpath(path), template) for path, template in projects
                                                 if os.path.isdir(expandpath(path))]
        for project_path, site_template in projects:
            sites = glob.glob(os.path.join(project_path, '*/sites'))
            path_list.extend([(site_path, site_template) for site_path in sites])
    for path, site_template in path_list:
        site_path = os.path.join(path, site_name)
        if os.path.isdir(site_path):
            site_script = os.path.join(site_path, 'root.py')
            if not os.path.isfile(site_script):
                site_script = None
            return dict(site_path=site_path,
                            site_template=site_template,
                            site_script = site_script)
示例#2
0
def get_config_path():
    if os.environ.has_key('VIRTUAL_ENV'):
        config_path = expandpath(os.path.join(os.environ['VIRTUAL_ENV'],'etc','gnr'))
    elif sys.platform == 'win32':
        config_path = '~\gnr'
    else:
        config_path = '~/.gnr'
    config_path  = expandpath(config_path)
    return config_path
示例#3
0
 def load_gnr_config(self):
     """add???
     
     :returns: add???
     """
     config_path = expandpath('~/.gnr')
     if os.path.isdir(config_path):
         return Bag(config_path)
     config_path = expandpath(os.path.join('/etc/gnr'))
     if os.path.isdir(config_path):
         return Bag(config_path)
     return Bag()
示例#4
0
 def load_gnr_config(self):
     """Load the gnr configuration. Return a Bag with the gnr configuration path"""
     home_config_path = expandpath('~/.gnr')
     global_config_path = expandpath(os.path.join('/etc/gnr'))
     if os.path.isdir(home_config_path):
         config = Bag(home_config_path)
     elif os.path.isdir(global_config_path):
         config = Bag(global_config_path)
     else:
         config = Bag()
     self.set_environment(config)
     return config
示例#5
0
 def load_gnr_config(self):
     """Load the gnr configuration. Return a Bag with the gnr configuration path"""
     home_config_path = expandpath('~/.gnr')
     global_config_path = expandpath(os.path.join('/etc/gnr'))
     if os.path.isdir(home_config_path):
         config = Bag(home_config_path)
     elif os.path.isdir(global_config_path):
         config = Bag(global_config_path)
     else:
         config = Bag()
     self.set_environment(config)
     return config
示例#6
0
def gnrConfigPath():
    if os.environ.has_key('VIRTUAL_ENV'):
        config_path = expandpath(os.path.join(os.environ['VIRTUAL_ENV'],'etc','gnr'))
    elif sys.platform == 'win32':
        config_path = '~\gnr'
    else:
        config_path = '~/.gnr'
    config_path  = expandpath(config_path)
    if os.path.isdir(config_path):
        return config_path
    config_path = expandpath('/etc/gnr')
    if os.path.isdir(config_path):
        return config_path
示例#7
0
def gnrConfigPath():
    if os.environ.has_key('VIRTUAL_ENV'):
        config_path = expandpath(
            os.path.join(os.environ['VIRTUAL_ENV'], 'etc', 'gnr'))
    elif sys.platform == 'win32':
        config_path = '~\gnr'
    else:
        config_path = '~/.gnr'
    config_path = expandpath(config_path)
    if os.path.isdir(config_path):
        return config_path
    config_path = expandpath('/etc/gnr')
    if os.path.isdir(config_path):
        return config_path
示例#8
0
 def load_gnr_config(self):
     """add???
     
     :returns: add???
     """
     home_config_path = expandpath('~/.gnr')
     global_config_path = expandpath(os.path.join('/etc/gnr'))
     if os.path.isdir(home_config_path):
         config = Bag(home_config_path)
     elif os.path.isdir(global_config_path):
         config = Bag(global_config_path)
     else:
         config = Bag()
     self.set_environment(config)
     return config
示例#9
0
 def load_gnr_config(self):
     """add???
     
     :returns: add???
     """
     home_config_path = expandpath('~/.gnr')
     global_config_path = expandpath(os.path.join('/etc/gnr'))
     if os.path.isdir(home_config_path):
         config = Bag(home_config_path)
     elif os.path.isdir(global_config_path):
         config = Bag(global_config_path)
     else:
         config = Bag()
     self.set_environment(config)
     return config
示例#10
0
    def find_webtools(self):
        """add???"""
        def isgnrwebtool(cls):
            return inspect.isclass(cls) and issubclass(
                cls, BaseWebtool) and cls is not BaseWebtool

        tools = {}
        webtool_pathlist = []
        if 'webtools' in self.gnr_config['gnr.environment_xml']:
            for path in self.gnr_config['gnr.environment_xml'].digest(
                    'webtools:#a.path'):
                webtool_pathlist.append(expandpath(path))
        for package in self.gnrapp.packages.values():
            webtool_pathlist.append(
                os.path.join(package.packageFolder, 'webtools'))
        project_resource_path = os.path.join(self.site_path, '..', '..',
                                             'webtools')
        webtool_pathlist.append(os.path.normpath(project_resource_path))
        for path in webtool_pathlist:
            if not os.path.isdir(path):
                continue
            for tool_module in os.listdir(path):
                if tool_module.endswith('.py'):
                    module_path = os.path.join(path, tool_module)
                    try:
                        module = gnrImport(module_path, avoidDup=True)
                        tool_classes = inspect.getmembers(module, isgnrwebtool)
                        tool_classes = [(name.lower(), value)
                                        for name, value in tool_classes]
                        tools.update(dict(tool_classes))
                    except ImportError:
                        pass
        return tools
示例#11
0
 def find_webtools(self):
     """TODO"""
     def isgnrwebtool(cls):
         return inspect.isclass(cls) and issubclass(cls, BaseWebtool) and cls is not BaseWebtool
         
     tools = {}
     webtool_pathlist = []
     if 'webtools' in self.gnr_config['gnr.environment_xml']:
         for path in self.gnr_config['gnr.environment_xml'].digest('webtools:#a.path'):
             webtool_pathlist.append(expandpath(path))
     for package in self.gnrapp.packages.values():
         webtool_pathlist.append(os.path.join(package.packageFolder, 'webtools'))
     project_resource_path = os.path.join(self.site_path, '..', '..', 'webtools')
     webtool_pathlist.append(os.path.normpath(project_resource_path))
     for path in webtool_pathlist:
         if not os.path.isdir(path):
             continue
         for tool_module in os.listdir(path):
             if tool_module.endswith('.py'):
                 module_path = os.path.join(path, tool_module)
                 try:
                     module = gnrImport(module_path, avoidDup=True)
                     tool_classes = inspect.getmembers(module, isgnrwebtool)
                     tool_classes = [(name.lower(), value) for name, value in tool_classes]
                     tools.update(dict(tool_classes))
                 except ImportError:
                     pass
     return tools
示例#12
0
def get_config_path():
    if sys.platform == 'win32':
        config_path = '~\gnr'
    else:
        config_path = '~/.gnr'
    config_path  = expandpath(config_path)
    return config_path
示例#13
0
 def run(self):
     if self.options.stop_daemon:
         return self.stop_daemon()
     self.set_user()
     if not (
     self.options.reload == 'false' or self.options.reload == 'False' or self.options.reload == False or self.options.reload == None):
         if os.environ.get(self._reloader_environ_key):
             if self.options.verbose > 1:
                 print 'Running reloading file monitor'
             gnr_reloader_install(int(self.options.reload_interval))
             menu_path = os.path.join(self.site_path, 'menu.xml')
             site_config_path = os.path.join(self.site_path, 'siteconfig.xml')
             for file_path in (menu_path, site_config_path):
                 if os.path.isfile(file_path):
                     GnrReloaderMonitor.watch_file(file_path)
             config_path = expandpath(self.config_path)
             if os.path.isdir(config_path):
                 for file_path in listdirs(config_path):
                     GnrReloaderMonitor.watch_file(file_path)
         else:
             return self.restart_with_reloader()
     first_run = int(getattr(self.options, 'counter', 0) or 0) == 0
     if self.options.bonjour and first_run:
         self.set_bonjour()
     if self.cmd:
         return self.check_cmd()
     self.check_logfile()
     self.check_pidfile()
     if getattr(self.options, 'daemon', False):
         try:
             self.daemonize()
         except DaemonizeException, ex:
             if self.options.verbose > 0:
                 print str(ex)
             return
示例#14
0
 def path(self, volume, *args, **kwargs):
     vpath = self.volumes.get(volume, volume)
     #print 'volumes',self.volumes,'volume'
     result = expandpath(
         os.path.join(self.site.site_static_dir, vpath, *args))
     #print 'aaa',result
     return result
示例#15
0
 def toXml(self, filename=None):
     if filename:
         filename = expandpath(filename)
     return self.root.toXml(filename=filename,
                            omitRoot=True,
                            autocreate=True,
                            addBagTypeAttr=False,
                            typeattrs=False)
示例#16
0
文件: menu.py 项目: OpenCode/genropy
    def test_7_dir_resolver(self,pane):
        #d = DirectoryResolver(,cacheTime=10,include='*.py', exclude='__*,.*',dropext=True,readOnly=False)()
        pane.data('.store',DirectoryResolver(expandpath('~/sviluppo'),cacheTime=10,
                            include='*.py', exclude='_*,.*',dropext=True,readOnly=False)()
                            )

        ddm = pane.div(height='50px', width='50px', background='lime')
        ddm.menu(action='console.log($1)', modifiers='*', storepath='.store', _class='smallmenu',
                        id='test99menu')
示例#17
0
 def toHtml(self, filename=None):
     """add???
     
     :param filename: add???. Default value is ``None``
     """
     if filename:
         filename = expandpath(filename)
     result = self.root.toHtml()
     return result.toXml(filename=filename, omitRoot=True, autocreate=True)
示例#18
0
 def site_name_to_path(self, site_name):
     path_list = []
     if 'sites' in self.gnr_config['gnr.environment_xml']:
         path_list.extend([(expandpath(path), site_template) for path, site_template in
                           self.gnr_config['gnr.environment_xml.sites'].digest('#a.path,#a.site_template') if
                           os.path.isdir(expandpath(path))])
     if 'projects' in self.gnr_config['gnr.environment_xml']:
         projects = [(expandpath(path), site_template) for path, site_template in
                     self.gnr_config['gnr.environment_xml.projects'].digest('#a.path,#a.site_template') if
                     os.path.isdir(expandpath(path))]
         for project_path, site_template in projects:
             sites = glob.glob(os.path.join(project_path, '*/sites'))
             path_list.extend([(site_path, site_template) for site_path in sites])
     for path, site_template in path_list:
         site_path = os.path.join(path, site_name)
         if os.path.isdir(site_path):
             return site_path, site_template
     raise ServerException(
             'Error: no site named %s found' % site_name)
示例#19
0
 def js_path(self, lib_type='gnr', version='11'):
     """TODO Return the configuration static js path, with *lib_type* and *version* specified
     
     :param lib_type: Genro Javascript library == gnr
     :param version: the Genro Javascript library version related to the Dojo one. The number of Dojo
                     version is written without any dot. E.g: '11' is in place of '1.1'"""
     path = self.gnr_config['gnr.environment_xml.static.js.%s_%s?path' % (lib_type, version)]
     if path:
         path = os.path.join(expandpath(path), 'js')
     return path
示例#20
0
 def toHtml_(self, filepath=None):
     if filepath:
         filepath = expandpath(filepath)
     self.finalize(self.body)
     self.html = self.root.toXml(filename=filepath,
                                 omitRoot=True,
                                 autocreate=True,
                                 forcedTagAttr='tag',
                                 addBagTypeAttr=False, typeattrs=False, self_closed_tags=['meta', 'br', 'img'])
     return self.html
示例#21
0
 def js_path(self, lib_type='gnr', version='11'):
     """add???
     
     :param lib_type: add???. Default value is ``gnr``
     :param version: add???. Default value is ``11``
     :returns: add???
     """
     path = self.gnr_config['gnr.environment_xml.static.js.%s_%s?path' % (lib_type, version)]
     if path:
         path = os.path.join(expandpath(path), 'js')
     return path
示例#22
0
 def js_path(self, lib_type='gnr', version='11'):
     """TODO Return the configuration static js path, with *lib_type* and *version* specified
     
     :param lib_type: Genro Javascript library == gnr
     :param version: the Genro Javascript library version related to the Dojo one. The number of Dojo
                     version is written without any dot. E.g: '11' is in place of '1.1'"""
     path = self.gnr_config['gnr.environment_xml.static.js.%s_%s?path' %
                            (lib_type, version)]
     if path:
         path = os.path.join(expandpath(path), 'js')
     return path
示例#23
0
 def project_repository_name_to_path(self, project_repository_name, strict=True):
     """TODO
     
     :param project_repository_name: TODO
     :param strict: TODO"""
     if not strict or 'gnr.environment_xml.projects.%s' % project_repository_name in self.gnr_config:
         path = self.gnr_config['gnr.environment_xml.projects.%s?path' % project_repository_name]
         if path:
             return expandpath(path)
     else:
         raise Exception('Error: Project Repository %s not found' % project_repository_name)
示例#24
0
 def toHtml_(self, filepath=None):
     if filepath:
         filepath = expandpath(filepath)
     self.finalize(self.body)
     self.html = self.root.toXml(filename=filepath,
                                 omitRoot=True,
                                 autocreate=True,
                                 forcedTagAttr='tag',
                                 addBagTypeAttr=False,
                                 typeattrs=False,
                                 self_closed_tags=['meta', 'br', 'img'])
     return self.html
示例#25
0
 def js_path(self, lib_type='gnr', version='11'):
     """add???
     
     :param lib_type: add???. Default value is ``gnr``
     :param version: add???. Default value is ``11``
     :returns: add???
     """
     path = self.gnr_config['gnr.environment_xml.static.js.%s_%s?path' %
                            (lib_type, version)]
     if path:
         path = os.path.join(expandpath(path), 'js')
     return path
示例#26
0
def getFullOptions(options=None):
    if sys.platform == 'win32':
        gnr_path = '~\gnr'
    else:
        gnr_path = '~/.gnr'
    enviroment_path = os.path.join(gnr_path,'environment.xml')
    env_options = Bag(expandpath(enviroment_path)).getAttr('gnrdaemon')
    assert env_options,"Missing gnrdaemon configuration."
    for k,v in options.items():
        if v:
            env_options[k] = v
    return env_options
示例#27
0
 def entity_name_to_path(self, entity_name, entity_type, look_in_projects=True):
     """TODO
     
     :param entity_name: TODO
     :param entity_type: TODO
     :param look_in_projects: TODO"""
     entity = self.entities.get(entity_type)
     if not entity:
         raise Exception('Error: entity type %s not known' % entity_type)
     if entity in self.gnr_config['gnr.environment_xml']:
         for path in [expandpath(path) for path in
                      self.gnr_config['gnr.environment_xml'].digest('%s:#a.path' % entity) if
                      os.path.isdir(expandpath(path))]:
             entity_path = os.path.join(path, entity_name)
             if os.path.isdir(entity_path):
                 return expandpath(entity_path)
     if look_in_projects and 'projects' in self.gnr_config['gnr.environment_xml']:
         projects = [expandpath(path) for path in self.gnr_config['gnr.environment_xml'].digest('projects:#a.path')
                     if os.path.isdir(expandpath(path))]
         for project_path in projects:
             for path in glob.glob(os.path.join(project_path, '*/%s' % entity)):
                 entity_path = os.path.join(path, entity_name)
                 if os.path.isdir(entity_path):
                     return expandpath(entity_path)
     raise Exception('Error: %s %s not found' % (entity_type, entity_name))
示例#28
0
 def load_gnr_config(self):
     if self.options.get('config_path'):
         config_path = self.options['config_path']
     else:
         if sys.platform == 'win32':
             config_path = '~\gnr'
         else:
             config_path = '~/.gnr'
     config_path = self.config_path = expandpath(config_path)
     if os.path.isdir(config_path):
         self.gnr_config = Bag(config_path)
     else:
         self.gnr_config = Bag()
示例#29
0
 def load_gnr_config(self):
     if hasattr(self.options, 'config_path') and self.options.config_path:
         config_path = self.options.config_path
     else:
         if sys.platform == 'win32':
             config_path = '~\gnr'
         else:
             config_path = '~/.gnr'
     config_path = self.config_path = expandpath(config_path)
     if os.path.isdir(config_path):
         self.gnr_config = Bag(config_path)
     else:
         self.gnr_config = Bag()
示例#30
0
 def load_gnr_config(self):
     if self.options.get('config_path'):
         config_path = self.options['config_path']
     else:
         if sys.platform == 'win32':
             config_path = '~\gnr'
         else:
             config_path = '~/.gnr'
     config_path = self.config_path = expandpath(config_path)
     if os.path.isdir(config_path):
         self.gnr_config = Bag(config_path)
     else:
         self.gnr_config = Bag()
示例#31
0
 def load_gnr_config(self):
     if hasattr(self.options, 'config_path') and self.options.config_path:
         config_path = self.options.config_path
     else:
         if sys.platform == 'win32':
             config_path = '~\gnr'
         else:
             config_path = '~/.gnr'
     config_path = self.config_path = expandpath(config_path)
     if os.path.isdir(config_path):
         self.gnr_config = Bag(config_path)
     else:
         self.gnr_config = Bag()
示例#32
0
 def toHtml(self, filepath=None):
     """TODO
     
     :param filepath: TODO"""
     if filepath:
         filepath = expandpath(filepath)
     self.finalize(self.body)
     self.html = self.root.toXml(filename=filepath,
                                 omitRoot=True,
                                 autocreate=True,
                                 forcedTagAttr='tag',
                                 addBagTypeAttr=False, typeattrs=False, self_closed_tags=['meta', 'br', 'img'],
                                 docHeader='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> \n')
     return self.html
示例#33
0
 def load_site_config(self):
     """add???"""
     site_config_path = os.path.join(self.site_path, 'siteconfig.xml')
     site_config = self.gnr_config['gnr.siteconfig.default_xml']
     path_list = []
     if 'projects' in self.gnr_config['gnr.environment_xml']:
         projects = [(expandpath(path), site_template) for path, site_template in
                     self.gnr_config['gnr.environment_xml.projects'].digest('#a.path,#a.site_template') if
                     os.path.isdir(expandpath(path))]
         for project_path, site_template in projects:
             sites = glob.glob(os.path.join(project_path, '*/sites'))
             path_list.extend([(site_path, site_template) for site_path in sites])
         for path, site_template in path_list:
             if path == os.path.dirname(self.site_path):
                 if site_config:
                     site_config.update(self.gnr_config['gnr.siteconfig.%s_xml' % site_template] or Bag())
                 else:
                     site_config = self.gnr_config['gnr.siteconfig.%s_xml' % site_template]
     if site_config:
         site_config.update(Bag(site_config_path))
     else:
         site_config = Bag(site_config_path)
     return site_config
示例#34
0
 def site_name_to_path(self, site_name):
     path_list = []
     if 'sites' in self.gnr_config['gnr.environment_xml']:
         path_list.extend([
             (expandpath(path), site_template) for path, site_template in
             self.gnr_config['gnr.environment_xml.sites'].digest(
                 '#a.path,#a.site_template')
             if os.path.isdir(expandpath(path))
         ])
     if 'projects' in self.gnr_config['gnr.environment_xml']:
         projects = [(expandpath(path), site_template)
                     for path, site_template in
                     self.gnr_config['gnr.environment_xml.projects'].digest(
                         '#a.path,#a.site_template')
                     if os.path.isdir(expandpath(path))]
         for project_path, site_template in projects:
             sites = glob.glob(os.path.join(project_path, '*/sites'))
             path_list.extend([(site_path, site_template)
                               for site_path in sites])
     for path, site_template in path_list:
         site_path = os.path.join(path, site_name)
         if os.path.isdir(site_path):
             return site_path, site_template
     raise ServerException('Error: no site named %s found' % site_name)
示例#35
0
def getFullOptions(options=None):
    gnr_path = gnrConfigPath()
    enviroment_path = os.path.join(gnr_path,'environment.xml')
    env_options = Bag(expandpath(enviroment_path)).getAttr('gnrdaemon')
    if env_options.get('sockets'):
        if env_options['sockets'].lower() in ('t','true','y') :
            env_options['sockets']=os.path.join(gnr_path,'sockets')
        if not os.path.isdir(env_options['sockets']):
            os.makedirs(env_options['sockets'])
        env_options['socket']=env_options.get('socket') or os.path.join(env_options['sockets'],'gnrdaemon.sock')
    assert env_options,"Missing gnrdaemon configuration."
    for k,v in options.items():
        if v:
            env_options[k] = v
    return env_options
示例#36
0
 def project_repository_name_to_path(self,
                                     project_repository_name,
                                     strict=True):
     """TODO
     
     :param project_repository_name: TODO
     :param strict: TODO"""
     if not strict or 'gnr.environment_xml.projects.%s' % project_repository_name in self.gnr_config:
         path = self.gnr_config['gnr.environment_xml.projects.%s?path' %
                                project_repository_name]
         if path:
             return expandpath(path)
     else:
         raise Exception('Error: Project Repository %s not found' %
                         project_repository_name)
示例#37
0
def getFullOptions(options=None):
    gnr_path = gnrConfigPath()
    enviroment_path = os.path.join(gnr_path, 'environment.xml')
    env_options = Bag(expandpath(enviroment_path)).getAttr('gnrdaemon')
    if env_options.get('sockets'):
        if env_options['sockets'].lower() in ('t', 'true', 'y'):
            env_options['sockets'] = os.path.join(gnr_path, 'sockets')
        if not os.path.isdir(env_options['sockets']):
            os.makedirs(env_options['sockets'])
        env_options['socket'] = env_options.get('socket') or os.path.join(
            env_options['sockets'], 'gnrdaemon.sock')
    assert env_options, "Missing gnrdaemon configuration."
    for k, v in options.items():
        if v:
            env_options[k] = v
    return env_options
示例#38
0
 def resource_name_to_path(self, res_id, safe=True):
     """add???
     
     :param res_id: add???
     :param safe: boolean. add???. Default value is ``True``
     """
     project_resource_path = os.path.join(self.site_path, '..', '..', 'resources', res_id)
     if os.path.isdir(project_resource_path):
         return project_resource_path
     if 'resources' in self.gnr_config['gnr.environment_xml']:
         for path in self.gnr_config['gnr.environment_xml'].digest('resources:#a.path'):
             res_path = expandpath(os.path.join(path, res_id))
             if os.path.isdir(res_path):
                 return res_path
     if safe:
         raise Exception('Error: resource %s not found' % res_id)
示例#39
0
 def code_monitor(self):
     if not hasattr(self, '_code_monitor'):
         if self.options.get('reload') in ('false', 'False', False, None):
             self._code_monitor = None
         else:
             self._code_monitor = GnrReloaderMonitor()
             menu_path = os.path.join(self.site_path, 'menu.xml')
             site_config_path = os.path.join(self.site_path, 'siteconfig.xml')
             for file_path in (menu_path, site_config_path):
                 if os.path.isfile(file_path):
                     self._code_monitor.watch_file(file_path)
             config_path = expandpath(self.config_path)
             if os.path.isdir(config_path):
                 for file_path in listdirs(config_path):
                     self._code_monitor.watch_file(file_path)
             self._code_monitor.add_reloader_callback(self.gnr_site.on_reloader_restart)
     return self._code_monitor
示例#40
0
    def test_7_dir_resolver(self, pane):
        #d = DirectoryResolver(,cacheTime=10,include='*.py', exclude='__*,.*',dropext=True,readOnly=False)()
        pane.data(
            '.store',
            DirectoryResolver(expandpath('~/sviluppo'),
                              cacheTime=10,
                              include='*.py',
                              exclude='_*,.*',
                              dropext=True,
                              readOnly=False)())

        ddm = pane.div(height='50px', width='50px', background='lime')
        ddm.menu(action='console.log($1)',
                 modifiers='*',
                 storepath='.store',
                 _class='smallmenu',
                 id='test99menu')
示例#41
0
 def resource_name_to_path(self, res_id, safe=True):
     """TODO
     
     :param res_id: TODO
     :param safe: TODO"""
     project_resource_path = os.path.normpath(os.path.join(self.site_path, '..', '..', 'resources', res_id))
     if os.path.isdir(project_resource_path):
         log.debug('resource_name_to_path(%s) -> %s (project)' % (repr(res_id),repr(project_resource_path)))
         return project_resource_path
     if 'resources' in self.gnr_config['gnr.environment_xml']:
         for path in self.gnr_config['gnr.environment_xml'].digest('resources:#a.path'):
             res_path = expandpath(os.path.join(path, res_id))
             if os.path.isdir(res_path):
                 log.debug('resource_name_to_path(%s) -> %s (gnr config)' % (repr(res_id), repr(res_path)))
                 return res_path
     log.debug('resource_name_to_path(%s) not found.' % repr(res_id))
     if safe:
         raise Exception('Error: resource %s not found' % res_id)
示例#42
0
 def resource_name_to_path(self, res_id, safe=True):
     """TODO
     
     :param res_id: TODO
     :param safe: TODO"""
     project_resource_path = os.path.normpath(os.path.join(self.site_path, '..', '..', 'resources', res_id))
     if os.path.isdir(project_resource_path):
         log.debug('resource_name_to_path(%s) -> %s (project)' % (repr(res_id),repr(project_resource_path)))
         return project_resource_path
     if 'resources' in self.gnr_config['gnr.environment_xml']:
         for path in self.gnr_config['gnr.environment_xml'].digest('resources:#a.path'):
             res_path = expandpath(os.path.join(path, res_id))
             if os.path.isdir(res_path):
                 log.debug('resource_name_to_path(%s) -> %s (gnr config)' % (repr(res_id), repr(res_path)))
                 return res_path
     log.debug('resource_name_to_path(%s) not found.' % repr(res_id))
     if safe:
         raise Exception('Error: resource %s not found' % res_id)
示例#43
0
 def toHtml(self, filepath=None):
     """TODO
     
     :param filepath: TODO"""
     if filepath:
         filepath = expandpath(filepath)
     self.finalize(self.body)
     self.html = self.root.toXml(
         filename=filepath,
         omitRoot=True,
         autocreate=True,
         forcedTagAttr='tag',
         addBagTypeAttr=False,
         typeattrs=False,
         self_closed_tags=['meta', 'br', 'img'],
         docHeader=
         '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> \n'
     )
     return self.html
示例#44
0
 def code_monitor(self):
     if not hasattr(self, '_code_monitor'):
         if self.options.get('reload') in ('false', 'False', False, None):
             self._code_monitor = None
         else:
             self._code_monitor = GnrReloaderMonitor()
             menu_path = os.path.join(self.site_path, 'menu.xml')
             site_config_path = os.path.join(self.site_path,
                                             'siteconfig.xml')
             for file_path in (menu_path, site_config_path):
                 if os.path.isfile(file_path):
                     self._code_monitor.watch_file(file_path)
             config_path = expandpath(self.config_path)
             if os.path.isdir(config_path):
                 for file_path in listdirs(config_path):
                     self._code_monitor.watch_file(file_path)
             self._code_monitor.add_reloader_callback(
                 self.gnr_site.on_reloader_restart)
     return self._code_monitor
示例#45
0
 def run(self):
     if self.options.stop_daemon:
         return self.stop_daemon()
     self.set_user()
     if not (self.options.reload == 'false' or self.options.reload
             == 'False' or self.options.reload == False
             or self.options.reload == None):
         if os.environ.get(self._reloader_environ_key):
             if self.options.verbose > 1:
                 print 'Running reloading file monitor'
             gnr_reloader_install(int(self.options.reload_interval))
             menu_path = os.path.join(self.site_path, 'menu.xml')
             site_config_path = os.path.join(self.site_path,
                                             'siteconfig.xml')
             for file_path in (menu_path, site_config_path):
                 if os.path.isfile(file_path):
                     GnrReloaderMonitor.watch_file(file_path)
             config_path = expandpath(self.config_path)
             if os.path.isdir(config_path):
                 for file_path in listdirs(config_path):
                     GnrReloaderMonitor.watch_file(file_path)
         else:
             return self.restart_with_reloader()
     first_run = int(getattr(self.options, 'counter', 0) or 0) == 0
     if self.options.bonjour and first_run:
         self.set_bonjour()
     if self.cmd:
         return self.check_cmd()
     self.check_logfile()
     self.check_pidfile()
     if getattr(self.options, 'daemon', False):
         try:
             self.daemonize()
         except DaemonizeException, ex:
             if self.options.verbose > 0:
                 print str(ex)
             return
示例#46
0
 def entity_name_to_path(self,
                         entity_name,
                         entity_type,
                         look_in_projects=True):
     """add???
     
     :param entity_name: add???
     :param entity_type: add???
     :param look_in_projects: add???. Default value is ``True``
     :returns: add???
     """
     entity = self.entities.get(entity_type)
     if not entity:
         raise Exception('Error: entity type %s not known' % entity_type)
     if entity in self.gnr_config['gnr.environment_xml']:
         for path in [
                 expandpath(path)
                 for path in self.gnr_config['gnr.environment_xml'].digest(
                     '%s:#a.path' % entity)
                 if os.path.isdir(expandpath(path))
         ]:
             entity_path = os.path.join(path, entity_name)
             if os.path.isdir(entity_path):
                 return expandpath(entity_path)
     if look_in_projects and 'projects' in self.gnr_config[
             'gnr.environment_xml']:
         projects = [
             expandpath(path)
             for path in self.gnr_config['gnr.environment_xml'].digest(
                 'projects:#a.path') if os.path.isdir(expandpath(path))
         ]
         for project_path in projects:
             for path in glob.glob(
                     os.path.join(project_path, '*/%s' % entity)):
                 entity_path = os.path.join(path, entity_name)
                 if os.path.isdir(entity_path):
                     return expandpath(entity_path)
     raise Exception('Error: %s %s not found' % (entity_type, entity_name))
示例#47
0
 def path(self, version, *args, **kwargs):
     return expandpath(os.path.join(self.site.dojo_path[version], *args))
示例#48
0
 def path(self, version, *args, **kwargs):
     return expandpath(os.path.join(self.site.dojo_path[version], *args))
示例#49
0
 def path(self, *args):
     return expandpath(os.path.join(self.site.site_static_dir, *args))
示例#50
0
 def path(self,volume,*args,**kwargs):
     vpath = self.volumes.get(volume,volume)
     #print 'volumes',self.volumes,'volume'
     result = expandpath(os.path.join(self.site.site_static_dir,vpath, *args))
     #print 'aaa',result
     return result
示例#51
0
 def path(self, *args):
     return expandpath(os.path.join(self.site.site_static_dir, *args))
示例#52
0
 def path(self, version, *args):
     return expandpath(os.path.join(self.site.gnr_path[version], *args))
示例#53
0
 def path(self, version, *args):
     return expandpath(os.path.join(self.site.gnr_path[version], *args))