Пример #1
0
 def __change( self, setup = None, group = None ):
   if not setup:
     setup = self.getUserSetup()
   if not group:
     group = self.getUserGroup() or 'anon'
   url = [ Conf.rootURL().strip( "/" ), "s:%s" % setup, "g:%s" % group ]
   self.redirect( "/%s" % "/".join( url ) )
Пример #2
0
 def __change(self, setup=None, group=None):
     if not setup:
         setup = self.getUserSetup()
     if not group:
         group = self.getUserGroup() or 'anon'
     url = [Conf.rootURL().strip("/"), "s:%s" % setup, "g:%s" % group]
     self.redirect("/%s" % "/".join(url))
Пример #3
0
  def web_index(self):
    # Render base template
    data = self.getSessionData()

    url_state = ""
    if self.request.arguments.has_key("url_state") and len(self.request.arguments["url_state"][0]) > 0:
      url_state = self.request.arguments["url_state"][0]

    view_name = Conf.getTheme()
    if self.request.arguments.has_key("view") and len(self.request.arguments["view"][0]) > 0:  
      view_name = self.request.arguments["view"][0]
      
    theme_name = "ext-all-gray"
    if self.request.arguments.has_key("theme") and len(self.request.arguments["theme"][0]) > 0:
      if self.request.arguments["theme"][0]=="Neptune":
        theme_name = "ext-all-neptune"
      if self.request.arguments["theme"][0]=="Classic":
        theme_name = "ext-all"
        
    open_app = ""
    if self.request.arguments.has_key("open_app") and len(self.request.arguments["open_app"][0]) > 0:
      open_app = self.request.arguments["open_app"][0].strip()
    
    level = str(gLogger.getLevel()).lower()
    self.render( "root.tpl", base_url = data[ 'baseURL' ], _dev = Conf.devMode(),
                 ext_version = data[ 'extVersion' ], url_state = url_state,
                 extensions = data[ 'extensions' ],
                 credentials = data[ 'user' ], title = Conf.getTitle(),
                 theme = theme_name, root_url = Conf.rootURL(), view = view_name, open_app = open_app, debug_level= level)
Пример #4
0
 def getData(self):
     DN = self.__disetConfig.getDN()
     group = self.__disetConfig.getGroup()
     credDict = self.__getCredDict(DN, group)
     data = {
         'menu':
         self.__getGroupMenu(credDict, group),
         'user':
         credDict,
         'validGroups': [],
         'setup':
         self.__disetConfig.getSetup()
         or gConfig.getValue("/DIRAC/Setup", ""),
         'validSetups':
         gConfig.getSections("/DIRAC/Setups")['Value'],
         'extensions':
         self.__extensions,
         'extVersion':
         self.getExtJSVersion()
     }
     if 'properties' in credDict:
         credDict.pop('properties')
     #Add valid groups if known
     if DN:
         result = Registry.getGroupsForDN(DN)
         if result['OK']:
             data['validGroups'] = result['Value']
     #Calculate baseURL
     baseURL = [
         Conf.rootURL().strip("/"),
         "s:%s" % data['setup'],
         "g:%s" % credDict.get('group', 'anon')
     ]
     data['baseURL'] = "/%s" % "/".join(baseURL)
     return data
