def compare(request, diff, key=None, type='file'): data = setup_viewer(request, diff.left.file) data['diff'] = diff data['poll_url'] = reverse('files.compare.poll', args=[diff.left.file.id, diff.right.file.id]) if (not waffle.switch_is_active('delay-file-viewer') and not diff.is_extracted()): extract_file(diff.left) extract_file(diff.right) if diff.is_extracted(): data.update({ 'status': True, 'files': diff.get_files(), 'files_deleted': diff.get_deleted_files() }) key = diff.left.get_default(key) if key not in data['files'] and key not in data['files_deleted']: raise http.Http404 diff.select(key) data['key'] = key if diff.is_diffable(): data['left'], data['right'] = diff.read_file() else: extract_file.delay(diff.left) extract_file.delay(diff.right) tmpl = ('files/content.html' if type == 'fragment' else 'files/viewer.html') return jingo.render(request, tmpl, data)
def browse(request, viewer, key=None, type='file'): data = setup_viewer(request, viewer.file) data['viewer'] = viewer data['poll_url'] = reverse('files.poll', args=[viewer.file.id]) if (not waffle.switch_is_active('delay-file-viewer') and not viewer.is_extracted()): extract_file(viewer) if viewer.is_extracted(): data.update({'status': True, 'files': viewer.get_files()}) key = viewer.get_default(key) if key not in data['files']: raise http.Http404 viewer.select(key) data['key'] = key if (not viewer.is_directory() and not viewer.is_binary()): data['content'] = viewer.read_file() else: extract_file.delay(viewer) tmpl = ('files/content.html' if type == 'fragment' else 'files/viewer.html') return jingo.render(request, tmpl, data)
def files_compare(request, diff, key='install.rdf'): data = setup_viewer(request, diff.file_one.file) data['diff'] = diff data['poll_url'] = reverse('files.compare.poll', args=[diff.file_one.file.id, diff.file_two.file.id]) if diff.is_extracted: files = diff.primary_files() data.update({'status': True, 'files': files}) if key: if key not in files: raise http.Http404 diff.select(key) data['selected'] = diff.one if not diff.is_diffable(): data['msg'] = diff.status elif not diff.is_binary(): data['text_one'], omsg = diff.file_one.read_file(diff.one) data['text_two'], tmsg = diff.file_two.read_file(diff.two) data['msg'] = omsg or tmsg else: extract_file.delay(diff) response = jingo.render(request, 'files/viewer.html', data) if not settings.DEBUG: response['ETag'] = '"%s"' % hashlib.md5(response.content).hexdigest() response['Last-Modified'] = http_date(data['selected']['modified'] if data['selected'] else None) return response
def browse(request, viewer, key=None, type_="file"): form = forms.FileCompareForm(request.POST or None, addon=viewer.addon, initial={"left": viewer.file}) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, viewer.file) data["viewer"] = viewer data["poll_url"] = reverse("mkt.files.poll", args=[viewer.file.id]) data["form"] = form if not waffle.switch_is_active("delay-file-viewer") and not viewer.is_extracted(): extract_file(viewer) if viewer.is_extracted(): data.update({"status": True, "files": viewer.get_files()}) key = viewer.get_default(key) if key not in data["files"]: raise http.Http404 viewer.select(key) data["key"] = key binary = viewer.is_binary() if not viewer.is_directory() and (not binary or binary != "image"): data["content"] = viewer.read_file() else: extract_file.delay(viewer) tmpl = "content" if type_ == "fragment" else "viewer" return jingo.render(request, "fileviewer/%s.html" % tmpl, data)
def browse(request, viewer, key=None, type_='file'): form = forms.FileCompareForm(request.POST or None, addon=viewer.addon, initial={'left': viewer.file}) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, viewer.file) data['viewer'] = viewer data['poll_url'] = reverse('mkt.files.poll', args=[viewer.file.id]) data['form'] = form if not viewer.is_extracted(): extract_file(viewer) if viewer.is_extracted(): data.update({'status': True, 'files': viewer.get_files()}) key = viewer.get_default(key) if key not in data['files']: raise http.Http404 viewer.select(key) data['key'] = key binary = viewer.is_binary() if (not viewer.is_directory() and (not binary or binary != 'image')): data['content'] = viewer.read_file() else: extract_file.delay(viewer) tmpl = 'content' if type_ == 'fragment' else 'viewer' return render(request, 'fileviewer/%s.html' % tmpl, data)
def files_compare(request, diff, key='install.rdf'): data = setup_viewer(request, diff.file_one.file) data['diff'] = diff data['poll_url'] = reverse( 'files.compare.poll', args=[diff.file_one.file.id, diff.file_two.file.id]) if diff.is_extracted: files = diff.primary_files() data.update({'status': True, 'files': files}) if key: if key not in files: raise http.Http404 diff.select(key) data['selected'] = diff.one if not diff.is_diffable(): data['msg'] = diff.status elif not diff.is_binary(): data['text_one'], omsg = diff.file_one.read_file(diff.one) data['text_two'], tmsg = diff.file_two.read_file(diff.two) data['msg'] = omsg or tmsg else: extract_file.delay(diff) response = jingo.render(request, 'files/viewer.html', data) if not settings.DEBUG: response['ETag'] = '"%s"' % hashlib.md5(response.content).hexdigest() response['Last-Modified'] = http_date( data['selected']['modified'] if data['selected'] else None) return response
def compare(request, diff, key=None, type_="file"): form = forms.FileCompareForm( request.POST or None, addon=diff.addon, initial={"left": diff.left.file, "right": diff.right.file} ) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, diff.left.file) data["diff"] = diff data["poll_url"] = reverse("mkt.files.compare.poll", args=[diff.left.file.id, diff.right.file.id]) data["form"] = form if not waffle.switch_is_active("delay-file-viewer") and not diff.is_extracted(): extract_file(diff.left) extract_file(diff.right) if diff.is_extracted(): data.update({"status": True, "files": diff.get_files(), "files_deleted": diff.get_deleted_files()}) key = diff.left.get_default(key) if key not in data["files"] and key not in data["files_deleted"]: raise http.Http404 diff.select(key) data["key"] = key if diff.is_diffable(): data["left"], data["right"] = diff.read_file() else: extract_file.delay(diff.left) extract_file.delay(diff.right) tmpl = "content" if type_ == "fragment" else "viewer" return jingo.render(request, "fileviewer/%s.html" % tmpl, data)
def compare(request, diff, key=None, type="file"): data = setup_viewer(request, diff.left.file) data["diff"] = diff data["poll_url"] = reverse("files.compare.poll", args=[diff.left.file.id, diff.right.file.id]) if not waffle.switch_is_active("delay-file-viewer") and not diff.is_extracted(): extract_file(diff.left) extract_file(diff.right) if diff.is_extracted(): data.update({"status": True, "files": diff.get_files(), "files_deleted": diff.get_deleted_files()}) key = diff.left.get_default(key) if key not in data["files"] and key not in data["files_deleted"]: raise http.Http404 diff.select(key) data["key"] = key if diff.is_diffable(): data["left"], data["right"] = diff.read_file() else: extract_file.delay(diff.left) extract_file.delay(diff.right) tmpl = "files/content.html" if type == "fragment" else "files/viewer.html" return jingo.render(request, tmpl, data)
def files_list(request, viewer, key='install.rdf'): data = setup_viewer(request, viewer.file) data['viewer'] = viewer data['poll_url'] = reverse('files.poll', args=[viewer.file.id]) if viewer.is_extracted: files = viewer.get_files() data.update({'status': True, 'files': files}) if key: if key not in files: raise http.Http404 selected = data['selected'] = files.get(key) if (not selected['directory'] and not selected['binary']): data['content'], data['msg'] = viewer.read_file(selected) else: extract_file.delay(viewer) response = jingo.render(request, 'files/viewer.html', data) if not settings.DEBUG: response['ETag'] = '"%s"' % hashlib.md5(response.content).hexdigest() response['Last-Modified'] = http_date( data['selected']['modified'] if data['selected'] else None) return response
def browse(request, viewer, key=None, type_='file'): form = forms.FileCompareForm(request.POST or None, addon=viewer.addon, initial={'left': viewer.file}) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, viewer.file) data['viewer'] = viewer data['poll_url'] = reverse('mkt.files.poll', args=[viewer.file.id]) data['form'] = form if (not waffle.switch_is_active('delay-file-viewer') and not viewer.is_extracted()): extract_file(viewer) if viewer.is_extracted(): data.update({'status': True, 'files': viewer.get_files()}) key = viewer.get_default(key) if key not in data['files']: raise http.Http404 viewer.select(key) data['key'] = key binary = viewer.is_binary() if (not viewer.is_directory() and (not binary or binary != 'image')): data['content'] = viewer.read_file() else: extract_file.delay(viewer) tmpl = 'content' if type_ == 'fragment' else 'viewer' return render(request, 'fileviewer/%s.html' % tmpl, data)
def files_list(request, viewer, key='install.rdf'): data = setup_viewer(request, viewer.file) data['viewer'] = viewer data['poll_url'] = reverse('files.poll', args=[viewer.file.id]) if viewer.is_extracted: files = viewer.get_files() data.update({'status': True, 'files': files}) if key: if key not in files: raise http.Http404 selected = data['selected'] = files.get(key) if (not selected['directory'] and not selected['binary']): data['content'], data['msg'] = viewer.read_file(selected) else: extract_file.delay(viewer) response = jingo.render(request, 'files/viewer.html', data) if not settings.DEBUG: response['ETag'] = '"%s"' % hashlib.md5(response.content).hexdigest() response['Last-Modified'] = http_date(data['selected']['modified'] if data['selected'] else None) return response
def compare(request, diff, key=None, type='file'): data = setup_viewer(request, diff.left.file) data['diff'] = diff data['poll_url'] = reverse('files.compare.poll', args=[diff.left.file.id, diff.right.file.id]) if (not waffle.switch_is_active('delay-file-viewer') and not diff.is_extracted()): extract_file(diff.left) extract_file(diff.right) if diff.is_extracted(): data.update({'status': True, 'files': diff.get_files(), 'files_deleted': diff.get_deleted_files()}) key = diff.left.get_default(key) if key not in data['files'] and key not in data['files_deleted']: raise http.Http404 diff.select(key) data['key'] = key if diff.is_diffable(): data['left'], data['right'] = diff.read_file() else: extract_file.delay(diff.left) extract_file.delay(diff.right) tmpl = ('files/content.html' if type == 'fragment' else 'files/viewer.html') return jingo.render(request, tmpl, data)
def browse(request, viewer, key=None, type='file'): form = forms.FileCompareForm(request.POST or None, addon=viewer.addon, initial={'left': viewer.file}) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, viewer.file) data['viewer'] = viewer data['poll_url'] = reverse('files.poll', args=[viewer.file.id]) data['form'] = form if (not waffle.switch_is_active('delay-file-viewer') and not viewer.is_extracted()): extract_file(viewer) if viewer.is_extracted(): data.update({'status': True, 'files': viewer.get_files()}) key = viewer.get_default(key) if key not in data['files']: raise http.Http404 viewer.select(key) data['key'] = key if (not viewer.is_directory() and not viewer.is_binary()): data['content'] = viewer.read_file() else: extract_file.delay(viewer) tmpl = ('files/content.html' if type == 'fragment' else 'files/viewer.html') return render(request, tmpl, data)
def compare(request, diff, key=None, type_='file'): form = forms.FileCompareForm(request.POST or None, addon=diff.addon, initial={ 'left': diff.left.file, 'right': diff.right.file }) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, diff.left.file) data['diff'] = diff data['poll_url'] = reverse('mkt.files.compare.poll', args=[diff.left.file.id, diff.right.file.id]) data['form'] = form if (not waffle.switch_is_active('delay-file-viewer') and not diff.is_extracted()): extract_file(diff.left) extract_file(diff.right) if diff.is_extracted(): data.update({ 'status': True, 'files': diff.get_files(), 'files_deleted': diff.get_deleted_files() }) key = diff.left.get_default(key) if key not in data['files'] and key not in data['files_deleted']: raise http.Http404 diff.select(key) data['key'] = key if diff.is_diffable(): data['left'], data['right'] = diff.read_file() else: extract_file.delay(diff.left) extract_file.delay(diff.right) tmpl = 'content' if type_ == 'fragment' else 'viewer' return render(request, 'fileviewer/%s.html' % tmpl, data)
def compare(request, diff, key=None, type_='file'): form = forms.FileCompareForm(request.POST or None, addon=diff.addon, initial={'left': diff.left.file, 'right': diff.right.file}) response = check_compare_form(request, form) if response: return response data = setup_viewer(request, diff.left.file) data['diff'] = diff data['poll_url'] = reverse('mkt.files.compare.poll', args=[diff.left.file.id, diff.right.file.id]) data['form'] = form if (not waffle.switch_is_active('delay-file-viewer') and not diff.is_extracted()): extract_file(diff.left) extract_file(diff.right) if diff.is_extracted(): data.update({'status': True, 'files': diff.get_files(), 'files_deleted': diff.get_deleted_files()}) key = diff.left.get_default(key) if key not in data['files'] and key not in data['files_deleted']: raise http.Http404 diff.select(key) data['key'] = key if diff.is_diffable(): data['left'], data['right'] = diff.read_file() else: extract_file.delay(diff.left) extract_file.delay(diff.right) tmpl = 'content' if type_ == 'fragment' else 'viewer' return render(request, 'fileviewer/%s.html' % tmpl, data)
def browse(request, viewer, key=None, type="file"): data = setup_viewer(request, viewer.file) data["viewer"] = viewer data["poll_url"] = reverse("files.poll", args=[viewer.file.id]) if not waffle.switch_is_active("delay-file-viewer") and not viewer.is_extracted(): extract_file(viewer) if viewer.is_extracted(): data.update({"status": True, "files": viewer.get_files()}) key = viewer.get_default(key) if key not in data["files"]: raise http.Http404 viewer.select(key) data["key"] = key if not viewer.is_directory() and not viewer.is_binary(): data["content"] = viewer.read_file() else: extract_file.delay(viewer) tmpl = "files/content.html" if type == "fragment" else "files/viewer.html" return jingo.render(request, tmpl, data)