当前位置: 首页>>代码示例>>Python>>正文


Python Config.get_value方法代码示例

本文整理汇总了Python中pyasm.common.Config.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get_value方法的具体用法?Python Config.get_value怎么用?Python Config.get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.common.Config的用法示例。


在下文中一共展示了Config.get_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: verify

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def verify(my, login_name, password):
        # replace cn=attribute with cn={login} in the config ldap_path
        # e.g. cn={login},o=organization,ou=server,dc=domain
        path = Config.get_value("security", "ldap_path")
        server = Config.get_value("security", "ldap_server")
        assert path, server

        my.login_name = login_name
        my.internal = True
        path = path.replace("{login}", login_name)
        #import ldap

        try:
            l = ldap.open(server)
            l.simple_bind_s(path, password)
            l.unbind()
            return True
        except: 
            login = Login.get_by_login(login_name)
            # check if it's an external account and verify with standard approach
            if login and login.get_value('location', no_exception=True) == 'external':
                auth_class = "pyasm.security.TacticAuthenticate"
                authenticate = Common.create_from_class_path(auth_class)
                is_authenticated = authenticate.verify(login_name, password)
                if is_authenticated == True:
                    my.internal = False
                    return True
            elif login:
                auth_class = "pyasm.security.TacticAuthenticate"
                authenticate = Common.create_from_class_path(auth_class)
                is_authenticated = authenticate.verify(login_name, password)
                if is_authenticated == True:
                    my.internal = False
                    return True
            raise SecurityException("Login/Password combination incorrect")
开发者ID:2gDigitalPost,项目名称:custom,代码行数:37,代码来源:ldap_authenticate.py

示例2: draw

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def draw(self):
        self.add_shortcuts()
        data_dir = tacticenv.get_data_dir()

        if os.path.exists(data_dir):
            geometry = Config.get_value("window", "geometry")
            title = Config.get_value("window", "title")
        else:
            geometry = None
            title = None

        if not title:
            title = "TACTIC - %s" % self.url
            geometry = Config.get_value("window", "geometry")
        
        if geometry == "fullscreen":
            self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
            self.showFullScreen()
        elif geometry:
            parts = geometry.split(",")
            parts = [int(x) for x in parts]
            self.setGeometry(parts[0], parts[1], parts[2], parts[3])

        self.splash.finish(self)
        self.setWindowTitle(title)
        self.setCentralWidget(self.webView)  
        self.show()  
开发者ID:Southpaw-TACTIC,项目名称:Team,代码行数:29,代码来源:python_applet.py

示例3: _do_login

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def _do_login(self):

        security = Environment.get_security()

        require_password = Config.get_value("security", "api_require_password")
        api_password = Config.get_value("security", "api_password")

        site = Site.get()
        allow_guest =  site.allow_guest()

        # the xmlrpc login can be overridden to not require a password
        if require_password == "false" or (allow_guest and self.login_name == "guest"):
            security.login_user_without_password(self.login_name, expiry="NULL")
        elif api_password:
            if api_password == self.password:
                security.login_user_without_password(self.login_name, expiry="NULL")
            else:
                # if api password is incorrect, still try and authenticate with
                # user's password
                security.login_user(self.login_name, self.password, expiry="NULL")
        elif self.login_name == "guest":
                security.login_user_without_password(self.login_name)
        else:        
            security.login_user(self.login_name, self.password, expiry="NULL")

        if not security.is_logged_in():
            raise SecurityException("Cannot login as user: %s." % self.login_name)
开发者ID:mincau,项目名称:TACTIC,代码行数:29,代码来源:batch.py

示例4: _test_cache

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def _test_cache(self):
        from pyasm.common import Config

        Config.set_value("security", "mode", "cache", no_exception=True)
        #Config.set_value("security", "authenticate_class", "pyasm.security.authenticate_test.AutocreateAuthenticate", no_exception=True)
        Config.set_value("security", "authenticate_class", "pyasm.security.mms_authenticate.MMSAuthenticate", no_exception=True)
        mode = Config.get_value("security", "authenticate_class", use_cache=False)

        mode = Config.get_value("security", "mode", use_cache=False)
        self.assertEquals(mode, "cache")


        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertEquals(None, login)


        from pyasm.search import Transaction
        transaction = Transaction.get(create=True)
        transaction.start()

        self.security.login_user("foofoo", "wow")

        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertNotEquals(None, login)
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:authenticate_test.py

示例5: verify

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def verify(self, login_name, password):
            
        if login_name.find("\\") != -1:
            domain, base_login_name = login_name.split("\\")
        else:
            base_login_name = login_name
            domain = None

        # confirm that there is a domain present if required
        require_domain = Config.get_value("active_directory", "require_domain")
        domain_component = Config.get_value("active_directory","domain_component")
        script_path = Config.get_value("active_directory","allow_script")
        
        if script_path:
            flag = False
            try:
                from tactic.command import PythonCmd
                from pyasm.command import Command
                kwargs = {'login' : login_name}
                cmd = PythonCmd(script_path=script_path, **kwargs)
                #flag = Command.execute_cmd(cmd)
                flag = cmd.execute()
            except Exception, e:
                print e
                raise
            if flag != True:
                return False  
