Esempio n. 1
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to the application object.
        :arg config: reference to the configuration.
        :arg str mount: URL mount point.

        """

        # must be in a static content directory
        frontpage = "html/ReqMgr/index.html"
        roots = \
        {
            "html":
            {
                # without repeating the 'html' here, it doesn't work
                # due to path gymnastics in WMCore.REST.Server.py
                # rather messy figuring out static content dir by
                # counting file separators and making it compatible
                # between localhost and VM running, hence the config
                # value here
                "root": "%s/html/" % config.static_content_dir,

                "rx": rx.RX_STATIC_DIR_PATH
            },
        }
        RESTFrontPage.__init__(self, app, config, mount, frontpage, roots)
Esempio n. 2
0
    def __init__(self, app, config, mount):
        """
    :arg app: reference to the application object.
    :arg config: reference to the configuration.
    :arg str mount: URL mount point."""
        CONTENT = os.path.abspath(__file__).rsplit('/', 6)[0]
        roots = \
        {
          "html":
          {
            "root": "%s/data/html/" % CONTENT,
            "rx": re.compile(r".*")
          },
          "script":
          {
            "root": "%s/data/script/" % CONTENT,
            "rx": re.compile(r".*")
          },
          "css":
          {
            "root": "%s/data/css/" % CONTENT,
            "rx": re.compile(r".*")
          }
        }

        frontpage = "html/index.html"  #crabserver?

        RESTFrontPage.__init__(self,
                               app,
                               config,
                               mount,
                               frontpage,
                               roots,
                               instances=lambda: app.views["data"]._db)
Esempio n. 3
0
  def __init__(self, app, config, mount):
    """
    :arg app: reference to the application object.
    :arg config: reference to the configuration.
    :arg str mount: URL mount point."""
    CONTENT = os.path.abspath(__file__).rsplit('/', 6)[0]
    roots = \
    {
      "html":
      {
        "root": "%s/data/html/" % CONTENT,
        "rx": re.compile(r".*")
      },
      "script":
      {
        "root": "%s/data/script/" % CONTENT,
        "rx": re.compile(r".*")
      },
      "css":
      {
        "root": "%s/data/css/" % CONTENT,
        "rx": re.compile(r".*")
      }
    }

    frontpage = "html/index.html"#crabserver?

    RESTFrontPage.__init__(self, app, config, mount, frontpage, roots,
                           instances = lambda: app.views["data"]._db)
Esempio n. 4
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to the application object.
     :arg config: reference to the configuration.
     :arg str mount: URL mount point."""
     mainroot = 'wmarchive'  # entry point in access URL
     wpath = os.getenv('WMA_STATIC_ROOT', '')
     if not wpath:
         content = os.path.abspath(__file__).rsplit('/', 5)[0]
         xlib = (__file__.find("/xlib/") >= 0 and "x") or ""
         wpath = "%s/%sdata/" % (content, xlib)
     if not wpath.endswith('/'):
         wpath += '/'
     print(tstamp(self.__class__.__name__), "static content: %s" % wpath)
     mdict = {"root": wpath, \
              "rx": re.compile(r"^[a-z]+/[-a-z0-9]+\.(?:html)$")}
     tdict = {"root": wpath+"templates/", \
             "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\.(?:html|tmpl)$")}
     jdict = {"root": wpath+"js/", \
              "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\.(?:js)$")}
     cdict = {"root": wpath+"css/", \
              "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\..*(?:css)$")}
     idict = {"root": wpath+"images/", \
              "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\.(?:png|gif|jpg)$")}
     roots = {mainroot: mdict, "templates": tdict, \
             "js": jdict, "css": cdict, "images": idict}
     # location of frontpage in the root, e.g. wmarchive
     frontpage = "%s/templates/wma.html" % mainroot
     RESTFrontPage.__init__(self, app, config, mount, frontpage, roots)
