def compare(request): """HTML pretty-fied output of compare-locales. """ run = Run.objects.get(id=request.GET['run']) json = '' for step in run.build.steps.filter(name__startswith='moz_inspectlocales'): for log in step.logs.all(): for chunk in generateLog(run.build.builder.master.name, log.filename): if chunk['channel'] == 5: json += chunk['data'] json = simplejson.loads(json) nodes = JSONAdaptor.adaptChildren(json['details'].get('children', [])) summary = json['summary'] if 'keys' not in summary: summary['keys'] = 0 # create table widths for the progress bar _width = 300 widths = {} for k in ('changed', 'missing', 'missingInFiles', 'report', 'unchanged'): widths[k] = summary.get(k, 0)*300/summary['total'] return render_to_response('l10nstats/compare.html', {'run': run, 'nodes': nodes, 'widths': widths, 'summary': summary})
def compare(request): """HTML pretty-fied output of compare-locales. """ try: run = get_object_or_404(Run, id=request.GET['run']) except ValueError: return HttpResponseBadRequest('Invalid ID') json = '' for step in Step.objects.filter(name__startswith='moz_inspectlocales', build__run=run): for log in step.logs.all(): for chunk in generateLog(run.build.builder.master.name, log.filename): if chunk['channel'] == 5: json += chunk['data'] if json: json = simplejson.loads(json) nodes = list(JSONAdaptor.adaptChildren(json['details'].get('children', []))) else: nodes = None # create table widths for the progress bar widths = {} for k in ('changed', 'missing', 'missingInFiles', 'report', 'unchanged'): widths[k] = getattr(run, k) * 300 / run.total return render(request, 'l10nstats/compare.html', { 'run': run, 'nodes': nodes, 'widths': widths, })
def compare(request): """HTML pretty-fied output of compare-locales. """ try: run = get_object_or_404(Run, id=request.GET['run']) except ValueError: return HttpResponseBadRequest('Invalid ID') json = '' for step in run.build.steps.filter(name__startswith='moz_inspectlocales'): for log in step.logs.all(): for chunk in generateLog(run.build.builder.master.name, log.filename): if chunk['channel'] == 5: json += chunk['data'] if json: json = simplejson.loads(json) nodes = list(JSONAdaptor.adaptChildren(json['details'].get('children', []))) else: nodes = None # create table widths for the progress bar widths = {} for k in ('changed', 'missing', 'missingInFiles', 'report', 'unchanged'): widths[k] = getattr(run, k) * 300 / run.total return render(request, 'l10nstats/compare.html', { 'run': run, 'nodes': nodes, 'widths': widths, })
def generateDocs(self, runs): run_master = dict( runs.values_list('id', 'build__builder__master__name')) for run in runs: self.offset = run.id data = '' for step in (Step.objects.filter( name__startswith='moz_inspectlocales', build__run=run)): for log in step.logs.all(): try: for chunk in generateLog(run_master[run.id], log.filename, channels=(Log.JSON, )): data += chunk['data'] except NoLogFile: pass if not data: continue comparison = json.loads(data) comparison['run'] = run.id # we have the summary in the database, drop it comparison.pop('summary') yield { "_index": self.index, "_type": "comparison", "_id": run.id, "_source": comparison }
def compare(request): """HTML pretty-fied output of compare-locales. """ run = Run.objects.get(id=request.GET['run']) json = '' for step in run.build.steps.filter(name__startswith='moz_inspectlocales'): for log in step.logs.all(): for chunk in generateLog(run.build.builder.master.name, log.filename): if chunk['channel'] == 5: json += chunk['data'] json = simplejson.loads(json) nodes = JSONAdaptor.adaptChildren(json['details'].get('children', [])) summary = json['summary'] if 'keys' not in summary: summary['keys'] = 0 # create table widths for the progress bar widths = {} for k in ('changed', 'missing', 'missingInFiles', 'report', 'unchanged'): widths[k] = summary.get(k, 0) * 300 / summary['total'] return render_to_response('l10nstats/compare.html', { 'run': run, 'nodes': nodes, 'widths': widths, 'summary': summary }, context_instance=RequestContext(request))
def generateDocs(self, runs): run_master = dict(runs .values_list('id', 'build__builder__master__name')) for run in runs: self.offset = run.id data = '' for step in (Step.objects .filter(name__startswith='moz_inspectlocales', build__run=run)): for log in step.logs.all(): try: for chunk in generateLog(run_master[run.id], log.filename, channels=(Log.JSON,)): data += chunk['data'] except NoLogFile: pass if not data: continue comparison = json.loads(data) comparison['run'] = run.id # we have the summary in the database, drop it comparison.pop('summary') yield { "_index": self.index, "_type": "comparison", "_id": run.id, "_source": comparison }
def compare(request): """HTML pretty-fied output of compare-locales. """ try: run = get_object_or_404(Run, id=request.GET['run']) except ValueError: return HttpResponseBadRequest('Invalid ID') # try disk first, then ES json = '' doc = None for step in Step.objects.filter(name__startswith='moz_inspectlocales', build__run=run): for log in step.logs.all(): try: for chunk in generateLog(run.build.builder.master.name, log.filename, channels=(Log.JSON, )): json += chunk['data'] except NoLogFile: pass if json: doc = simplejson.loads(json) elif hasattr(settings, 'ES_COMPARE_HOST'): es = elasticsearch.Elasticsearch(hosts=[settings.ES_COMPARE_HOST]) try: rv = es.get(index=settings.ES_COMPARE_INDEX, doc_type='comparison', id=run.id) except elasticsearch.TransportError: rv = {'found': False} if rv['found']: doc = rv['_source'] else: doc = None if doc: nodes = list( JSONAdaptor.adaptChildren(doc['details'].get('children', []))) else: nodes = None # create table widths for the progress bar widths = {} for k in ('changed', 'missing', 'missingInFiles', 'report', 'unchanged'): widths[k] = getattr(run, k) * 300 / run.total return render(request, 'l10nstats/compare.html', { 'run': run, 'nodes': nodes, 'widths': widths, })
def compare(request): """HTML pretty-fied output of compare-locales. """ try: run = get_object_or_404(Run, id=request.GET['run']) except ValueError: return HttpResponseBadRequest('Invalid ID') # try disk first, then ES json = '' doc = None for step in Step.objects.filter(name__startswith='moz_inspectlocales', build__run=run): for log in step.logs.all(): try: for chunk in generateLog(run.build.builder.master.name, log.filename, channels=(Log.JSON,)): json += chunk['data'] except NoLogFile: pass if json: doc = simplejson.loads(json) elif hasattr(settings, 'ES_COMPARE_HOST'): es = elasticsearch.Elasticsearch(hosts=[settings.ES_COMPARE_HOST]) try: rv = es.get(index=settings.ES_COMPARE_INDEX, doc_type='comparison', id=run.id) except elasticsearch.TransportError: rv = {'found': False} if rv['found']: doc = rv['_source'] else: doc = None if doc: nodes = list(JSONAdaptor.adaptChildren(doc['details'].get('children', []))) else: nodes = None # create table widths for the progress bar widths = {} for k in ('changed', 'missing', 'missingInFiles', 'report', 'unchanged'): widths[k] = getattr(run, k) * 300 / run.total return render(request, 'l10nstats/compare.html', { 'run': run, 'nodes': nodes, 'widths': widths, })
def compare(request): """HTML pretty-fied output of compare-locales. """ try: run = get_object_or_404(Run, id=request.GET["run"]) except ValueError: return HttpResponseBadRequest("Invalid ID") # try disk first, then ES json = "" doc = None for step in Step.objects.filter(name__startswith="moz_inspectlocales", build__run=run): for log in step.logs.all(): try: for chunk in generateLog(run.build.builder.master.name, log.filename, channels=(Log.JSON,)): json += chunk["data"] except NoLogFile: pass if json: doc = simplejson.loads(json) elif hasattr(settings, "ES_COMPARE_HOST"): es = elasticsearch.Elasticsearch(hosts=[settings.ES_COMPARE_HOST]) try: rv = es.get(index=settings.ES_COMPARE_INDEX, doc_type="comparison", id=run.id) except elasticsearch.TransportError: rv = {"found": False} if rv["found"]: doc = rv["_source"] else: doc = None if doc: nodes = list(JSONAdaptor.adaptChildren(doc["details"].get("children", []))) else: nodes = None # create table widths for the progress bar widths = {} for k in ("changed", "missing", "missingInFiles", "report", "unchanged"): widths[k] = getattr(run, k) * 300 / run.total return render(request, "l10nstats/compare.html", {"run": run, "nodes": nodes, "widths": widths})