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


Python common.jsondumps函数代码示例

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


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

示例1: 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

示例2: add

    def add(command, kwargs, queue_type, priority, description, message_code=None):

        queue = SearchType.create("sthpw/queue")
        queue.set_value("project_code", Project.get_project_code())
        #queue.set_sobject_value(sobject)

        if not queue_type:
            queue_type = "default"
        queue.set_value("queue", queue_type)

        queue.set_value("state", "pending")

        queue.set_value("login", Environment.get_user_name())

        queue.set_value("command", command)
        data = jsondumps(kwargs)
        queue.set_value("data", data)

        if message_code:
            queue.set_value("message_code", message_code)


        if not priority:
            priority = 9999
        queue.set_value("priority", priority)

        if description:
            queue.set_value("description", description)

        queue.set_user()
        queue.commit()

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

示例3: handle_layout_behaviors

    def handle_layout_behaviors(my, layout):

        my.layout = layout

        # FIXME: not needed ... but need a way to make calling this twice safe
        #SwapDisplayWdg.handle_top(my.layout)

        class_name = my.get_option("dynamic_class")
        if not class_name:
            class_name = "tactic.ui.panel.table_layout_wdg.FastTableLayoutWdg"

        kwargs = jsondumps(my.kwargs)

        name = my.get_name()

        my.layout.add_relay_behavior( {
        'type': 'click',
        'col_name': name,
        'bvr_match_class': 'spt_hidden_row_%s' % name,
        'class_name': class_name,
        'cbjs_action': '''

        var swap_top = bvr.src_el.getElement(".spt_swap_top");
        var state = swap_top.getAttribute("spt_state");

        var row = bvr.src_el.getParent(".spt_table_row");
        var search_key = row.getAttribute("spt_search_key");
        search_key = search_key.replace(/\\&/, "\\&");

        var class_name = '%s';

        eval("var kwargs = " + %s);
        kwargs['search_key'] = search_key;
        kwargs['__hidden__'] = true;
        kwargs['src_el'] = bvr.src_el;

        if (state == 'on') {
            spt.table.remove_hidden_row(row, bvr.col_name);
        }
        else {
            //spt.table.add_hidden_row(row, bvr.class_name, bvr.kwargs);
            spt.table.add_hidden_row(row, class_name, kwargs);
        }

        ''' % (class_name, jsondumps(kwargs))
        } )
开发者ID:funic,项目名称:TACTIC,代码行数:46,代码来源:hidden_row_element_wdg.py

示例4: dumps

    def dumps(self, sobjects):
        sobject_list = []

        for sobject in sobjects:
            data = sobject.get_data()
            sobject_list.append(data)

        sobjects_str = jsondumps(sobject_list)
        return sobjects_str
开发者ID:mincau,项目名称:TACTIC,代码行数:9,代码来源:serialize_wdg.py

示例5: get_custom_layout_wdg

    def get_custom_layout_wdg(my, layout_view):

        content_div = DivWdg()

        from tactic.ui.panel import CustomLayoutWdg
        layout = CustomLayoutWdg(view=layout_view)
        content_div.add(layout)

        for widget in my.widgets:
            name = widget.get_name()
            if my.input_prefix:
                widget.set_input_prefix(my.input_prefix)

            layout.add_widget(widget, name)



        search_key = SearchKey.get_by_sobject(my.sobjects[0], use_id=True)
        search_type = my.sobjects[0].get_base_search_type()


        element_names = my.element_names[:]
        for element_name in my.skipped_element_names:
            element_names.remove(element_name)


        config_xml = my.kwargs.get("config_xml")
        bvr =  {
            'type': 'click_up',
            'mode': my.mode,
            'element_names': element_names,
            'search_key': search_key,
            'input_prefix': my.input_prefix,
            'view': my.view,
            'config_xml': config_xml
        }

        if my.mode == 'insert':
            bvr['refresh'] = 'true'
            # for adding parent relationship in EditCmd
            if my.parent_key:
                bvr['parent_key'] = my.parent_key


        hidden_div = DivWdg()
        hidden_div.add_style("display: none")
        content_div.add(hidden_div)

        hidden = TextAreaWdg("__data__")
        hidden_div.add(hidden)
        hidden.set_value( jsondumps(bvr) )

        show_action = my.kwargs.get("show_action")
        if show_action in [True, 'true']:
            content_div.add( my.get_action_html() )

        return content_div
开发者ID:funic,项目名称:TACTIC,代码行数:57,代码来源:edit_wdg.py

示例6: execute

    def execute(my):
      
        input_data = my.get_input_data()
        data = my.data

        # input data for the handler
        if my.mode == 'separate process,blocking':
            input_data_str = jsondumps(input_data)
            data_str = jsondumps(data)

            file = __file__
            py_exec = Config.get_value("services", "python")
            if not py_exec:
                py_exec = "python"

            retcode = subprocess.call([py_exec, file, data_str, input_data_str])

        elif my.mode == 'separate process,non-blocking':
            input_data_str = jsondumps(input_data)
            data_str = jsondumps(data)

            file = __file__
            py_exec = Config.get_value("services", "python")
            if not py_exec:
                py_exec = "python"

            retcode = subprocess.Popen([py_exec, file, data_str, input_data_str])
        elif my.mode == 'same process,new transaction':
            # run it inline
            trigger = ScriptTrigger()
            trigger.set_data(data)
            trigger.set_input(input_data)
            trigger.execute()


        # DEPRECATED MMS mode
        elif my.mode == 'MMS':
            # run it inline
            trigger = MMSScriptTrigger()
            trigger.set_data(data)
            trigger.set_input(input_data)
            trigger.execute()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:42,代码来源:subprocess_trigger.py