Пример #5
0
    def web_index(self):
        # Render base template
        data = self.getSessionData()

        url_state = ""
        if self.request.arguments.has_key("url_state") and len(
                self.request.arguments["url_state"][0]) > 0:
            url_state = xss_filter(self.request.arguments["url_state"][0])

        view_name = Conf.getTheme()
        if self.request.arguments.has_key("view") and len(
                self.request.arguments["view"][0]) > 0:
            view_name = xss_filter(self.request.arguments["view"][0])

        theme_name = "ext-all-gray"
        if self.request.arguments.has_key("theme") and len(
                self.request.arguments["theme"][0]) > 0:
            if self.request.arguments["theme"][0] == "Neptune":
                theme_name = "ext-all-neptune"
            if self.request.arguments["theme"][0] == "Classic":
                theme_name = "ext-all"

        open_app = ""
        if self.request.arguments.has_key("open_app") and len(
                self.request.arguments["open_app"][0]) > 0:
            open_app = xss_filter(
                self.request.arguments["open_app"][0].strip())

        icon = data['baseURL'] + Conf.getIcon()
        background = data['baseURL'] + Conf.getBackgroud()
        logo = data['baseURL'] + Conf.getLogo()
        welcomeFile = Conf.getWelcome()
        welcome = ''
        if welcomeFile:
            try:
                with open(welcomeFile, 'r') as f:
                    welcome = f.read().replace('\n', '')
            except:
                gLogger.warn('Welcome page not found here: %s' % welcomeFile)

        level = str(gLogger.getLevel()).lower()
        self.render("root.tpl",
                    iconUrl=icon,
                    base_url=data['baseURL'],
                    _dev=Conf.devMode(),
                    ext_version=data['extVersion'],
                    url_state=url_state,
                    extensions=data['extensions'],
                    credentials=data['user'],
                    title=Conf.getTitle(),
                    theme=theme_name,
                    root_url=Conf.rootURL(),
                    view=view_name,
                    open_app=open_app,
                    debug_level=level,
                    welcome=welcome,
                    backgroundImage=background,
                    logo=logo)
Пример #6
0
 def run(self):
     """
 Start web servers
 """
     bu = Conf.rootURL().strip("/")
     urls = []
     for proto, port in self.__servers:
         urls.append("%s://0.0.0.0:%s/%s/" % (proto, port, bu))
     self.log.always("Listening on %s" % " and ".join(urls))
     tornado.autoreload.add_reload_hook(self.__reloadAppCB)
     tornado.ioloop.IOLoop.instance().start()
Пример #7
0
 def __change(self, setup=None, group=None):
     if not setup:
         setup = self.getUserSetup()
     if not group:
         group = self.getUserGroup() or 'anon'
     qs = False
     if 'Referer' in self.request.headers:
         o = urlparse.urlparse(self.request.headers['Referer'])
         qs = '?%s' % o.query
     url = [Conf.rootURL().strip("/"), "s:%s" % setup, "g:%s" % group]
     self.redirect("/%s%s" % ("/".join(url), qs))
Пример #8
0
 def __change( self, setup = None, group = None ):
   if not setup:
     setup = self.getUserSetup()
   if not group:
     group = self.getUserGroup() or 'anon'
   qs = False
   if 'Referer' in self.request.headers:
     o = urlparse.urlparse( self.request.headers[ 'Referer' ] )
     qs = '?%s' % o.query
   url = [ Conf.rootURL().strip( "/" ), "s:%s" % setup, "g:%s" % group ]
   self.redirect( "/%s%s" % ( "/".join( url ), qs ) )
Пример #9
0
 def get( self, setup, group, route ):
   if self.__action == "addSlash":
     self.redirect( "%s/" % self.request.uri, permanent = True )
   elif self.__action == "sendToRoot":
     dest = "/"
     rootURL = Conf.rootURL()
     if rootURL:
       dest += "%s/" % rootURL.strip( "/" )
     if setup and group:
       dest += "s:%s/g:%s/" % ( setup, group )
     self.redirect( dest )
Пример #10
0
 def get(self, setup, group, route):
     if self.__action == "addSlash":
         self.redirect("%s/" % self.request.uri, permanent=True)
     elif self.__action == "sendToRoot":
         dest = "/"
         rootURL = Conf.rootURL()
         if rootURL:
             dest += "%s/" % rootURL.strip("/")
         if setup and group:
             dest += "s:%s/g:%s/" % (setup, group)
         self.redirect(dest)
Пример #11
0
 def run( self ):
   """
   Start web servers
   """
   bu = Conf.rootURL().strip( "/" )
   urls = []
   for proto, port in self.__servers:
     urls.append("%s://0.0.0.0:%s/%s/" % ( proto, port, bu ) )
   self.log.always( "Listening on %s" % " and ".join( urls ) )
   tornado.autoreload.add_reload_hook( self.__reloadAppCB )
   tornado.ioloop.IOLoop.instance().start()
