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


Python command.PythonCmd类代码示例

本文整理汇总了Python中tactic.command.PythonCmd的典型用法代码示例。如果您正苦于以下问题:Python PythonCmd类的具体用法?Python PythonCmd怎么用?Python PythonCmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: verify

    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,代码行数:27,代码来源:ad_authenticate.py

示例2: delete_files

    def delete_files(my, nodes):

        # clean out all of the files
        for node in nodes:
            name = my.xml.get_node_name(node)

            if name == "include":
                path = my.xml.get_attribute(node, "path")
                if not path:
                    print("WARNING: No path found for search type in manifest")
                    continue

                path = "%s/%s" % (my.plugin_dir, path)

                if path.endswith(".py"):
                    from tactic.command import PythonCmd
                    cmd = PythonCmd(file_path=path)
                    manifest = cmd.execute()
                    if manifest:
                        xml = Xml()
                        xml.read_string(manifest)
                        include_nodes = xml.get_nodes("manifest/*")

                        my.delete_files(include_nodes)
            elif name == "python":
                # don't delete python node file
                pass
            else:
                path = my.get_path_from_node(node)
                if path and os.path.exists(path):
                    print "Deleting: ", path
                    os.unlink(path)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py

示例3: handle_include

    def handle_include(my, node):
        path = my.xml.get_attribute(node, "path")
        if not path:
            raise TacticException("No path found for include in manifest")

        path = "%s/%s" % (my.plugin_dir, path)

        if path.endswith(".py"):
            from tactic.command import PythonCmd
            cmd = PythonCmd(file_path=path)
            manifest = cmd.execute()

        if not manifest:
            print "No manifest discovered in [%s]" %path
            return

        xml = Xml()
        xml.read_string(manifest)
        nodes = xml.get_nodes("manifest/*")

        sobjects = []
        for i, node in enumerate(nodes):
            name = my.xml.get_node_name(node)
            if name == 'sobject':
                dumped_sobjects = my.handle_sobject(node)
                if not dumped_sobjects:
                    dumped_sobjects = []
                sobjects.extend(dumped_sobjects)
            elif name == 'search_type':
                my.handle_search_type(node)
            elif name == 'include':
                my.handle_include(node)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py

示例4: get_result

 def get_result(my, sobject):
     result = None
     sobject_dict = sobject.get_sobject_dict()
     filter_data = my.filter_data.get_data()
     try:
         cmd = PythonCmd(code=my.code, sobject=sobject_dict, filter_data=filter_data)
         result = cmd.execute()
     except Exception, e:
         return str(e)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:9,代码来源:python_element_wdg.py

示例5: get_text_value

    def get_text_value(my):

        sobject = my.get_current_sobject()
        sobject_dict = sobject.get_sobject_dict()

        try:
            cmd = PythonCmd(code=my.code, sobject=sobject_dict)
            result = cmd.execute()
        except Exception, e:
            return str(e)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:10,代码来源:python_element_wdg.py

示例6: get_display

    def get_display(my):

        script_path = my.kwargs.get("script_path")
        if not script_path:
            return {}

        python_cmd = PythonCmd(**my.kwargs)

        ret_val = python_cmd.execute()

        return ret_val
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:python_rest_handler.py

示例7: alter_search

    def alter_search(my, search):
        script_path = my.get_option("alter_search_script_path")
        script_code = my.get_option("alter_search_script_code")

        from tactic.command import PythonCmd
        if script_path:
            cmd = PythonCmd(script_path=script_path, values=my.values, search=search, show_title=my.show_title)
        elif script_code:
            cmd = PythonCmd(script_code=script_code, values=my.values, search=search, show_title=my.show_title)

        cmd.execute()
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:11,代码来源:custom_layout_wdg.py

示例8: get_display

    def get_display(self):
        script_path = self.get_option("script_path")
        script_code = self.get_option("script_code")

        from tactic.command import PythonCmd
        if script_path:
            cmd = PythonCmd(script_path=script_path, values=self.values, search=search, show_title=self.show_title)
        elif script_code:
            cmd = PythonCmd(script_code=script_code, values=self.values, search=search, show_title=self.show_title)

        cmd.execute()
开发者ID:mincau,项目名称:TACTIC,代码行数:11,代码来源:checkin_trigger.py

