mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	use pkg_resources
This change uses if no path for e capabilities-file is supplied a temporary file created by pkg_resources, which should be more robust than directly accessing the file. (This failed sometimes, for example in zipped distributions or uncommon structures)
This commit is contained in:
		@@ -3,6 +3,7 @@ Pillow>=2.0
 | 
				
			|||||||
qrcode>=4.0
 | 
					qrcode>=4.0
 | 
				
			||||||
pyserial
 | 
					pyserial
 | 
				
			||||||
sphinx-rtd-theme
 | 
					sphinx-rtd-theme
 | 
				
			||||||
 | 
					setuptools
 | 
				
			||||||
setuptools-scm
 | 
					setuptools-scm
 | 
				
			||||||
docutils>=0.12
 | 
					docutils>=0.12
 | 
				
			||||||
python-barcode>=0.11.0,<1
 | 
					python-barcode>=0.11.0,<1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,6 +40,7 @@ install_requires =
 | 
				
			|||||||
    qrcode>=4.0
 | 
					    qrcode>=4.0
 | 
				
			||||||
    pyserial
 | 
					    pyserial
 | 
				
			||||||
    python-barcode>=0.9.1,<1
 | 
					    python-barcode>=0.9.1,<1
 | 
				
			||||||
 | 
					    setuptools
 | 
				
			||||||
    six
 | 
					    six
 | 
				
			||||||
    appdirs
 | 
					    appdirs
 | 
				
			||||||
    PyYAML
 | 
					    PyYAML
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
import re
 | 
					import re
 | 
				
			||||||
from os import environ, path
 | 
					from os import environ, path
 | 
				
			||||||
 | 
					import pkg_resources
 | 
				
			||||||
import pickle
 | 
					import pickle
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
@@ -15,9 +16,9 @@ logger = logging.getLogger(__name__)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pickle_dir = environ.get('ESCPOS_CAPABILITIES_PICKLE_DIR', gettempdir())
 | 
					pickle_dir = environ.get('ESCPOS_CAPABILITIES_PICKLE_DIR', gettempdir())
 | 
				
			||||||
pickle_path = path.join(pickle_dir, '{v}.capabilities.pickle'.format(v=platform.python_version()))
 | 
					pickle_path = path.join(pickle_dir, '{v}.capabilities.pickle'.format(v=platform.python_version()))
 | 
				
			||||||
capabilities_path = environ.get(
 | 
					# get a temporary file from pkg_resources if no file is specified in env
 | 
				
			||||||
    'ESCPOS_CAPABILITIES_FILE',
 | 
					capabilities_path = environ.get('ESCPOS_CAPABILITIES_FILE',
 | 
				
			||||||
    path.join(path.dirname(__file__), 'capabilities.json'))
 | 
					                                pkg_resources.resource_filename(__name__, 'capabilities.json'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Load external printer database
 | 
					# Load external printer database
 | 
				
			||||||
t0 = time.time()
 | 
					t0 = time.time()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user