Пример #12
0
 def get(self, setup, group, route):
     if self.__action == "addSlash":
         o = urlparse.urlparse(self.request.uri)
         proto = self.request.protocol
         if 'X-Scheme' in self.request.headers:
             proto = self.request.headers['X-Scheme']
         nurl = "%s://%s%s/" % (proto, self.request.host, o.path)
         if o.query:
             nurl = "%s?%s" % (nurl, o.query)
         self.redirect(nurl, permanent=True)
     elif self.__action == "sendToRoot":
         dest = "/"
         rootURL = Conf.rootURL()
         if rootURL:
             dest += "%s/" % rootURL.strip("/")
         if setup and group:
             dest += "s:%s/g:%s/" % (setup, group)
         self.redirect(dest)
Пример #13
0
 def get( self, setup, group, route ):
   if self.__action == "addSlash":
     o = urlparse.urlparse( self.request.uri )
     proto = self.request.protocol
     if 'X-Scheme' in self.request.headers:
       proto = self.request.headers[ 'X-Scheme' ]
     nurl = "%s://%s%s/" % ( proto, self.request.host, o.path )
     if o.query:
       nurl = "%s?%s" % ( nurl, o.query )
     self.redirect( nurl, permanent = True )
   elif self.__action == "sendToRoot":
     dest = "/"
     rootURL = Conf.rootURL()
     if rootURL:
       dest += "%s/" % rootURL.strip( "/" )
     if setup and group:
       dest += "s:%s/g:%s/" % ( setup, group )
     self.redirect( dest )
Пример #14
0
  def web_index(self):
    # Render base template
    data = self.getSessionData()

    url_state = ""
    if self.request.arguments.has_key("url_state") and len(self.request.arguments["url_state"][0]) > 0:
      url_state = xss_filter( self.request.arguments["url_state"][0] )

    view_name = Conf.getTheme()
    if self.request.arguments.has_key("view") and len(self.request.arguments["view"][0]) > 0:
      view_name = xss_filter( self.request.arguments["view"][0] )

    theme_name = "ext-all-gray"
    if self.request.arguments.has_key("theme") and len(self.request.arguments["theme"][0]) > 0:
      if self.request.arguments["theme"][0]=="Neptune":
        theme_name = "ext-all-neptune"
      if self.request.arguments["theme"][0]=="Classic":
        theme_name = "ext-all"

    open_app = ""
    if self.request.arguments.has_key("open_app") and len(self.request.arguments["open_app"][0]) > 0:
      open_app = xss_filter( self.request.arguments["open_app"][0].strip() )

    icon = data[ 'baseURL' ] + Conf.getIcon()
    background = data[ 'baseURL' ] + Conf.getBackgroud()
    logo = data[ 'baseURL' ] + Conf.getLogo()
    welcomeFile = Conf.getWelcome()
    welcome = ''
    if welcomeFile:
      try: 
        with open(welcomeFile, 'r') as f:
          welcome = f.read().replace('\n', '')
      except:
        gLogger.warn('Welcome page not found here: %s' % welcomeFile)
    
    level = str(gLogger.getLevel()).lower()
    self.render( "root.tpl", iconUrl=icon, base_url = data[ 'baseURL' ], _dev = Conf.devMode(),
                 ext_version = data[ 'extVersion' ], url_state = url_state,
                 extensions = data[ 'extensions' ],
                 credentials = data[ 'user' ], title = Conf.getTitle(),
                 theme = theme_name, root_url = Conf.rootURL(), view = view_name, 
                 open_app = open_app, debug_level = level, welcome = welcome,
                 backgroundImage = background, logo = logo )
Пример #15
0
 def getData( self ):
   data = { 'menu' : self.__getGroupMenu(),
            'user' :  self.__credDict,
            'validGroups' : [],
            'setup' : self.__setup,
            'validSetups' : gConfig.getSections( "/DIRAC/Setups" )[ 'Value' ],
            'extensions' : self.__extensions,
            'extVersion' : self.getExtJSVersion() }
   #Add valid groups if known
   DN = self.__credDict.get( "DN", "" )
   if DN:
     result = Registry.getGroupsForDN( DN )
     if result[ 'OK' ]:
       data[ 'validGroups' ] = result[ 'Value' ]
   #Calculate baseURL
   baseURL = [ Conf.rootURL().strip( "/" ),
               "s:%s" % data[ 'setup' ],
               "g:%s" % self.__credDict.get( 'group', '' )  ]
   data[ 'baseURL' ] = "/%s" % "/".join( baseURL )
   return data