Esempio n. 5
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to the application object.
     :arg config: reference to the configuration.
     :arg str mount: URL mount point.
     
     """
     
     # must be in a static content directory
     frontpage = "html/ReqMgr/index.html"
     roots = \
     {
         "html":
         {
             # without repeating the 'html' here, it doesn't work
             # due to path gymnastics in WMCore.REST.Server.py
             # rather messy figuring out static content dir by 
             # counting file separators and making it compatible
             # between localhost and VM running, hence the config
             # value here
             "root": "%s/html/" % config.static_content_dir,
             
             "rx": rx.RX_STATIC_DIR_PATH
         },
     }
     RESTFrontPage.__init__(self, app, config, mount, frontpage, roots)
Esempio n. 6
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to the application object.
     :arg config: reference to the configuration.
     :arg str mount: URL mount point."""
     mainroot = 'wmarchive' # entry point in access URL
     wpath = os.getenv('WMA_STATIC_ROOT', '')
     if  not wpath:
         content = os.path.abspath(__file__).rsplit('/', 5)[0]
         xlib = (__file__.find("/xlib/") >= 0 and "x") or ""
         wpath = "%s/%sdata/" % (content, xlib)
     if  not wpath.endswith('/'):
         wpath += '/'
     print(tstamp(self.__class__.__name__), "static content: %s" % wpath)
     mdict = {"root": wpath, \
              "rx": re.compile(r"^[a-z]+/[-a-z0-9]+\.(?:html)$")}
     tdict = {"root": wpath+"templates/", \
             "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\.(?:html|tmpl)$")}
     jdict = {"root": wpath+"js/", \
              "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\.(?:js)$")}
     cdict = {"root": wpath+"css/", \
              "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\..*(?:css)$")}
     idict = {"root": wpath+"images/", \
              "rx": re.compile(r"^([a-zA-Z]+/)*[-a-z0-9_]+\.(?:png|gif|jpg)$")}
     roots = {mainroot: mdict, "templates": tdict, \
             "js": jdict, "css": cdict, "images": idict}
     # location of frontpage in the root, e.g. wmarchive
     frontpage = "%s/templates/wma.html" % mainroot
     RESTFrontPage.__init__(self, app, config, mount, frontpage, roots)
Esempio n. 7
0
    def __init__(self, app, config, mount):
        """
    :arg app: reference to the application object.
    :arg config: reference to the configuration.
    :arg str mount: URL mount point."""
        CONTENT = os.path.abspath(__file__).rsplit('/', 5)[0]
        X = (__file__.find("/xlib/") >= 0 and "x") or ""
        roots = \
        {
          "sitedb":
          {
            "root": "%s/%sdata/" % (CONTENT, X),
            "rx": re.compile(r"^[a-z]+/[-a-z0-9]+\.(?:css|js|png|gif|html)$")
          },

          "yui":
          {
            "root": "%s/build/" % os.environ["YUI3_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9/_]+\.(?:css|js|png|gif)$")
          },

          "d3":
          {
            "root": "%s/data/" % os.environ["D3_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9]+(?:\.min)?\.(?:css|js)$")
          },

          "xregexp":
          {
            "root": "%s/data/xregexp/" % os.environ["XREGEXP_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+(?:-min)?\.js$")
          }
        }

        frontpage = "sitedb/templates/sitedb.html"
        if os.path.exists("%s/templates/sitedb-min.html" %
                          roots["sitedb"]["root"]):
            frontpage = "sitedb/templates/sitedb-min.html"

        regexps = dict((name[3:], getattr(SiteDB.Regexps, name).pattern)
                       for name in dir(SiteDB.Regexps)
                       if name.startswith("RX_") and name != "RX_PASSWD")

        RESTFrontPage.__init__(self,
                               app,
                               config,
                               mount,
                               frontpage,
                               roots,
                               instances=lambda: app.views["data"]._db,
                               preamble="var SITEDB_REGEXPS = %s;\n" %
                               cjson.encode(regexps))
