def check_git_backend(app_configs, **kwargs): if find_git_http_backend() is None: return [ weblate_check( "weblate.E022", "Failed to find git-http-backend, the git exporter will not work.", ) ] return []
def check_git_backend(app_configs, **kwargs): if find_git_http_backend() is None: return [ Critical( 'Failed to find git-http-backend, ' 'the git exporter will not work.', hint=get_doc_url('admin/optionals', 'git-exporter'), id='weblate.E022', ) ] return []
def check_git_backend(app_configs, **kwargs): if find_git_http_backend() is None: return [ Critical( "Failed to find git-http-backend, " "the git exporter will not work.", hint=get_doc_url("admin/optionals", "git-exporter"), id="weblate.E022", ) ] return []
def run_git_http(request, obj, path): """Git HTTP backend execution wrapper.""" # Find Git HTTP backend git_http_backend = find_git_http_backend() if git_http_backend is None: return HttpResponseServerError('git-http-backend not found') # Invoke Git HTTP backend query = request.META.get('QUERY_STRING', '') process_env = { 'REQUEST_METHOD': request.method, 'PATH_TRANSLATED': os.path.join(obj.full_path, path), 'GIT_HTTP_EXPORT_ALL': '1', 'CONTENT_TYPE': request.META.get('CONTENT_TYPE', ''), 'QUERY_STRING': query, 'HTTP_CONTENT_ENCODING': request.META.get('HTTP_CONTENT_ENCODING', ''), } process = subprocess.Popen( [git_http_backend], env=process_env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) output, output_err = process.communicate(request.body) retcode = process.poll() # Log error if output_err: try: raise Exception('Git http backend error: {}'.format( force_text(output_err).splitlines()[0] )) except Exception as error: report_error(error, request, prefix='Git backend failure') # Handle failure if retcode: return HttpResponseServerError(output_err) headers, content = output.split(b'\r\n\r\n', 1) message = message_from_string(headers.decode('utf-8')) # Handle status in response if 'status' in message: return HttpResponse( status=int(message['status'].split()[0]) ) # Send content response = HttpResponse( content_type=message['content-type'] ) response.write(content) return response
def check_git_backend(app_configs, **kwargs): if find_git_http_backend() is None: return [ Critical( 'Failed to find git-http-backend, ' 'the git exporter will not work.', hint=get_doc_url('admin/optionals', 'git-exporter'), id='weblate.E022', ) ] return []
def run_git_http(request, obj, path): """Git HTTP backend execution wrapper.""" # Find Git HTTP backend git_http_backend = find_git_http_backend() if git_http_backend is None: return HttpResponseServerError('git-http-backend not found') # Invoke Git HTTP backend query = request.META.get('QUERY_STRING', '') process_env = { 'REQUEST_METHOD': request.method, 'PATH_TRANSLATED': os.path.join(obj.full_path, path), 'GIT_HTTP_EXPORT_ALL': '1', 'CONTENT_TYPE': request.META.get('CONTENT_TYPE', ''), 'QUERY_STRING': query, 'HTTP_CONTENT_ENCODING': request.META.get('HTTP_CONTENT_ENCODING', ''), } process = subprocess.Popen( [git_http_backend], env=process_env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) output, output_err = process.communicate(request.body) retcode = process.poll() # Log error if output_err: try: raise Exception( 'Git http backend error: {}'.format( force_text(output_err).splitlines()[0] ) ) except Exception as error: report_error(error, request, prefix='Git backend failure') # Handle failure if retcode: return HttpResponseServerError(output_err) headers, content = output.split(b'\r\n\r\n', 1) message = message_from_string(headers.decode('utf-8')) # Handle status in response if 'status' in message: return HttpResponse(status=int(message['status'].split()[0])) # Send content response = HttpResponse(content_type=message['content-type']) response.write(content) return response
def run_git_http(request, obj, path): """Git HTTP backend execution wrapper.""" # Find Git HTTP backend git_http_backend = find_git_http_backend() if git_http_backend is None: return HttpResponseServerError("git-http-backend not found") # Invoke Git HTTP backend query = request.META.get("QUERY_STRING", "") process_env = { "REQUEST_METHOD": request.method, "PATH_TRANSLATED": os.path.join(obj.full_path, path), "GIT_HTTP_EXPORT_ALL": "1", "CONTENT_TYPE": request.META.get("CONTENT_TYPE", ""), "QUERY_STRING": query, "HTTP_CONTENT_ENCODING": request.META.get("HTTP_CONTENT_ENCODING", ""), } process = subprocess.Popen( [git_http_backend], env=process_env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) output, output_err = process.communicate(request.body) retcode = process.poll() # Log error if output_err: try: raise Exception( "Git http backend error: {}".format( force_str(output_err).splitlines()[0] ) ) except Exception: report_error(cause="Git backend failure") # Handle failure if retcode: return HttpResponseServerError(output_err) headers, content = output.split(b"\r\n\r\n", 1) message = message_from_string(headers.decode()) # Handle status in response if "status" in message: return HttpResponse(status=int(message["status"].split()[0])) # Send content response = HttpResponse(content_type=message["content-type"]) response.write(content) return response