Ejemplo n.º 1
0
def _init_controllers():
    """Here we init all the controllers of the bewype namespace before running
    the app.
    """
    # simple shortcut
    _namespace = "bewype.flask.controllers"
    # controllers name space
    _controllers_package = importString(_namespace)
    # controllers all paths
    _controllers_paths = _controllers_package.__path__
    # ...
    for _p in _controllers_paths:
        for _f in os.listdir(_p):
            # simple check
            if '__init__.' in _f\
            or os.path.splitext(_f)[-1] != '.py':
                continue
            # do init
            else:
                _controller_name = os.path.splitext(_f)[0]
                _c = importString("%s.%s" % (_namespace, _controller_name))
                # prepare module name - custom bewype
                _m_name = 'module_%s' % _controller_name
                # module check
                if hasattr(_c, _m_name):
                    # get module
                    _m = getattr(_c, _m_name)
                    _controller_name
                    # get templates search path
                    _search_path = _m.jinja_loader.searchpath
                    # update jinja loader templates search path
                    app.jinja_loader.searchpath.extend(_search_path)
Ejemplo n.º 2
0
def findPackage(pkg):
    """Find containing package (module w/'__path__') for module named 'pkg'"""

    mod = importString(pkg)

    while not hasattr(mod, '__path__') and '.' in pkg:
        pkg = '.'.join(pkg.split('.')[:-1])
        mod = importString(pkg)

    return pkg, mod
Ejemplo n.º 3
0
def run_command(args):
    command_class = {}
    command_imports = (
        ('ca_create_ca', 'zato.cli.ca_create_ca.Create'),
        ('ca_create_lb_agent', 'zato.cli.ca_create_lb_agent.Create'),
        ('ca_create_server', 'zato.cli.ca_create_server.Create'),
        ('ca_create_web_admin', 'zato.cli.ca_create_web_admin.Create'),
        ('check_config', 'zato.cli.check_config.CheckConfig'),
        ('component_version', 'zato.cli.component_version.ComponentVersion'),
        ('create_cluster', 'zato.cli.create_cluster.Create'),
        ('create_lb', 'zato.cli.create_lb.Create'),
        ('create_odb', 'zato.cli.create_odb.Create'),
        ('create_server', 'zato.cli.create_server.Create'),
        ('create_user', 'zato.cli.web_admin_auth.CreateUser'),
        ('create_web_admin', 'zato.cli.create_web_admin.Create'),
        ('delete_odb', 'zato.cli.delete_odb.Delete'),
        ('decrypt', 'zato.cli.crypto.Decrypt'),
        ('encrypt', 'zato.cli.crypto.Encrypt'),
        ('enmasse', 'zato.cli.enmasse.EnMasse'),
        ('from_config', 'zato.cli.FromConfig'),
        ('info', 'zato.cli.info.Info'),
        ('migrate', 'zato.cli.migrate.Migrate'),
        ('quickstart_create', 'zato.cli.quickstart.Create'),
        ('service_invoke', 'zato.cli.service.Invoke'),
        ('start', 'zato.cli.start.Start'),
        ('stop', 'zato.cli.stop.Stop'),
        ('update_crypto', 'zato.cli.crypto.UpdateCrypto'),
        ('update_password', 'zato.cli.web_admin_auth.UpdatePassword'),
        ('update_openid', 'zato.cli.web_admin_auth.UpdateOpenID'),
    )
    for k, v in command_imports:
        command_class[k] = importString(v)
        
    command_class[args.command](args).run(args)
Ejemplo n.º 4
0
def run_command(args):
    command_class = {}
    command_imports = (
        ('ca_create_ca', 'zato.cli.ca_create_ca.Create'),
        ('ca_create_lb_agent', 'zato.cli.ca_create_lb_agent.Create'),
        ('ca_create_server', 'zato.cli.ca_create_server.Create'),
        ('ca_create_web_admin', 'zato.cli.ca_create_web_admin.Create'),
        ('check_config', 'zato.cli.check_config.CheckConfig'),
        ('component_version', 'zato.cli.component_version.ComponentVersion'),
        ('create_cluster', 'zato.cli.create_cluster.Create'),
        ('create_lb', 'zato.cli.create_lb.Create'),
        ('create_odb', 'zato.cli.create_odb.Create'),
        ('create_server', 'zato.cli.create_server.Create'),
        ('create_user', 'zato.cli.web_admin_auth.CreateUser'),
        ('create_web_admin', 'zato.cli.create_web_admin.Create'),
        ('delete_odb', 'zato.cli.delete_odb.Delete'),
        ('decrypt', 'zato.cli.crypto.Decrypt'),
        ('encrypt', 'zato.cli.crypto.Encrypt'),
        ('enmasse', 'zato.cli.enmasse.EnMasse'),
        ('from_config', 'zato.cli.FromConfig'),
        ('info', 'zato.cli.info.Info'),
        ('quickstart_create', 'zato.cli.quickstart.Create'),
        ('service_invoke', 'zato.cli.service.Invoke'),
        ('start', 'zato.cli.start.Start'),
        ('stop', 'zato.cli.stop.Stop'),
        ('update_crypto', 'zato.cli.crypto.UpdateCrypto'),
        ('update_password', 'zato.cli.web_admin_auth.UpdatePassword'),
        ('update_openid', 'zato.cli.web_admin_auth.UpdateOpenID'),
    )
    for k, v in command_imports:
        command_class[k] = importString(v)

    command_class[args.command](args).run(args)