Esempio n. 8
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to the application object.
        :arg config: reference to the configuration.
        :arg str mount: URL mount point.

        """

        # must be in a static content directory
        frontpage = "html/WMStats/index.html"
        roots = \
        {
            "html":
            {
                # without repeating the 'html' here, it doesn't work
                # due to path gymnastics in WMCore.REST.Server.py
                # rather messy figuring out static content dir by
                # counting file separators and making it compatible
                # between localhost and VM running, hence the config
                # value here
                "root": "%s/html/" % config.static_content_dir,

                "rx": RX_STATIC_DIR_PATH
            },
            "js":
            {   "root": "%s/html/WMStats/js/" % config.static_content_dir,
                "rx": re.compile(r"^([a-zA-Z]+/)+[-a-z0-9_]+\.(?:js)$")
            },
            "css":
            {   "root": "%s/html/WMStats/css/" % config.static_content_dir,
                "rx": re.compile(r"^([a-zA-Z]+/)+[-a-z0-9_]+\.(?:css)$")
            },
            "images":
            {   "root": "%s/html/WMStats/images/" % config.static_content_dir,
                "rx": re.compile(r"^([a-zA-Z]+/)+[-a-z0-9_]+\.(?:png|gif)$")
            },
            "lib":
            {   "root": "%s/html/WMStats/lib/" % config.static_content_dir,
                "rx": RX_STATIC_DIR_PATH
            },
            "fonts":
            {   "root": "%s/html/WMStats/fonts/" % config.static_content_dir,
                "rx": RX_STATIC_DIR_PATH
            }

        }
        RESTFrontPage.__init__(self, app, config, mount, frontpage, roots)
Esempio n. 9
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to the application object.
     :arg config: reference to the configuration.
     :arg str mount: URL mount point.
     
     """
     
     # must be in a static content directory
     frontpage = "html/WMStats/index.html"
     roots = \
     {
         "html":
         {
             # without repeating the 'html' here, it doesn't work
             # due to path gymnastics in WMCore.REST.Server.py
             # rather messy figuring out static content dir by 
             # counting file separators and making it compatible
             # between localhost and VM running, hence the config
             # value here
             "root": "%s/html/" % config.static_content_dir,
             
             "rx": RX_STATIC_DIR_PATH
         },
         "js":
         {   "root": "%s/html/WMStats/js/" % config.static_content_dir,
             "rx": re.compile(r"^([a-zA-Z]+/)+[-a-z0-9_]+\.(?:js)$")
         },
         "css":
         {   "root": "%s/html/WMStats/css/" % config.static_content_dir,
             "rx": re.compile(r"^([a-zA-Z]+/)+[-a-z0-9_]+\.(?:css)$")
         },
         "images":
         {   "root": "%s/html/WMStats/images/" % config.static_content_dir,
             "rx": re.compile(r"^([a-zA-Z]+/)+[-a-z0-9_]+\.(?:png|gif)$")
         },
         "lib":
         {   "root": "%s/html/WMStats/lib/" % config.static_content_dir,
             "rx": RX_STATIC_DIR_PATH
         },
         "fonts":
         {   "root": "%s/html/WMStats/fonts/" % config.static_content_dir,
             "rx": RX_STATIC_DIR_PATH
         }
     
     }
     RESTFrontPage.__init__(self, app, config, mount, frontpage, roots)
Esempio n. 10
0
  def __init__(self, app, config, mount):
    """
    :arg app: reference to the application object.
    :arg config: reference to the configuration.
    :arg str mount: URL mount point."""
    CONTENT = os.path.abspath(__file__).rsplit('/', 5)[0]
    X = (__file__.find("/xlib/") >= 0 and "x") or ""
    roots = \
    {
      "sitedb":
      {
        "root": "%s/%sdata/" % (CONTENT, X),
        "rx": re.compile(r"^[a-z]+/[-a-z0-9]+\.(?:css|js|png|gif|html)$")
      },

      "yui":
      {
        "root": "%s/build/" % os.environ["YUI3_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9/_]+\.(?:css|js|png|gif)$")
      },

      "d3":
      {
        "root": "%s/data/" % os.environ["D3_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9]+(?:\.min)?\.(?:css|js)$")
      },

      "xregexp":
      {
        "root": "%s/data/xregexp/" % os.environ["XREGEXP_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+(?:-min)?\.js$")
      }
    }

    frontpage = "sitedb/templates/sitedb.html"
    if os.path.exists("%s/templates/sitedb-min.html" % roots["sitedb"]["root"]):
      frontpage = "sitedb/templates/sitedb-min.html"

    regexps = dict((name[3:], getattr(SiteDB.Regexps, name).pattern)
                   for name in dir(SiteDB.Regexps)
                   if name.startswith("RX_") and name != "RX_PASSWD")

    RESTFrontPage.__init__(self, app, config, mount, frontpage, roots,
                           instances = lambda: app.views["data"]._db,
                           preamble = "var SITEDB_REGEXPS = %s;\n"
                                      % cjson.encode(regexps))