示例7: get_json_string

    def get_json_string(dict, use_cache=True):
        '''given a dictionary, return a javascript friendly json string as a js string'''
        dict_str = None
        if use_cache:
            data = Container.get("Html:json_str")
            if not data:
                data = {}
                Container.put("Html:json_str", data)

            key = str(dict)
            dict_str = data.get(key)
    
        if dict_str == None:
            try:
                dict_str = jsondumps(dict)
            except UnicodeDecodeError, e:
                if isinstance(dict, basestring):
                    dict = dict.decode('iso-8859-1')
                    dict_str = jsondumps(dict)

            dict_str = dict_str.replace('"', '"')
            if use_cache:
                data[key] = dict_str
开发者ID:nuxping,项目名称:TACTIC,代码行数:23,代码来源:html_wdg.py

示例8: _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

示例9: get_instance_wdg

    def get_instance_wdg(self, instance_type):
        sorted_instances = self._get_sorted_instances()
        content_div = Widget()

        for instance in sorted_instances:
            item_div = self.get_item_div(instance)
            item_div.add_attr( "spt_search_key", SearchKey.get_by_sobject(instance) )
            item_div.add_class("spt_drop_item")

            # no need for that
            #item_div.add(' ')
            content_div.add(item_div)
        value_wdg = self.get_value_wdg()
        json = jsondumps(self.values)
        json = json.replace('"', '"')
        value_wdg.set_value(json)

        return content_div
开发者ID:mincau,项目名称:TACTIC,代码行数:18,代码来源:drop_element_wdg.py

示例10: handle_manifest

    def handle_manifest(self, share):

        import datetime

        sync_folder = self.get_value("sync_folder")
        if not os.path.exists(sync_folder):
            os.makedirs(sync_folder)

        manifest_path = "%s/tactic.txt" % sync_folder


        """
        # find the last transaction for this project
        project_code = self.get_value("projects")
        search = Search("sthpw/transaction_log")
        search.add_filter("namespace", project_code)
        search.add_order_by("timestamp desc")
        last_transaction = search.get_sobject()
        if last_transaction:
            transaction_code = last_transaction.get_code()
            # get rid of the unicode because pprint doesn't remove it
            transaction_code = str(transaction_code)
        else:
            transaction_code = ""
        """


        f = open(manifest_path, 'wb')

        manifest = {
          "code": str(share.get_code()),
          "description": share.get_value('description'),
          #"last_transaction": transaction_code,
          "is_encrypted": "true",
          "date_created": datetime.datetime.now(),
          "created_by": self.server_prefix,
          "project": self.project_code
        }

        from pyasm.common import jsondumps
        #f.write(Common.get_pretty_print(manifest))
        f.write(jsondumps(manifest))
        f.close()
开发者ID:mincau,项目名称:TACTIC,代码行数:43,代码来源:sync_settings_wdg.py

示例11: execute

                def execute(self):
                    # check to see the status of this job
                    """
                    job = self.kwargs.get('job')
                    job_code = job.get_code()
                    search = Search("sthpw/queue")
                    search.add_filter("code", job_code)
                    self.kwargs['job'] = search.get_sobject()

                    if not job:
                        print("Cancelling ...")
                        return

                    state = job.get_value("state")
                    if state == "cancel":
                        print("Cancelling 2 ....")
                        return
                    """

                    subprocess_kwargs = {
                        'login': login,
                        'project_code': project_code,
                        'command': command,
                        'kwargs': kwargs
                    }
                    subprocess_kwargs_str = jsondumps(subprocess_kwargs)
                    install_dir = Environment.get_install_dir()
                    python = Config.get_value("services", "python")
                    if not python:
                        python = 'python'
                    args = ['%s' % python, '%s/src/tactic/command/queue.py' % install_dir]
                    args.append(subprocess_kwargs_str)

                    import subprocess
                    p = subprocess.Popen(args)

                    DbContainer.close_thread_sql()

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

示例12: execute

    def execute(self):

        rule_code = self.kwargs.get("rule_code")

        if rule_code:
            search = Search("config/ingest_rule")
            search.add_filter("code", rule_code)
            rule = search.get_sobject()
        else:
            rule = SearchType.create("config/ingest_rule")

        # explicitly save the columns
        columns = ['base_dir', 'rule', 'title']
        for column in columns:
            rule.set_value(column, self.kwargs.get(column) )


        # not sure if we want to save the entire kwargs??
        kwargs_str = jsondumps(self.kwargs)
        rule.set_value("data", kwargs_str)

        rule.commit()
        return
