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


Python common.jsonloads函数代码示例

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


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

示例1: get_files

    def get_files(my):

        paths = []

        # remember this here for now
        my.files = {}

        my.snapshots = {}


        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = SearchKey.get_by_search_key(search_key)
            my.sobjects = [sobject]

        if search_keys:
            if isinstance(search_keys, basestring):
                search_keys = search_keys.replace("'", '"')
                search_keys = jsonloads(search_keys)
            my.sobjects = Search.get_by_search_keys(search_keys)

        if not my.sobjects:
            return []

        my.sobject = my.sobjects[0]


        for sobject in my.sobjects:
            sobject_paths = my.get_sobject_files(sobject)
            paths.extend(sobject_paths)

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

示例2: get_display

    def get_display(my):
        top = my.top
        # top.add_border()

        width = my.kwargs.get("width")
        if not width:
            width = "50px"
        height = my.kwargs.get("height")
        if not height:
            height = "50px"

        class_name = my.kwargs.get("class")
        if class_name:
            top.add_class(class_name)

        top.add_style("width: 100%")
        top.add_border()
        top.add_color("background", "background3")

        font_size = my.kwargs.get("font-size")
        if font_size:
            top.add_style("font-size: %s" % font_size)

        css = my.kwargs.get("css")
        if css:
            css = jsonloads(css)
            for name, value in css.items():
                top.add_style(name, value)

        top.add_style("height: %s" % height)
        top.add_style("width: %s" % width)

        return top
开发者ID:hellios78,项目名称:TACTIC,代码行数:33,代码来源:freeform_layout_wdg.py

示例3: __init__

    def __init__(self, data=[]):

        if not data:
            self.data = []
        elif type(data) in types.StringTypes:
            try:
                # optimize the loading of json data
                json_data = Container.get("json_data")
                if json_data == None:
                    json_data = {}
                    Container.put("json_data", json_data)

                self.data = json_data.get(data)
                if self.data == None:
                    self.data = jsonloads(data)
                    json_data[data] = self.data

            except ValueError, e:
                if e.__str__().find('No JSON object') != -1:
                    raise SetupException('Data is not decodable as JSON.')
                # try a straight eval
                self.data = eval(data)

            except Exception as e:
                 if e.__str__().find('cannot parse JSON description') != -1:
                    raise SetupException('Data is not valid JSON.')
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:filter_data.py

示例4: run

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

示例5: execute

    def execute(my):
        plugin = my.sobject

        web = WebContainer.get_web()
        value = web.get_form_value( my.get_input_name() )
        if not value:
            return
        src_search_keys = jsonloads(value)


        manifest = plugin.get_xml_value("manifest")

        top_node = manifest.get_node("manifest")

        for search_key in src_search_keys:
            sobject = SearchKey.get_by_search_key(search_key)

            node = manifest.create_element("sobject")

            # For now, a plugin must contain project specfic entries
            search_type = sobject.get_base_search_type()
            code = sobject.get_value("code")
            manifest.set_attribute(node, "search_type", search_type)
            manifest.set_attribute(node, "code", code)

            #search_key = SearchKey.get_by_sobject(sobject)
            #manifest.set_attribute(node, "search_key", search_key)

            manifest.append_child(top_node, node)

        plugin.set_value("manifest", manifest.to_string() )
        plugin.commit()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py