Esempio n. 11
0
from WMCore.REST.Server import RESTFrontPage
from WMCore.REST.Server import MiniRESTApi
from WMCore.REST.Server import RESTApi
from WMCore.REST.Server import DBConnectionPool
from WMCore.REST.Server import DatabaseRESTApi
from WMCore.REST.Server import RESTEntity
import os, threading

srcfile = os.path.abspath(__file__).rsplit("/", 1)[-1].split(".")[0]
dbspec = {}


class FakeApp:
    appname = "app"


class FakeConf:
    db = srcfile + ".dbspec"


RESTFrontPage(None, None, "/", "/dev/null", {})
MiniRESTApi(FakeApp(), None, "/")
RESTApi(FakeApp(), None, "/")
DBConnectionPool("x", {})
if threading.current_thread().name == "MainThread":
    DatabaseRESTApi(FakeApp(), FakeConf(), "/")
RESTEntity(FakeApp(), None, None, "/")
Esempio n. 12
0
    def __init__(self, app, config, mount):
        """
    :arg app: reference to the application object.
    :arg config: reference to the configuration.
    :arg str mount: URL mount point."""
        CONTENT = os.path.abspath(__file__).rsplit('/', 5)[0]
        X = (__file__.find("/xlib/") >= 0 and "x") or ""
        ROOT = "%s/%sdata/web/" % (CONTENT, X)

        roots = \
        {
          "overview":
          {
            "root": ROOT,
            "rx": re.compile(r"^[-A-Za-z0-9]+\.(?:css|js|png|gif|html)$")
          },

          "yui":
          {
            "root": "%s/build/" % os.environ["YUI3_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9/_]+\.(?:css|js|png|gif)$")
          },

          "d3":
          {
            "root": "%s/data/" % os.environ["D3_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9]+(?:\.[-a-z0-9]+)?(?:\.min)?\.(?:css|js)$")
          },

          "polymaps":
          {
            "root": "%s/data/" % os.environ["POLYMAPS_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+(?:\.min)?\.(?:css|js)$")
          },

          "xregexp":
          {
            "root": "%s/data/xregexp/" % os.environ["XREGEXP_ROOT"],
            "rx": re.compile(r"^[-a-z0-9]+(?:-min)?\.js$")
          }
        }

        MIN = (os.path.exists("%s/overview-min.html" % ROOT) and "-min") or ""
        frontpage = "overview/overview%s.html" % MIN
        viewhtml = glob(ROOT + "view-*" + MIN + ".html")
        viewcssref = [
            "overview/%s" % x.rsplit("/", 1)[1]
            for x in glob(ROOT + "view-*" + MIN + ".css")
        ]
        viewjsref = [
            "overview/%s" % x.rsplit("/", 1)[1]
            for x in glob(ROOT + "view-*" + MIN + ".js")
        ]
        cssref = "@MOUNT@/static?" + "&".join([
            "yui/cssreset/reset%s.css" % MIN,
            "yui/cssfonts/fonts%s.css" % MIN,
            "yui/cssgrids/grids%s.css" % MIN,
            "yui/cssbase/base%s.css" % MIN,
            "overview/overview%s.css" % MIN,
            "overview/button%s.css" % MIN,
            "overview/popup-menu%s.css" % MIN,
            "overview/world-map%s.css" % MIN
        ] + viewcssref)
        jsref = "@MOUNT@/static?" + "&".join([
            "rest/preamble.js",
            "yui/yui/yui%s.js" % MIN,
            "polymaps/polymaps%s.js" % MIN.replace("-", ".")
        ] + [
            "d3/d3/d3%s%s.js" % (x, MIN.replace("-", "."))
            for x in ("", ".layout", ".chart", ".geo")
        ] + [
            "xregexp/xregexp%s%s.js" % (x, MIN)
            for x in ("", "-unicode-base", "-unicode-categories")
        ] + [
            "overview/%s%s.js" % (x, MIN) for x in
            ("sprintf", "utils", "time", "d3ext", "app", "cache", "view")
        ] + viewjsref + ["overview/start%s.js" % MIN])

        RESTFrontPage.__init__(self,
                               app,
                               config,
                               mount,
                               frontpage,
                               roots,
                               substitutions={
                                   "CSSREF": cssref,
                                   "JSREF": jsref
                               },
                               embeddings={"VIEWHTML": viewhtml})