Ejemplo n.º 5
0
def run_command(args):
    command_class = {}
    command_imports = (
        ("ca_create_ca", "zato.cli.ca_create_ca.Create"),
        ("ca_create_lb_agent", "zato.cli.ca_create_lb_agent.Create"),
        ("ca_create_server", "zato.cli.ca_create_server.Create"),
        ("ca_create_web_admin", "zato.cli.ca_create_web_admin.Create"),
        ("check_config", "zato.cli.check_config.CheckConfig"),
        ("component_version", "zato.cli.component_version.ComponentVersion"),
        ("create_cluster", "zato.cli.create_cluster.Create"),
        ("create_lb", "zato.cli.create_lb.Create"),
        ("create_odb", "zato.cli.create_odb.Create"),
        ("create_server", "zato.cli.create_server.Create"),
        ("create_user", "zato.cli.web_admin_auth.CreateUser"),
        ("create_web_admin", "zato.cli.create_web_admin.Create"),
        ("delete_odb", "zato.cli.delete_odb.Delete"),
        ("decrypt", "zato.cli.crypto.Decrypt"),
        ("encrypt", "zato.cli.crypto.Encrypt"),
        ("enmasse", "zato.cli.enmasse.EnMasse"),
        ("from_config", "zato.cli.FromConfig"),
        ("info", "zato.cli.info.Info"),
        ("migrate", "zato.cli.migrate.Migrate"),
        ("quickstart_create", "zato.cli.quickstart.Create"),
        ("service_invoke", "zato.cli.service.Invoke"),
        ("start", "zato.cli.start.Start"),
        ("stop", "zato.cli.stop.Stop"),
        ("update_crypto", "zato.cli.crypto.UpdateCrypto"),
        ("update_password", "zato.cli.web_admin_auth.UpdatePassword"),
        ("update_openid", "zato.cli.web_admin_auth.UpdateOpenID"),
    )
    for k, v in command_imports:
        command_class[k] = importString(v)

    command_class[args.command](args).run(args)
Ejemplo n.º 6
0
    def __parent__(self, d, a):

        parent = self.__module__
        name = self.__name__

        if '.' in name:
            name = '.'.join(name.split('.')[:-1])
            parent = '%s:%s' % (parent, name)

        return importString(parent),
Ejemplo n.º 7
0
    def _run(self):
        args = self.parsed_args
        if len(args) > 1:
            raise InvocationError('too many arguments')

        cprt = 'Type "copyright", "credits" or "license" for more information.'
        help = 'Type "help" or "help(n2)" for help.'

        self.banner = 'PEAK N2 (Python %s on %s)\n%s\n%s' % (sys.version.split(
            None, 1)[0], sys.platform, cprt, help)

        self.idict['n2'] = self

        exec 'from peak.api import *' in self.idict
        exec 'import pdb' in self.idict

        for cmd in ('cd', 'ls'):
            self.idict[cmd] = getattr(self, 'py_' + cmd)

        storage.begin(self)

        try:
            if args:
                c = naming.lookup(self, args[0])
            else:
                c = naming.InitialContext(self)

            if self.adapt_to is not None:
                iface = importString(self.adapt_to)
                c = adapt(c, iface)
                self.py_anyway = True
        except:
            if self.force_py or self.py_anyway:
                c = None
                sys.excepthook(*sys.exc_info())  # XXX
                print >> self.stderr
            else:
                raise

        self.idict['c'] = self.idict['__c__'] = c
        self.idict['pwd'] = ` c `

        self.handle(c)

        try:
            storage.abort(self)
        except:
            pass

        return 0