示例6: _test_csv_export

    def _test_csv_export(self):
        from tactic.ui.widget import CsvExportWdg
        view = 'table'
        search_type ='sthpw/task'
        search_view = 'auto_search:table'
        #search_view = ''
        simple_search_view = 'simple_search'
        search_class =''
        mode = 'export_matched'
        element_name=  'project_tasks'
        filter =  [{"prefix":"main_body","main_body_enabled":"on","main_body_column":"project_code","main_body_relation":"is","main_body_value":"{$PROJECT}"}, {"prefix":"main_body","main_body_enabled":"on","main_body_column":"search_type","main_body_relation":"is not","main_body_value":"sthpw/project"}]
        
        from pyasm.common import jsondumps, jsonloads
        values  = {'json': jsondumps(filter)}
        element_names = ['code','id','description']
        server = TacticServerStub(protocol='xmlrpc')
        current_project = 'vfx'
        server.set_project(current_project)

        rtn = server.get_widget('tactic.ui.widget.CsvExportWdg', args={'search_type':search_type, 'view':view,\
            'filter': filter, 'element_name': element_name, 'show_search_limit':'false', 'search_limit':-1, 'search_view':search_view, \
            'element_names': element_names, 'mode':mode, 'search_class':search_class, 'simple_search_view':simple_search_view,\
            'init_load_num':-1, 'test':True}, values=values )
        expected_columns = ['code','id','description']
        expected_sql = '''SELECT "sthpw"."public"."task".* FROM "sthpw"."public"."task" WHERE ( "task"."project_code" = \'%s\' AND ( "task"."search_type" != \'sthpw/project\' OR "task"."search_type" is NULL ) ) AND ("task"."s_status" != \'retired\' or "task"."s_status" is NULL) AND ("task"."s_status" != \'retired\' or "task"."s_status" is NULL) AND ("task"."s_status" != \'retired\' or "task"."s_status" is NULL) ORDER BY "task"."search_type", "task"."search_code"'''%current_project

        expr = "@COUNT(sthpw/task['project_code','%s']['search_type','!=','sthpw/project])"%current_project
        expected_count = Search.eval(expr, single=True)
        
        rtn = jsonloads(rtn)
        self.assertEquals(expected_columns, rtn.get('columns'))
        self.assertEquals(expected_sql, rtn.get('sql'))
        self.assertEquals(expected_count, rtn.get('count'))


        mode = 'export_displayed'
        selected_search_keys = ['sthpw/task?id=4385','sthpw/task?id=4386','sthpw/task?id=4387']
        rtn = server.get_widget('tactic.ui.widget.CsvExportWdg', args={'search_type':search_type, 'view':view,\
            'filter': filter, 'element_name': element_name, 'show_search_limit':'false', 'search_limit':-1, 'search_view':search_view, \
            'element_names': element_names, 'mode':mode, 'search_class':search_class, 'simple_search_view':simple_search_view,\
            'init_load_num':-1, 'test':True, 'selected_search_keys': selected_search_keys}, values=values )
        
        expected_count = 3
        rtn = jsonloads(rtn)
        self.assertEquals(expected_columns, rtn.get('columns'))
        self.assertEquals(expected_count, rtn.get('count'))
开发者ID:mincau,项目名称:TACTIC,代码行数:46,代码来源:widget_test.py

示例7: add_data

    def add_data(self, data):
        '''add data dictionary.'''
        if type(data) in types.StringTypes:
            try:
                data = jsonloads(data)
            except ValueError, e:
                if e.__str__().find('No JSON object') != -1:
                    raise SetupException('Data is not decodable as JSON.')

                # try a straight eval
                data = eval(data)
开发者ID:mincau,项目名称:TACTIC,代码行数:11,代码来源:filter_data.py

示例8: preprocess

    def preprocess(my):
        my.options = my.get_option('options')
        if my.options:
            try:
                my.group_list = jsonloads(my.options)
            except:
                my.group_list = [{'label': 'Syntax Error', 'context':[]}]
        else:
            my.group_list = [{'label':'default', 'context': []}]

        super(TaskGroupCompletionWdg, my).preprocess()
开发者ID:nuxping,项目名称:TACTIC,代码行数:11,代码来源:statistic_wdg.py

示例9: execute

    def execute(self):
        web = WebContainer.get_web()
        value = web.get_form_value( self.get_input_name() )
        if not value:
            value = self.get_data()

        if not value:
            return


        src_search_keys = jsonloads(value)
        #print "xxx: ", type(src_search_keys), src_search_keys

        # get all fo the sobjects from the search keys
        #src_sobjects = SearchKey.get_by_search_keys(src_search_keys)
        instance_type = self.get_option("instance_type")
        # path is used for self-relating in an instance table
        src_path = self.get_option("path")

        src_sobjects = []
        src_instances = []
        for src_search_key in src_search_keys:
            src_sobject = SearchKey.get_by_search_key(src_search_key)

            if src_sobject.get_base_search_type() == instance_type:
                src_instances.append(src_sobject)
            else:
                src_sobjects.append(src_sobject)


        dst_sobject = self.sobject

        
        # get all of the current instances and see if any were removed
        instances = dst_sobject.get_related_sobjects(instance_type)
        for instance in instances:
            exists = False
            for src_instance in src_instances:
                if src_instance.get_search_key() == instance.get_search_key():
                    exists = True

            if not exists:
                instance.delete()


        # add all the new sobjects
        for src_sobject in src_sobjects:

            instance = SearchType.create(instance_type)
            instance.add_related_connection(src_sobject, dst_sobject, src_path=src_path)

            instance.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:52,代码来源:drop_element_wdg.py