开发者ID:mincau,项目名称:TACTIC,代码行数:23,代码来源:ingestion_cmd.py

示例13: get_behavior

    def get_behavior(cls, sobject):
        '''it takes sobject as an argument and turn it into a dictionary to pass to 
            NotificationTestCmd'''
        pal = WebContainer.get_web().get_palette()
        bg_color = pal.color('background')
        sobj_dict = SObject.get_sobject_dict(sobject)
        sobj_json = jsondumps(sobj_dict)
        bvr = {'type': 'click_up',
                 'cbjs_action': '''
                   var server = TacticServerStub.get();
                   var rtn = {};
                   var msg = '';

                   try
                   { 
                      spt.app_busy.show( 'Email Test', 'Waiting for email server response...' );
                      rtn = server.execute_cmd('tactic.command.NotificationTestCmd', args={'sobject_dict': %s});
                      msg = rtn.description;
                      msg += '\\nYou can also review the notification in the Notification Log.'
                   }
                   catch(e) {
                       msg = 'Error found in this notification:\\n\\n' + spt.exception.handler(e);
                   }
                   //console.log(msg)
                   spt.app_busy.hide();
                   var popup_id = 'Notification test result';

                   var class_name = 'tactic.ui.panel.CustomLayoutWdg';

                   msg= msg.replace(/\\n/g, '<br/>');

                   var options = { 'html': '<div><div style="background:%s; padding: 5px">' + msg + '</div></div>'};
                   var kwargs = {'width':'600px'};
                   spt.panel.load_popup(popup_id, class_name, options, kwargs);
                   
                  ''' %(sobj_json, bg_color)}
        return bvr
开发者ID:funic,项目名称:TACTIC,代码行数:37,代码来源:table_element_wdg.py

示例14: get_action_html

    def get_action_html(my):


        search_key = SearchKey.get_by_sobject(my.sobjects[0], use_id=True)
        search_type = my.sobjects[0].get_base_search_type()


        div = DivWdg(css='centered')


        # construct the bvr
        element_names = my.element_names[:]
        for element_name in my.skipped_element_names:
            element_names.remove(element_name)

        bvr =  {
            'type': 'click_up',
            'mode': my.mode,
            'element_names': element_names,
            'search_key': search_key,
            'input_prefix': my.input_prefix,
            'view': my.view
        }

        if my.mode == 'insert':
            bvr['refresh'] = 'true'
            # for adding parent relationship in EditCmd
            if my.parent_key:
                bvr['parent_key'] = my.parent_key




        hidden_div = DivWdg()
        hidden_div.add_style("display: none")
        div.add(hidden_div)

        hidden = TextAreaWdg("__data__")
        hidden_div.add(hidden)
        hidden.set_value( jsondumps(bvr) )

        show_action = my.kwargs.get("show_action")
        if show_action in [False, 'false']:
            return div



 
        div.add_styles('height: 35px; margin-top: 5px;')
        div.add_named_listener('close_EditWdg', '''
            var popup = spt.popup.get_popup( $('edit_popup') );
            if (popup != null) {
                spt.popup.destroy(popup);
            }
            ''')

     
        # custom callbacks
        cbjs_cancel = my.kwargs.get('cbjs_cancel')
        if not cbjs_cancel:
            cbjs_cancel = '''
            spt.named_events.fire_event('preclose_edit_popup', {});
            spt.named_events.fire_event('close_EditWdg', {})
            '''

        # custom callbacks
        cbjs_insert_path = my.kwargs.get('cbjs_%s_path' % my.mode)
        cbjs_insert = None
        if cbjs_insert_path:
            script_obj = CustomScript.get_by_path(cbjs_insert_path)
            if script_obj:
                cbjs_insert = script_obj.get_value("script")

        # get it inline
        if not cbjs_insert:
            cbjs_insert = my.kwargs.get('cbjs_%s' % my.mode)

        # use a default
        if not cbjs_insert:
            mode_label = my.mode.capitalize()
            cbjs_insert = '''
            spt.app_busy.show("%sing items", "");
            spt.edit.edit_form_cbk(evt, bvr);
            spt.app_busy.hide();
            '''%mode_label

        save_event = my.kwargs.get('save_event')
        if not save_event:
            save_event = div.get_unique_event("save")
        bvr['save_event'] = save_event
        bvr['named_event'] = 'edit_pressed'

        bvr['cbjs_action'] = cbjs_insert

        
        ok_btn_label = my.mode.capitalize()
        if ok_btn_label == 'Edit':
            ok_btn_label = 'Save'
        if ok_btn_label == 'Insert':
            ok_btn_label = 'Add'
#.........这里部分代码省略.........
开发者ID:funic,项目名称:TACTIC,代码行数:101,代码来源:edit_wdg.py

示例15: set_to_cgi

 def set_to_cgi(self):
     web = WebContainer.get_web()
     data = jsondumps(self.data)
     web.set_form_value('json', data)
     Container.put("FilterData", self)
开发者ID:mincau,项目名称:TACTIC,代码行数:5,代码来源:filter_data.py


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