def on_in(query_name, host_key, schema_key):
    """\
    @brief Constructs an on/in snippet (for running named queries)
    from a schema name and two keys referencing values stored in
    indra.xml.

    @param query_name Name of the query.
    @param host_key Logical name of destination host.  Will be
        looked up in indra.xml.
    @param schema_key Logical name of destination schema.  Will
        be looked up in indra.xml.
    """
    host_name = config.get(host_key)
    schema_name = config.get(schema_key)
    return '/'.join( ('on', host_name, 'in', schema_name, query_name.lstrip('/')) )
Beispiel #2
0
def on_in(query_name, host_key, schema_key):
    """\
    @brief Constructs an on/in snippet (for running named queries)
    from a schema name and two keys referencing values stored in
    indra.xml.

    @param query_name Name of the query.
    @param host_key Logical name of destination host.  Will be
        looked up in indra.xml.
    @param schema_key Logical name of destination schema.  Will
        be looked up in indra.xml.
    """
    host_name = config.get(host_key)
    schema_name = config.get(schema_key)
    return '/'.join(
        ('on', host_name, 'in', schema_name, query_name.lstrip('/')))
Beispiel #3
0
def compile_route(route):
    fp = StringIO()
    last_pos = 0
    for match in route_re.finditer(route):
        #print "matches: ", match.groups()
        fp.write(re.escape(route[last_pos:match.start()]))
        var_name = match.group(1)
        sep = match.group(2)
        expr = match.group(3)
        if var_name == 'config':
            expr = re.escape(str(config.get(var_name)))
        else:
            if expr:
                if sep == ':':
                    expr = predefined_regexps[expr]
                # otherwise, treat what follows '~' as a regexp
            else:
                expr = '[^/]+'
            if var_name != '':
                expr = '(?P<%s>%s)' % (var_name, expr)
            else:
                expr = '(%s)' % (expr,)
        fp.write(expr)
        last_pos = match.end()
    fp.write(re.escape(route[last_pos:]))
    compiled_route = '^%s$' % fp.getvalue()
    #print route, "->", compiled_route
    return compiled_route
Beispiel #4
0
def compile_route(route):
    fp = StringIO()
    last_pos = 0
    for match in route_re.finditer(route):
        #print "matches: ", match.groups()
        fp.write(re.escape(route[last_pos:match.start()]))
        var_name = match.group(1)
        sep = match.group(2)
        expr = match.group(3)
        if var_name == 'config':
            expr = re.escape(str(config.get(var_name)))
        else:
            if expr:
                if sep == ':':
                    expr = predefined_regexps[expr]
                # otherwise, treat what follows '~' as a regexp
            else:
                expr = '[^/]+'
            if var_name != '':
                expr = '(?P<%s>%s)' % (var_name, expr)
            else:
                expr = '(%s)' % (expr,)
        fp.write(expr)
        last_pos = match.end()
    fp.write(re.escape(route[last_pos:]))
    compiled_route = '^%s$' % fp.getvalue()
    #print route, "->", compiled_route
    return compiled_route
Beispiel #5
0
def get_channel(version_type):
    if version_type == 'viewer':
        settings_file = open(os.path.join(
            get_src_root(), 'indra', 'newview', 'app_settings', 'settings.xml'))
        data = llsd.parse(settings_file.read())
        settings_file.close()
        return data['VersionChannelName']['Value']
    
    config.load()
    return config.get('channel', 'Second Life Server')
Beispiel #6
0
 def buildServiceURL(self, name, context):
     """\
     @brief given the environment on construction, return a service URL.
     @param name The name of the service.
     @param context A dict of name value lookups for the service.
     @returns Returns the 
     """
     base_url = config.get('services-base-url')
     svc_path = russ.format(self.builders[name], context)
     return base_url + svc_path
Beispiel #7
0
 def buildServiceURL(self, name, context):
     """\
     @brief given the environment on construction, return a service URL.
     @param name The name of the service.
     @param context A dict of name value lookups for the service.
     @returns Returns the 
     """
     base_url = config.get('services-base-url')
     svc_path = russ.format(self.builders[name], context)
     return base_url + svc_path