示例9: preprocess

    def preprocess(my):
        code = my.kwargs.get('data')
        if not code:
            my.data = {}
            return
        
        # preprocess using mako
        #include_mako = my.kwargs.get("include_mako")
        #if not include_mako:
        #    include_mako = my.view_attrs.get("include_mako")

        from tactic.command import PythonCmd
        python_cmd = PythonCmd(code=code)
        my.data = python_cmd.execute()
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:14,代码来源:custom_layout_wdg.py

示例10: handle_include

    def handle_include(my, node):
        path = my.xml.get_attribute(node, "path")
        if not path:
            raise TacticException("No path found for search type in manifest")

        path = "%s/%s" % (my.plugin_dir, path)

        if path.endswith(".py"):
            from tactic.command import PythonCmd
            cmd = PythonCmd(file_path=path)
            manifest = cmd.execute()

        xml = Xml()
        xml.read_string(manifest)
        nodes = xml.get_nodes("manifest/*")
        nodes.reverse()

        my.handle_nodes(nodes)
开发者ID:blezek,项目名称:TACTIC,代码行数:18,代码来源:plugin.py

示例11: handle_python

    def handle_python(my, node):
        '''during uninstall, handle the python undo_path'''
        path = my.xml.get_attribute(node, "undo_path")
        
        # if no path, then nothing to undo
        if not path:
            print "No undo_path defined for this python node"
            return

        if not path.endswith('.py'):
            raise TacticException("Path should have the .py extension for python in manifest")

        path = "%s/%s" % (my.plugin_dir, path)
        if not os.path.exists(path):
            raise TacticException("Undo Path [%s] does not exist python in manifest" %path)
        if path.endswith(".py"):
            from tactic.command import PythonCmd
            cmd = PythonCmd(file_path=path)
            cmd.execute()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:19,代码来源:plugin.py

示例12: get_text_value

    def get_text_value(self):

        sobject = self.get_current_sobject()
        sobject_dict = sobject.get_sobject_dict()

        try:
            cmd = PythonCmd(code=self.code, sobject=sobject_dict)
            result = cmd.execute()
        except Exception as e:
            return str(e)

        if result == "":
            return result

        sobject.set_value(self.get_name(), result, temp=True)
        display_format = self.get_option("display_format")
        if display_format:
            expr = "@FORMAT(@GET(.%s), '%s')" % (self.get_name(), display_format)
            result = Search.eval(expr, sobject, single=True)
        return result
开发者ID:mincau,项目名称:TACTIC,代码行数:20,代码来源:python_element_wdg.py

示例13: run_callback

    def run_callback(my, pipeline, process, status):

        # get the node triggers
        # TODO: make this more efficient
        search = Search("config/process")        
        search.add_filter("pipeline_code", pipeline.get_code())
        search.add_filter("process", process)
        process_sobj = search.get_sobject()

        #print "callback process: ", process, pipeline.get_code()
        if not process_sobj:
            raise TacticException('Process item [%s] has not been created. Please save your pipeline in the Project Workflow Editor to refresh the processes.'%process)



        triggers = {}
        if process_sobj:
            triggers = process_sobj.get_json_value("workflow")
        if not triggers:
            triggers = {}

        ret_val = None

        action = triggers.get("on_%s" % status)
        js_action = triggers.get("cbjs_%s" % status)
        action_path = triggers.get("on_%s_path" % status)

        kwargs, input = my.build_trigger_input()
        if action or action_path:
            from tactic.command import PythonCmd
            if action:
                cmd = PythonCmd(code=action, input=input, **kwargs)
            else:
                cmd = PythonCmd(script_path=script_path, input=input, **kwargs)

            ret_val = cmd.execute()

        elif js_action:
            from tactic.command import JsCmd
            if action:
                cmd = JsCmd(code=action, input=input, **kwargs)
            else:
                cmd = JsCmd(script_path=script_path, input=input, **kwargs)

            ret_val = cmd.execute()
        else:
            # or call a trigger
            event = "process|%s" % status

            # how to get the value here?
            process_code = process_sobj.get_code()
            triggers = Trigger.call(my, event, kwargs, process=process_code)
            if triggers:
                ret_val = triggers[0].get_ret_val()

        return ret_val
开发者ID:jayvdb,项目名称:TACTIC,代码行数:56,代码来源:workflow.py

