Exemple #1
0
    def handle(self, *args, **options):

        ##Load data views##
        views_file_obj = open("%s%s" %
                              (settings.ROOT, "/templates/data/views.json"))
        try:
            data_view_file = views_file_obj.read()
        finally:
            views_file_obj.close()
        ##Strip out comments and newlines##
        t = BaseHub.strip_python_comments(data_view_file)
        data_views = BaseHub.deserialize_json(data_view_file)

        Command.build_nav(data_views)

        #Uncomment to see datastructure for debugging
        #pp = pprint.PrettyPrinter(indent=3)
        #self.stdout.write( pp.pformat(data_views) )

        menu_file_obj = open(
            "%s%s" % (settings.ROOT, "/html/nav/nav_menu.html"), 'w+')
        try:
            menu_file_obj.write('<ul class="bh-viewtext">\n%s\n</ul>' %
                                (bh_unorderedlist(data_views)))
        finally:
            menu_file_obj.close()

        ##Write out json for the nav_lookup_hash##
        jstring = json.dumps(Command.nav_lookup_hash, ensure_ascii=False)

        html = """<input id="bh_nav_json" type="hidden" value="{{ json_data }}" />"""
        t = Template(html)
        c = Context({'json_data': jstring})
        templateString = t.render(c)

        nav_lookup_file_obj = open(
            "%s%s" % (settings.ROOT, "/templates/bughunter.navlookup.html"),
            'w+')
        try:
            nav_lookup_file_obj.write(templateString)
        finally:
            nav_lookup_file_obj.close()
Exemple #2
0
    def handle(self, *args, **options):

        ##Load data views##
        views_file_obj = open("%s%s" % (settings.ROOT, "/datazilla/webapp/templates/data/views.json"))
        try:
            data_view_file = views_file_obj.read()
        finally:
            views_file_obj.close()
        ##Strip out comments and newlines##
        t = BaseHub.strip_python_comments(data_view_file)
        data_views = BaseHub.deserialize_json(data_view_file)

        Command.build_nav(data_views)

        #Uncomment to see datastructure for debugging
        #pp = pprint.PrettyPrinter(indent=3)
        #self.stdout.write( pp.pformat(data_views) )

        menu_file_obj = open("%s%s" % (settings.ROOT, "/datazilla/webapp/static/html/nav_menu.html"), 'w+')
        try:
            menu_file_obj.write( '<ul class="dv-viewtext">\n%s\n</ul>' % (dv_unorderedlist(data_views)) )
        finally:
            menu_file_obj.close()

        ##Write out json for the nav_lookup_hash##
        jstring = json.dumps( Command.nav_lookup_hash, ensure_ascii=False )

        html = """<input id="dv_nav_json" type="hidden" value="{{ json_data }}" />"""
        t = Template(html)
        c = Context({ 'json_data':jstring })
        template_string = t.render(c)

        nav_lookup_file_obj = open("%s%s" % (settings.ROOT, "/datazilla/webapp/templates/graphs.navlookup.html"), 'w+')
        try:
            nav_lookup_file_obj.write(template_string)
        finally:
            nav_lookup_file_obj.close()