开发者ID:mincau,项目名称:TACTIC,代码行数:29,代码来源:ad_authenticate.py

示例6: _test_strict_checkin

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def _test_strict_checkin(my):

        server = Config.get_value("install", "server")
        process = "process"
        person_code = my.person.get_code()

        filename = "filename.jpg"

        process = "strict"

        subcontexts = [
            '', '', # do 2 checkins
            'hi', 'hi',
            'medium',
            'low',
        ]

        for i, subcontext in enumerate(subcontexts):

            if subcontext:
                context = "%s/%s" % (process, subcontext)
            else:
                context = process

            # create a new test.txt file
            file_path = "./%s" % filename
            file = open(file_path, 'w')
            file.write("test")
            file.close()


            #import time
            #start = time.time()

            checkin = FileCheckin(my.person, file_path, context=context, checkin_type='strict')
            checkin.execute()
            snapshot = checkin.get_snapshot()

            #print "time: ", time.time() - start
            #print "---"

            # make sure there is no versionless
            versionless = Snapshot.get_versionless(my.person.get_search_type(), my.person.get_id(), context, mode='latest', create=False)
            my.assertEquals(None, versionless)

            
            path = snapshot.get_path_by_type("main")

            asset_dir = Config.get_value("checkin", "asset_base_dir")

            file_objects = snapshot.get_all_file_objects()
            my.assertEquals(1, len(file_objects))

            file_object = file_objects[0]
            relative_dir = file_object.get_value("relative_dir")
            file_name = file_object.get_value("file_name")

            test_path = "%s/%s/%s" % (asset_dir, relative_dir, file_name)
            my.assertEquals(test_path, path)
开发者ID:blezek,项目名称:TACTIC,代码行数:61,代码来源:checkin_test.py

示例7: do_startup

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
def do_startup(port, server=""):

    #from tactic.startup import FirstRunInit
    #cmd = FirstRunInit()
    #cmd.execute()

    if os.name != 'nt' and os.getuid() == 0:
        print 
        print "You should not run this as root. Run it as the Web server process's user. e.g. apache"
        print
	return

    thread_count = Config.get_value("services", "thread_count") 
    

    if not thread_count:
        thread_count = 10
    else: 
        thread_count = int(thread_count)


    from pyasm.web.cherrypy30_startup import CherryPyStartup
    startup = CherryPyStartup()

    startup.set_config('global', 'server.socket_port', port)

    startup.set_config('global', 'server.socket_queue_size', 100)
    startup.set_config('global', 'server.thread_pool', thread_count)
    #startup.set_config('global', 'server.socket_host', server)

    #startup.set_config('global', 'log.screen', True)

    startup.set_config('global', 'request.show_tracebacks', True)
    startup.set_config('global', 'server.log_unhandled_tracebacks', True)

    startup.set_config('global', 'engine.autoreload_on', True)




    hostname = None
    server_default = '127.0.0.1'

    if not server:
        hostname = Config.get_value("install", "hostname") 
        if hostname == 'localhost':
            # swap it to IP to suppress CherryPy Warning
            hostname = server_default
        if hostname:
            # special host name for IIS which can't load balance across many
            # ports with the same service
            hostname = hostname.replace("{port}", str(port))
            server = hostname
        else:
            server = server_default
       
    startup.set_config('global', 'server.socket_host', server)

    startup.execute()
开发者ID:Southpaw-TACTIC,项目名称:Team,代码行数:61,代码来源:startup_standalone.py

示例8: get_local_dir

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def get_local_dir(self):
        '''get the local asset directory on the client machine'''
        user_agent = self.get_env("HTTP_USER_AGENT")
        if user_agent.startswith("Houdini"):
            dir = Config.get_value("checkin", "win32_local_base_dir")

        elif user_agent.find("Windows") != -1:
            dir = Config.get_value("checkin", "win32_local_base_dir")
        else:
            dir = Config.get_value("checkin", "linux_local_base_dir")

        return dir
开发者ID:mincau,项目名称:TACTIC,代码行数:14,代码来源:web_environment.py

示例9: execute

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def execute(my):
        hostname = my.kwargs.get("hostname")
        if not hostname:
            hostname = Config.get_value("install", "hostname")

        port = my.kwargs.get("port")
        if not port:
            port = Config.get_value("install", "port")
        if not port:
            port = 9123
        else:
            port = int(port)

        do_startup(port, server=hostname)
开发者ID:Southpaw-TACTIC,项目名称:Team,代码行数:16,代码来源:startup_standalone.py