Ejemplo n.º 8
0
def run_command(args):
    command_class = {}
    command_imports = (
        ('apispec', 'zato.cli.apispec.APISpec'),
        ('ca_create_ca', 'zato.cli.ca_create_ca.Create'),
        ('ca_create_lb_agent', 'zato.cli.ca_create_lb_agent.Create'),
        ('ca_create_scheduler', 'zato.cli.ca_create_scheduler.Create'),
        ('ca_create_server', 'zato.cli.ca_create_server.Create'),
        ('ca_create_web_admin', 'zato.cli.ca_create_web_admin.Create'),
        ('check_config', 'zato.cli.check_config.CheckConfig'),
        ('component_version', 'zato.cli.component_version.ComponentVersion'),
        ('create_cluster', 'zato.cli.create_cluster.Create'),
        ('create_lb', 'zato.cli.create_lb.Create'),
        ('create_odb', 'zato.cli.create_odb.Create'),
        ('create_scheduler', 'zato.cli.create_scheduler.Create'),
        ('create_server', 'zato.cli.create_server.Create'),
        ('create_secret_key', 'zato.cli.crypto.CreateSecretKey'),
        ('create_user', 'zato.cli.web_admin_auth.CreateUser'),
        ('create_web_admin', 'zato.cli.create_web_admin.Create'),
        ('crypto_create_secret_key', 'zato.cli.crypto.CreateSecretKey'),
        ('delete_odb', 'zato.cli.delete_odb.Delete'),
        ('decrypt', 'zato.cli.crypto.Decrypt'),
        ('encrypt', 'zato.cli.crypto.Encrypt'),
        ('enmasse', 'zato.cli.enmasse.EnMasse'),
        ('from_config', 'zato.cli.FromConfig'),
        ('hash_get_rounds', 'zato.cli.crypto.GetHashRounds'),
        ('info', 'zato.cli.info.Info'),
        ('migrate', 'zato.cli.migrate.Migrate'),
        ('quickstart_create', 'zato.cli.quickstart.Create'),
        ('service_invoke', 'zato.cli.service.Invoke'),
        ('update_crypto', 'zato.cli.crypto.UpdateCrypto'),
        ('sso_change_user_password', 'zato.cli.sso.ChangeUserPassword'),
        ('sso_create_odb', 'zato.cli.sso.CreateODB'),
        ('sso_create_user', 'zato.cli.sso.CreateUser'),
        ('sso_create_super_user', 'zato.cli.sso.CreateSuperUser'),
        ('sso_delete_user', 'zato.cli.sso.DeleteUser'),
        ('sso_lock_user', 'zato.cli.sso.LockUser'),
        ('sso_reset_user_password', 'zato.cli.sso.ResetUserPassword'),
        ('sso_unlock_user', 'zato.cli.sso.UnlockUser'),
        ('start', 'zato.cli.start.Start'),
        ('stop', 'zato.cli.stop.Stop'),
        ('update_password', 'zato.cli.web_admin_auth.UpdatePassword'),
    )
    for k, v in command_imports:
        command_class[k] = importString(v)

    command_class[args.command](args).run(args)
Ejemplo n.º 9
0
class Expects(Element):
    """Render child elements with target data, or skip element altogether"""

    staticText = None

    dataSpec = ''  # to disable conversion to path

    protocol = binding.Make(lambda self: imports.importString(self.dataSpec),
                            uponAssembly=True)

    def renderFor(self, data, state):

        data = data.clone(current=adapt(data.current, self.protocol))

        state.write(self._openTag)
        for child in self.optimizedChildren:
            child.renderFor(data, state)
        state.write(self._closeTag)
Ejemplo n.º 10
0
    def find(self, name):
        if naming.URLMatch(name):
            ob = self.lookupComponent(name, NOT_FOUND)
            if ob is not NOT_FOUND:
                return ob
        try:
            name = str(PropertyName(name.replace(':', '.')))
        except exceptions.InvalidName:
            raise InvocationError("Invalid format for argument %r" % name)

        for prefix in ('peak.api.', 'peak.', ''):
            try:
                return importString(prefix + name)
            except ImportError:
                pass

        for prefix in ('peak.running.shortcuts.', 'peak.help.'):
            ob = self.lookupComponent(
                PropertyName('peak.running.shortcuts.' + name), NOT_FOUND)
            if ob is not NOT_FOUND:
                return ob

        raise InvocationError("Can't find help on %r" % name)
Ejemplo n.º 11
0
 def config(self):
     config = self.settings['config']
     return importString(config)
Ejemplo n.º 12
0
    def _get(self, name, retrieve=1):

        try:
            return importString(name.body)
        except ImportError:
            return NOT_FOUND
Ejemplo n.º 13
0
 def __call__(self, component, instDict, attrName):
     return adapt(importString(self.subject), IRecipe)(component, instDict,
                                                       attrName)
Ejemplo n.º 14
0
def fileNearModule(moduleName,filename):
    """DEPRECATED: please switch to 'config.packageFile()' or a URL"""
    filebase = importString(moduleName+':__file__')
    import os; return os.path.join(os.path.dirname(filebase), filename)
Ejemplo n.º 15
0
 def onImport(module):
     iface = importString(name)
     pMap.registerProvider(
         FactoryFor(iface),
         ruleForExpr(name, "importObject(%s)" % value, globalDict))
     pMap.registerProvider(iface, CreateViaFactory(iface))
Ejemplo n.º 16
0
 def config(self):
     settings = get_settings()
     config = settings['config']
     return importString(config)