Пример #16
0
    def web_index(self):
        # Render base template
        data = self.getSessionData()

        url_state = ""
        if self.request.arguments.has_key("url_state") and len(self.request.arguments["url_state"][0]) > 0:
            url_state = self.request.arguments["url_state"][0]

        view_name = "desktop"
        if self.request.arguments.has_key("view") and len(self.request.arguments["view"][0]) > 0:
            view_name = self.request.arguments["view"][0]

        theme_name = "ext-all-gray"
        if self.request.arguments.has_key("theme") and len(self.request.arguments["theme"][0]) > 0:
            if self.request.arguments["theme"][0] == "Neptune":
                theme_name = "ext-all-neptune"
            if self.request.arguments["theme"][0] == "Classic":
                theme_name = "ext-all"

        open_app = ""
        if self.request.arguments.has_key("open_app") and len(self.request.arguments["open_app"][0]) > 0:
            open_app = self.request.arguments["open_app"][0].strip()

        self.render(
            "root.tpl",
            base_url=data["baseURL"],
            _dev=Conf.devMode(),
            ext_version=data["extVersion"],
            url_state=url_state,
            extensions=data["extensions"],
            credentials=data["user"],
            title=Conf.getTitle(),
            theme=theme_name,
            root_url=Conf.rootURL(),
            view=view_name,
            open_app=open_app,
        )
Пример #17
0
 def getData(self):
     data = {
         'menu': self.__getGroupMenu(),
         'user': self.__credDict,
         'validGroups': [],
         'setup': self.__setup,
         'validSetups': gConfig.getSections("/DIRAC/Setups")['Value'],
         'extensions': self.__extensions,
         'extVersion': self.getExtJSVersion()
     }
     #Add valid groups if known
     DN = self.__credDict.get("DN", "")
     if DN:
         result = Registry.getGroupsForDN(DN)
         if result['OK']:
             data['validGroups'] = result['Value']
     #Calculate baseURL
     baseURL = [
         Conf.rootURL().strip("/"),
         "s:%s" % data['setup'],
         "g:%s" % self.__credDict.get('group', '')
     ]
     data['baseURL'] = "/%s" % "/".join(baseURL)
     return data
Пример #18
0
 def getData( self ):
   DN = self.__disetConfig.getDN()
   group = self.__disetConfig.getGroup()
   credDict = self.__getCredDict( DN, group )
   data = { 'menu' : self.__getGroupMenu( credDict, group ),
            'user' :  credDict,
            'validGroups' : [],
            'setup' : self.__disetConfig.getSetup() or gConfig.getValue( "/DIRAC/Setup", "" ),
            'validSetups' : gConfig.getSections( "/DIRAC/Setups" )[ 'Value' ],
            'extensions' : self.__extensions,
            'extVersion' : self.getExtJSVersion() }
   if 'properties' in credDict:
     credDict.pop( 'properties' )
   #Add valid groups if known
   if DN:
     result = Registry.getGroupsForDN( DN )
     if result[ 'OK' ]:
       data[ 'validGroups' ] = result[ 'Value' ]
   #Calculate baseURL
   baseURL = [ Conf.rootURL().strip( "/" ),
               "s:%s" % data[ 'setup' ],
               "g:%s" % credDict.get( 'group', 'anon' )  ]
   data[ 'baseURL' ] = "/%s" % "/".join( baseURL )
   return data
Пример #19
0
 def __init__( self ):
   self.__routes = Routes( Conf.rootURL() )
   self.__servers = {}
   self.log = gLogger.getSubLogger( "Web" )
Пример #20
0
 def __init__(self):
     self.__handlerMgr = HandlerMgr(Conf.rootURL())
     self.__servers = {}
     self.log = gLogger.getSubLogger("Web")
Пример #21
0
 def __init__( self ):
   self.__handlerMgr = HandlerMgr( Conf.rootURL() )
   self.__servers = {}
   self.log = gLogger.getSubLogger( "Web" )