示例10: get_otherdb_wdg

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def get_otherdb_wdg(my):

        div = DivWdg()
        div.add_class("spt_db_options")
        div.add_attr("spt_vendor", "Other")
        div.add_style("margin: 20px")

        table = Table()
        div.add(table)
        table.add_color("color", "color")


        table.add_row()
        table.add_cell("Server: ")
        text = TextInputWdg(name="server")
        text.set_value("localhost")
        table.add_cell(text)
        server = Config.get_value("database", "server")
        if server:
            text.set_value(server)

        table.add_row()
        table.add_cell("Port: ")
        text = TextInputWdg(name="port")
        table.add_cell(text)
        port = Config.get_value("database", "port")
        if port:
            text.set_value(port)

        table.add_row()
        table.add_cell("Login: ")
        text = TextInputWdg(name="user")
        table.add_cell(text)
        user = Config.get_value("database", "user")
        if user:
            text.set_value(user)

        table.add_row()
        text = PasswordInputWdg(name="password")
        table.add_cell("Password: ")
        table.add_cell(text)
        password = Config.get_value("database", "password")
        if password:
            text.set_value(password)

        #from pyasm.search import Sql
        #sql.connect()

        return div
开发者ID:blezek,项目名称:TACTIC,代码行数:51,代码来源:db_config_wdg.py

示例11: get_base_url

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def get_base_url(self):
        host = self.get_http_host()

        # see if there is a protocol defined
        protocol = Config.get_value("security", "protocol")
        if not protocol:
            protocol = "http"

        # FIXME: not sure about this.
        if host == "127.0.0.1":
            base_url = Config.get_value("install", "base_url")
        else:
            base_url = "%s://%s" % (protocol, host)

        return Url(base_url)
开发者ID:mincau,项目名称:TACTIC,代码行数:17,代码来源:web_environment.py

示例12: verify

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def verify(my, login_name, password):
        path = Config.get_value("checkin", "ldap_path")
        server = Config.get_value("checkin", "ldap_server")
        assert path, server

        path = path.replace("{login}", login_name)

        import ldap

        try:
            l = ldap.open(server)
            l.simple_bind_s(path, password)
            return True
        except:
            raise SecurityException("Login/Password combination incorrect")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:17,代码来源:authenticate.py

示例13: verify

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def verify(my, login_name, password):
            
        if login_name.find("\\") != -1:
            domain, login_name = login_name.split("\\")
        else:
            domain = None

        # confirm that there is a domain present if required
        require_domain = Config.get_value("active_directory", "require_domain")
        if require_domain == "true" and not domain:
            raise SecurityException("Domain Selection Required")



        # skip authentication if ad does not exist
        if not my.ad_exists:
            print "WARNING: Active directory does not exist ... skipping verify"
            return True

        ad_connect = ADConnect()
        if domain:
            ad_connect.set_domain(domain)
        ad_connect.set_user(login_name)
        ad_connect.set_password(password)
        is_logged_in = ad_connect.logon()

        # preload data for further use later
        if is_logged_in:
            my.load_user_data(login_name)

        return is_logged_in
开发者ID:blezek,项目名称:TACTIC,代码行数:33,代码来源:ad_authenticate.py

示例14: get_skin

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def get_skin(my):
        # DEPRECATED: replaced by palettes

        # TODO: prod setting shouldn't be in prod!!!
        from pyasm.prod.biz import ProdSetting
        web = WebContainer.get_web()
        skin = web.get_form_value("skin")

        # look at users preferences
        if not skin:
            skin = PrefSetting.get_value_by_key("skin")

        # if skin isn't found in user preference settings then look for it
        # in the projects/config XML file ...
        if not skin:
            skin = Config.get_value("look", "skin")

        if not skin:
            skin = "dark"

        # MMS-TACTIC ... allow for 'MMS' skin to be returned for use in overriding some colors (MMS is a copy of
        # 'dark' skin)
        if skin == 'MMS':
            return 'MMS'

        return "dark"
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:28,代码来源:web_environment.py

示例15: run

# 需要导入模块: from pyasm.common import Config [as 别名]
# 或者: from pyasm.common.Config import get_value [as 别名]
    def run(code, kwargs):
        code = jsondumps(code)
        kwargs = jsondumps(kwargs)

        install_dir = tacticenv.get_install_dir()
        cmd = '%s/src/tactic/command/js_cmd.py' % install_dir

        python_exec = Config.get_value("services", "python")
        cmd_list = [python_exec, cmd, code, kwargs]



        import subprocess
        program = subprocess.Popen(cmd_list, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        ret_val, error = program.communicate()

        lines = []
        start = False
        for line in ret_val.split("\n") :
            if line.startswith("~"*20):
                start = True
                continue

            if not start:
                continue

            lines.append(line)

        value = jsonloads("\n".join(lines))


        return value
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:js_cmd.py


注:本文中的pyasm.common.Config.get_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。