Esempio n. 13
0
  def __init__(self, app, config, mount):
    """
    :arg app: reference to the application object.
    :arg config: reference to the configuration.
    :arg str mount: URL mount point."""
    CONTENT = os.path.abspath(__file__).rsplit('/', 5)[0]
    X = (__file__.find("/xlib/") >= 0 and "x") or ""
    ROOT = "%s/%sdata/web/" % (CONTENT, X)

    roots = \
    {
      "overview":
      {
        "root": ROOT,
        "rx": re.compile(r"^[-A-Za-z0-9]+\.(?:css|js|png|gif|html)$")
      },

      "yui":
      {
        "root": "%s/build/" % os.environ["YUI3_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9/_]+\.(?:css|js|png|gif)$")
      },

      "d3":
      {
        "root": "%s/data/" % os.environ["D3_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+/[-a-z0-9]+(?:\.[-a-z0-9]+)?(?:\.min)?\.(?:css|js)$")
      },

      "polymaps":
      {
        "root": "%s/data/" % os.environ["POLYMAPS_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+(?:\.min)?\.(?:css|js)$")
      },

      "xregexp":
      {
        "root": "%s/data/xregexp/" % os.environ["XREGEXP_ROOT"],
        "rx": re.compile(r"^[-a-z0-9]+(?:-min)?\.js$")
      }
    }

    MIN = (os.path.exists("%s/overview-min.html" % ROOT) and "-min") or ""
    frontpage = "overview/overview%s.html" % MIN
    viewhtml = glob(ROOT + "view-*" + MIN + ".html")
    viewcssref = ["overview/%s" % x.rsplit("/", 1)[1]
                   for x in glob(ROOT + "view-*" + MIN + ".css")]
    viewjsref = ["overview/%s" % x.rsplit("/", 1)[1]
                 for x in glob(ROOT + "view-*" + MIN + ".js")]
    cssref = "@MOUNT@/static?" + "&".join(["yui/cssreset/reset%s.css" % MIN,
                                           "yui/cssfonts/fonts%s.css" % MIN,
                                           "yui/cssgrids/grids%s.css" % MIN,
                                           "yui/cssbase/base%s.css" % MIN,
                                           "overview/overview%s.css" % MIN,
                                           "overview/button%s.css" % MIN,
                                           "overview/popup-menu%s.css" % MIN,
                                           "overview/world-map%s.css" % MIN]
                                          + viewcssref)
    jsref = "@MOUNT@/static?" + "&".join(["rest/preamble.js",
                                          "yui/yui/yui%s.js" % MIN,
                                          "polymaps/polymaps%s.js" % MIN.replace("-", ".")] +
                                         ["d3/d3/d3%s%s.js" % (x, MIN.replace("-", "."))
                                          for x in ("", ".layout", ".chart", ".geo")] +
                                         ["xregexp/xregexp%s%s.js" % (x, MIN)
                                          for x in ("", "-unicode-base",
                                                    "-unicode-categories")] +
                                         ["overview/%s%s.js" % (x, MIN)
                                          for x in ("sprintf", "utils", "time",
                                                    "d3ext", "app", "cache",
                                                    "view")]
                                         + viewjsref +
                                         ["overview/start%s.js" % MIN])

    RESTFrontPage.__init__(self, app, config, mount, frontpage, roots,
                           substitutions = { "CSSREF": cssref, "JSREF": jsref },
                           embeddings = { "VIEWHTML": viewhtml })