示例10: execute_func

    def execute_func(self, js, kwargs={}):

        js = '''
        var func = function() {
            %s
        }
        var ret_val = func();
        ret_val = JSON.stringify(ret_val);
        ''' % js
        ret_val = self.execute(js, kwargs)
        ret_val = jsonloads(ret_val)

        return ret_val
开发者ID:mincau,项目名称:TACTIC,代码行数:13,代码来源:js_wrapper.py

示例11: execute

    def execute(my, func_name, args=[], kwargs={}):

        server = TacticServerStub.get()

        if args:
            args = jsonloads(args)
        if kwargs:
            kwargs = jsonloads(kwargs)


        if kwargs:
            # Quirk ... when there is a kwargs, the last args is the kwargs
            if args:
                args.pop()
            call = "server.%s(*args, **kwargs)" % func_name
        else:
            call = "server.%s(*args)" % func_name

        try:
            ret_val = eval(call)
        except Exception, e:
            print "ERROR: ", e
            raise
开发者ID:nuxping,项目名称:TACTIC,代码行数:23,代码来源:js_wrapper.py

示例12: execute

    def execute(self):

        trigger_sobj = self.get_trigger_sobj()
        data = trigger_sobj.get_value("data")
        #data = """
        #{ "columns": [column1, column2]
        #"""

        data = jsonloads(data)

        column = data.get('column')
        src_status = data.get('src_status')

        

        item = self.get_caller()


        if isinstance(item, SObject):
            if isinstance(item, Task):
                if src_status != None:
                    if item.get_value("status") != src_status:
                        return

                item.set_now(column)
                item.commit()

            #Item can be a note when trigger input is adding or modifying notes
            else:
                process = item.get_value('process')
                expr = '@SOBJECT(parent.sthpw/task["process","%s"])'%process
                tasks = Search.eval(expr, sobjects=[item])

                if tasks:
                    for task in tasks:
                        task.set_now(column)
                        task.commit()

        #item can be a command such as check-in                 
        else:
            if hasattr(item, 'process'):
                process = item.process
                expr = '@SOBJECT(sthpw/task["process","%s"])'%process
                tasks = Search.eval(expr, sobjects=[item.sobject])

                if tasks:
                    for task in tasks:
                        task.set_now(column)
                        task.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:49,代码来源:pipeline_task_trigger.py

示例13: loads

    def loads(self, search_type, sobjects_str):
        sobject_list = jsonloads(sobjects_str)

        sobjects = []
        for sobject_dict in sobject_list:
            sobject = SearchType.create(search_type)

            for name, value in sobject_dict.items():
                if value == None:
                    continue
                sobject.set_value(name, value)

            sobjects.append(sobject)

        return sobjects
开发者ID:mincau,项目名称:TACTIC,代码行数:15,代码来源:serialize_wdg.py

示例14: set_data

    def set_data(self, data):
        '''add data dictionary or a JSON string'''
        self.data = []
        # protect against empty spaces/lines from xml
        if isinstance(data, basestring):
            data = data.strip()
        if not data:
            return

        if isinstance(data, basestring):
            try:
                data = data.replace("'", '"')
                data = jsonloads(data)
            except ValueError, e:
                if e.__str__().find('No JSON object') != -1:
                    raise SetupException('Data is not decodable as JSON. [%s]'%data)
                # try a straight eval
                data = eval(data)
开发者ID:mincau,项目名称:TACTIC,代码行数:18,代码来源:filter_data.py

示例15: execute

    def execute(my):

        trigger_sobj = my.get_trigger_sobj()
        data = trigger_sobj.get_value("data")
        #data = """
        #{ "columns": [column1, column2]
        #"""

        data = jsonloads(data)

        column = data.get('column')
        src_status = data.get('src_status')
        
        task = my.get_caller()
        if task.get_value("status") != src_status:
            return

        task.set_now(column)
        task.commit()
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:19,代码来源:pipeline_task_trigger.py


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