Beispiel #8
0
def _init_g_named_manager(sql_dir = None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')
    global _g_named_manager
    _g_named_manager = NamedQueryManager(
        os.path.abspath(os.path.realpath(sql_dir)))
Beispiel #9
0
def get_channel(version_type):
    if version_type == 'viewer':
        settings_file = open(
            os.path.join(get_src_root(), 'indra', 'newview', 'app_settings',
                         'settings.xml'))
        data = llsd.parse(settings_file.read())
        settings_file.close()
        return data['VersionChannelName']['Value']

    config.load()
    return config.get('channel', 'Second Life Server')
Beispiel #10
0
def _init_g_named_manager(sql_dir=None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')
    global _g_named_manager
    _g_named_manager = NamedQueryManager(
        os.path.abspath(os.path.realpath(sql_dir)))
Beispiel #11
0
def _init_g_named_manager(sql_dir = None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    global NQ_FILE_SUFFIX
    NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
    global NQ_FILE_SUFFIX_LEN
    NQ_FILE_SUFFIX_LEN  = len(NQ_FILE_SUFFIX)

    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')

    # extra fallback directory in case config doesn't return what we want
    if sql_dir is None:
        sql_dir = os.path.abspath(
            os.path.join(
            os.path.realpath(os.path.dirname(__file__)), "..", "..", "..", "..", "web", "dataservice", "sql"))

    global _g_named_manager
    _g_named_manager = NamedQueryManager(
        os.path.abspath(os.path.realpath(sql_dir)))
Beispiel #12
0
def _init_g_named_manager(sql_dir=None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    global NQ_FILE_SUFFIX
    NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
    global NQ_FILE_SUFFIX_LEN
    NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX)

    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')

    # extra fallback directory in case config doesn't return what we want
    if sql_dir is None:
        sql_dir = os.path.abspath(
            os.path.join(os.path.realpath(os.path.dirname(__file__)), "..",
                         "..", "..", "..", "web", "dataservice", "sql"))

    global _g_named_manager
    _g_named_manager = NamedQueryManager(
        os.path.abspath(os.path.realpath(sql_dir)))
Beispiel #13
0
 def buildServiceURL(self, name, context={}, **kwargs):
     """\
     @brief given the environment on construction, return a service URL.
     @param name The name of the service.
     @param context A dict of name value lookups for the service.
     @param kwargs Any keyword arguments are treated as members of the
         context, this allows you to be all 31337 by writing shit like:
         servicebuilder.build('name', param=value)
     @returns Returns the 
     """
     context = context.copy()  # shouldn't modify the caller's dictionary
     context.update(kwargs)
     base_url = config.get('services-base-url')
     svc_path = russ.format(self.builders[name], context)
     return base_url + svc_path
 def buildServiceURL(self, name, context={}, **kwargs):
     """\
     @brief given the environment on construction, return a service URL.
     @param name The name of the service.
     @param context A dict of name value lookups for the service.
     @param kwargs Any keyword arguments are treated as members of the
         context, this allows you to be all 31337 by writing shit like:
         servicebuilder.build('name', param=value)
     @returns Returns the 
     """
     context = context.copy()  # shouldn't modify the caller's dictionary
     context.update(kwargs)
     base_url = config.get('services-base-url')
     svc_path = russ.format(self.builders[name], context)
     return base_url + svc_path
Beispiel #15
0
def _init_g_named_manager(sql_dir = None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')

    # extra fallback directory in case config doesn't return what we want
    if sql_dir is None:
        sql_dir = os.path.dirname(__file__) + "../../../../web/dataservice/sql"

    global _g_named_manager
    _g_named_manager = NamedQueryManager(
        os.path.abspath(os.path.realpath(sql_dir)))
Beispiel #16
0
import time

#import sys # *TODO: remove. only used in testing.
#import pprint # *TODO: remove. only used in testing.

try:
    set = set
except NameError:
    from sets import Set as set

from indra.base import llsd
from indra.base import config

DEBUG = False

NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
NQ_FILE_SUFFIX_LEN  = len(NQ_FILE_SUFFIX)

_g_named_manager = None

def _init_g_named_manager(sql_dir = None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')

    # extra fallback directory in case config doesn't return what we want
    if sql_dir is None:
Beispiel #17
0
import time

# import sys # *TODO: remove. only used in testing.
# import pprint # *TODO: remove. only used in testing.

try:
    set = set
except NameError:
    from sets import Set as set

from indra.base import llsd
from indra.base import config

DEBUG = False

NQ_FILE_SUFFIX = config.get("named-query-file-suffix", ".nq")
NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX)

_g_named_manager = None


def _init_g_named_manager(sql_dir=None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    if sql_dir is None:
        sql_dir = config.get("named-query-base-dir")

    # extra fallback directory in case config doesn't return what we want
Beispiel #18
0
import os.path
import re
import time

#import sys # *TODO: remove. only used in testing.
#import pprint # *TODO: remove. only used in testing.

try:
    set = set
except NameError:
    from sets import Set as set

from indra.base import llsd
from indra.base import config

NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
NQ_FILE_SUFFIX_LEN  = len(NQ_FILE_SUFFIX)

_g_named_manager = None

def _init_g_named_manager(sql_dir = None):
    """Initializes a global NamedManager object to point at a
    specified named queries hierarchy.

    This function is intended entirely for testing purposes,
    because it's tricky to control the config from inside a test."""
    if sql_dir is None:
        sql_dir = config.get('named-query-base-dir')

    # extra fallback directory in case config doesn't return what we want
    if sql_dir is None:
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
$/LicenseInfo$
"""

from indra.base import config
from indra.ipc import llsdhttp
from indra.ipc import russ

# *NOTE: agent presence relies on this variable existing and being current, it is a huge hack
services_config = {}
try:
    services_config = llsdhttp.get(config.get("services-config"))
except:
    pass

_g_builder = None


def build(name, context={}, **kwargs):
    """ Convenience method for using a global, singleton, service builder.  Pass arguments either via a dict or via python keyword arguments, or both!

    Example use:
     > context = {'channel':'Second Life Release', 'version':'1.18.2.0'}
     > servicebuilder.build('version-manager-version', context)
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
     > servicebuilder.build('version-manager-version', channel='Second Life Release', version='1.18.2.0')
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
Beispiel #20
0
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
$/LicenseInfo$
"""

from indra.base import config
from indra.ipc import llsdhttp
from indra.ipc import russ

# *NOTE: agent presence relies on this variable existing and being current, it is a huge hack
services_config = {}
try:
    services_config = llsdhttp.get(config.get('services-config'))
except:
    pass

_g_builder = None
def build(name, context={}, **kwargs):
    """ Convenience method for using a global, singleton, service builder.  Pass arguments either via a dict or via python keyword arguments, or both!

    Example use:
     > context = {'channel':'Second Life Release', 'version':'1.18.2.0'}
     > servicebuilder.build('version-manager-version', context)
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
     > servicebuilder.build('version-manager-version', channel='Second Life Release', version='1.18.2.0')
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
     > servicebuilder.build('version-manager-version', context, version='1.18.1.2')
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.1.2'
Beispiel #21
0
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
$/LicenseInfo$
"""

from indra.base import config
from indra.ipc import llsdhttp
from indra.ipc import russ

# *NOTE: agent presence relies on this variable existing and being current, it is a huge hack
services_config = {}
try:
    services_config = llsdhttp.get(config.get('services-config'))
except:
    pass

_g_builder = None


def build(name, context={}, **kwargs):
    """ Convenience method for using a global, singleton, service builder.  Pass arguments either via a dict or via python keyword arguments, or both!

    Example use:
     > context = {'channel':'Second Life Release', 'version':'1.18.2.0'}
     > servicebuilder.build('version-manager-version', context)
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
     > servicebuilder.build('version-manager-version', channel='Second Life Release', version='1.18.2.0')
       'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'