示例14: handle_action

    def handle_action(my):
        my.log_message(my.sobject, my.process, "in_progress")

        process_obj = my.pipeline.get_process(my.process)

        # get the node's triggers
        search = Search("config/process")        
        search.add_filter("process", my.process)
        search.add_filter("pipeline_code", my.pipeline.get_code())
        process_sobj = search.get_sobject()

        #process_sobj = my.pipeline.get_process_sobject(my.process)


        triggers = {}
        if process_sobj:
            triggers = process_sobj.get_json_value("workflow")
        if not triggers:
            triggers = {}

        action = triggers.get("on_action")
        cbjs_action = triggers.get("cbjs_action")
        action_path = triggers.get("on_action_path")
        kwargs, input = my.build_trigger_input()
        if action or action_path:
            from tactic.command import PythonCmd
            if action:
                cmd = PythonCmd(code=action, input=input, **kwargs)
            else:
                cmd = PythonCmd(script_path=action_path, input=input, **kwargs)

            ret_val = cmd.execute()

        elif cbjs_action:
            from tactic.command import JsCmd
            if cbjs_action:
                cmd = JsCmd(code=cbjs_action, input=input, **kwargs)
            else:
                cmd = JsCmd(script_path=script_path, input=input, **kwargs)

            ret_val = cmd.execute()
        else:
            # or call an action trigger
            Trigger.call(my, "process|action", input, process=process_sobj.get_code())

        Trigger.call(my, "process|complete", my.input)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:46,代码来源:workflow.py

示例15: execute

    def execute(my):

        file_path = my.kwargs.get("path")
        project_code = my.kwargs.get("project_code")
        base_dir = my.kwargs.get("base_dir")
        search_type = my.kwargs.get("search_type")
        process = my.kwargs.get("process")
        watch_script_path =  my.kwargs.get("script_path")
        if not process:
            process = "publish"

        basename = os.path.basename(file_path)

        context = my.kwargs.get("context")
        if not context:
            context = '%s/%s'  % (process, basename)


        # find the relative_dir and relative_path
        relative_path = file_path.replace("%s/" % base_dir, "")
        relative_dir = os.path.dirname(relative_path)

        file_name = os.path.basename(file_path)
        log_path = '%s/TACTIC_log.txt' %(base_dir)
        my.create_checkin_log()

        # Define asset type of the file
        asset_type = my.get_asset_type(file_path)
        description = "drop folder check-in of %s" %file_name

        from client.tactic_client_lib import TacticServerStub
        server = TacticServerStub.get(protocol='local')
        server.set_project(project_code)

        transaction = Transaction.get(create=True)
        server.start(title='Check-in of media', description='Check-in of media')

        server_return_value = {}

        try:
            filters = [
                    [ 'name', '=', file_name ],
                    #[ 'relative_dir', '=', relative_dir ]
                ]
            sobj = server.query(search_type, filters=filters, single=True)

            if not sobj:
                # create sobject if it does not yet exist
                sobj = SearchType.create(search_type)
                if SearchType.column_exists(search_type, "name"):
                    sobj.set_value("name", basename)
                if SearchType.column_exists(search_type, "media_type"):
                    sobj.set_value("media_type", asset_type)


                if SearchType.column_exists(search_type, "relative_dir"):
                    sobj.set_value("relative_dir", relative_dir)

                if SearchType.column_exists(search_type, "keywords"):
                    relative_path = relative_path
                    keywords = Common.get_keywords_from_path(relative_path)
                    keywords = " ".join( keywords )
                    sobj.set_value("keywords", keywords)

                sobj.commit()
                search_key = sobj.get_search_key()
            else:
                search_key = sobj.get("__search_key__")


            #task = server.create_task(sobj.get('__search_key__'),process='publish')
            #server.update(task, {'status': 'New'})


            server_return_value = server.simple_checkin(search_key,  context, file_path, description=description, mode='move')

            if watch_script_path:
                cmd = PythonCmd(script_path=watch_script_path,search_type=search_type,drop_path=file_path,search_key=search_key)
                cmd.execute()




            
        except Exception, e:
            print "Error occurred", e
            error_message=str(e)

            import traceback
            tb = sys.exc_info()[2]
            stacktrace = traceback.format_tb(tb)
            stacktrace_str = "".join(stacktrace)
            print "-"*50
            print stacktrace_str


            version_num='Error:'
            system_time=strftime("%Y/%m/%d %H:%M", gmtime())
            pre_log=file_name+(50-len(file_name))*' '+system_time+(33-len(system_time))*' '+version_num+(15-len(version_num))*' ' +error_message+'\n'\
                    + stacktrace_str + '\n' + watch_script_path
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:watch_drop_folder.py


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