• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.jsondumps函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: serialize

 def serialize(self):
     '''serialize the data into a string'''
     value = jsondumps(self.data)
     return value
开发者ID:mincau,项目名称:TACTIC,代码行数:4,代码来源:filter_data.py


示例17: get_display


#.........这里部分代码省略.........
                
                var idx = spt.gallery.index;
                var video_id = spt.gallery.videos[idx];
                
                if (!video_id) return;

                var player = videojs(video_id, {"nativeControlsForTouch": false});
                if (player.paused()) {
                    player.play();
                    //console.log("play " + video_id)
                }
                else 
                    player.pause();
                '''
                })


            top.add(overlay) 



        top.add_behavior( {
            'type': 'load',
            'cbjs_action': my.get_onload_js()
        } )

        top.add_behavior( {
            'type': 'load',
            'index' : my.index,
            'video_id': my.video_id,
            'cbjs_action': '''
            if (!bvr.index) bvr.index = 0;

            var video_id = bvr.video_id;


            spt.video.init_videojs(video_id);


            if (spt.gallery) {
                
                spt.gallery.videos[bvr.index] = video_id;

                if (!spt.gallery.portrait) {
                    var overlay = bvr.src_el.getElement('.video_overlay');
                    if (overlay)
                        overlay.setStyles({'top': '4%', 'left': '5%', 
                            'width': '90%', 'height':'87%'});
                }
            }
            
            
            '''
        } )
        #video.add_attr("data-setup", "{}")




        if width:
            video.add_attr("width", width)
        if height:
            video.add_attr("height", height)

        if poster:
            video.add_attr("poster", poster)

        if preload == None:
            preload = "none"

        if controls == None:
            controls = True

        autoplay = False

        # videojs uses a json data structre
        data = {
                'preload': preload,
                'controls': controls,
                'autoplay': autoplay
        }

        from pyasm.common import jsondumps
        data_str = jsondumps(data)
        video.add_attr("data-setup", data_str)


        for i, src in enumerate(sources):

            source = HtmlElement(type="source")
            source.add_attr("src", src)

            if len(source_types) > i:
                source_type = source_types[i]
                source.add_attr("type", source_type)

            video.add(source)

        #print top.get_buffer_display()
        return top
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:video_wdg.py


示例18: get_import_wdg

    def get_import_wdg(self):
        div = DivWdg()

        if self.data:

            div.add("<br/>"*2)
            div.add("The following TACTIC share was found: ")
            div.add("<br/>"*2)

            data_input = TextAreaWdg("data")
            data_input.add_style("display: none")
            div.add(data_input)

            #print "xxxx: ", self.data
            data_str = jsondumps(self.data)
            #data_str = data_str.replace('"', "'")
            print "data: ", data_str
            data_input.set_value(data_str)




            table = Table()
            div.add(table)
            table.set_max_width()
            table.add_style("margin-left: 20px")
            table.add_style("margin-right: 20px")

            for name, value in self.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)



            div.add("<br/>"*2)

            div.add( self.get_versions_wdg() )

            div.add("<br/>"*2)

            # check to see if the project exists
            project_code = self.data.get("project_code")
            project_code = self.data.get("projects")
            project = Project.get_by_code(project_code)
            #if project:
            if False:
                msg_div = DivWdg()
                div.add(msg_div)
                msg_div.add_style("padding: 20px")
                msg_div.add_color("background", "background3")
                msg_div.add_color("color", "color")
                msg_div.add_border()

                icon = IconWdg("WARNING", IconWdg.WARNING)
                msg_div.add(icon)
                icon.add_style("float: left")

                msg_div.add("The project with code [%s] already exists.  You must remove the installed project before trying to import this one." % project_code)
                return div





            if self.data.get("is_encrypted") == "true":
                div.add("The transactions in this share is encrypted.  Please provide an encryption key to decrypt the transactions<br/><br/>")
                div.add("Encryption Key: ")
                text = TextWdg("encryption_key")
                div.add(text)
                div.add("<br/>"*2)

            button = ActionButtonWdg(title="Import >>")
            button.add_style("float: right")
            div.add(button)
            div.add("<br/>"*2)
            button.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Importing Project "+bvr.project_code+"...");
                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var values = spt.api.Utility.get_input_values(top, null, false);
                var cmd = "tactic.ui.sync.SyncImportCmd";
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, values, {}, {use_transaction: false});
                spt.notify.show_message("Finished importing project");
                spt.app_busy.hide();
                document.location = '/tactic/'+bvr.project_code;
                '''
            } )



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


示例19: serialize

 def serialize(my):
     '''serialize the data into a string'''
     value = jsondumps(my.data)
     return value
开发者ID:0-T-0,项目名称:TACTIC,代码行数:4,代码来源:filter_data.py


示例20: apply_pattern


#.........这里部分代码省略.........

                        path = "%s/%s/" % (root, dir)
                        parts_depth = len(path.split("/"))
                        #print path, parts_depth

                        if not parts_depth - start_depth == depth:
                            self.paths_not_matched.append(path)
                            continue

                        self.sobject_tags = {}
                        self.snapshot_tags = {}

                        self.process_path(path, pattern, checkin_type)

                        self.tags[path] = {
                            'sobject': self.sobject_tags,
                            'snapshot': self.snapshot_tags
                        }

                else:
                    for file in files:

                        count += 1
                        limit = 100000
                        if count > limit:
                            break


                        path = "%s/%s" % (root, file)
                        self.check_irregular(path)

                        skip = False
                        for p in ignore:
                            if file.endswith(p):
                                skip = True
                                break

                        for p in filter:
                            if p.startswith("/") and p.endswith("/"):
                                import re
                                p = p.strip("/")
                                p = re.compile(p)
                                if p.match(file):
                                    skip = False
                                    break

                            elif file.find(p) != -1:
                                skip = False
                                break
                        else:
                            if not filter:
                                skip = False
                            else:
                                skip = True

                        if skip:
                            self.paths_not_matched.append(path)
                            continue


                        #xx = "scan"
                        xx = "xx"
                        if xx == 'scan':
                            self.scan_path(path, pattern)
                        else:

                            self.sobject_tags = {}
                            self.snapshot_tags = {}
                            self.process_path(path, pattern, checkin_type)
                            self.tags[path] = {
                                'sobject': self.sobject_tags,
                                'snapshot': self.snapshot_tags,
                            }

        print "length: ", len(self.data.keys())

        self.info["paths_matched"] = self.paths_matched
        self.info["paths_not_matched"] = self.paths_not_matched
        self.info["paths_invalid"] = self.paths_invalid
        self.info["paths_irregular"] = self.paths_irregular
        self.info["tags"] = self.tags


        self.info["data"] = self.data

        import codecs
        scan_path = "/tmp/scan"
        if os.path.exists(scan_path):
            f = codecs.open(scan_path, 'r', 'utf-8')
            data = jsonloads( f.read() )
            f.close()
            data.update(self.data)
        else:
            data = self.data

        f = codecs.open(scan_path, 'w', 'utf-8')
        f.write( jsondumps( data ) )
        f.close()

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.jsonloads函数代码示例发布时间:2022-05-25
下一篇:
Python command.Trigger类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap