mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	default language check
This commit is contained in:
		@@ -1 +1,2 @@
 | 
				
			|||||||
from .checks import changed_password_check
 | 
					# this is here so that django finds the checks.
 | 
				
			||||||
 | 
					from .checks import *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					# this is here so that django finds the checks.
 | 
				
			||||||
 | 
					from .checks import *
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								src/paperless_tesseract/checks.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/paperless_tesseract/checks.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.conf import settings
 | 
				
			||||||
 | 
					from django.core.checks import Error, register
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_tesseract_langs():
 | 
				
			||||||
 | 
					    with subprocess.Popen(['tesseract', '--list-langs'], stdout=subprocess.PIPE) as p:
 | 
				
			||||||
 | 
					        stdout, stderr = p.communicate()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return stdout.decode().strip().split("\n")[1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@register()
 | 
				
			||||||
 | 
					def check_default_language_available(app_configs, **kwargs):
 | 
				
			||||||
 | 
					    langs = get_tesseract_langs()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if not settings.OCR_LANGUAGE in langs:
 | 
				
			||||||
 | 
					        return [Error(
 | 
				
			||||||
 | 
					            f"The default ocr language {settings.OCR_LANGUAGE} is "
 | 
				
			||||||
 | 
					            f"not installed. Paperless cannot OCR your documents "
 | 
				
			||||||
 | 
					            f"without it. Please fix PAPERLESS_OCR_LANGUAGE.")]
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        return []
 | 
				
			||||||
		Reference in New Issue
	
	Block a user