Replace gs subprocess call (Wand experiment)
Replace gs subprocess call Update requirements.txtpull/2/head
parent
9b2fc53e58
commit
2527512f63
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import copy
|
import copy
|
||||||
|
import locale
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import ghostscript
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|
@ -174,16 +177,6 @@ class Lattice(BaseParser):
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def _generate_image(self):
|
def _generate_image(self):
|
||||||
# TODO: hacky, get rid of ghostscript #96
|
|
||||||
def get_platform():
|
|
||||||
import platform
|
|
||||||
|
|
||||||
info = {
|
|
||||||
'system': platform.system().lower(),
|
|
||||||
'machine': platform.machine().lower()
|
|
||||||
}
|
|
||||||
return info
|
|
||||||
|
|
||||||
self.imagename = ''.join([self.rootname, '.png'])
|
self.imagename = ''.join([self.rootname, '.png'])
|
||||||
gs_call = [
|
gs_call = [
|
||||||
'-q',
|
'-q',
|
||||||
|
|
@ -193,18 +186,9 @@ class Lattice(BaseParser):
|
||||||
'-r600',
|
'-r600',
|
||||||
self.filename
|
self.filename
|
||||||
]
|
]
|
||||||
info = get_platform()
|
encoding = locale.getpreferredencoding()
|
||||||
if info['system'] == 'windows':
|
args = [g.encode(encoding) for g in gs_call]
|
||||||
bit = info['machine'][-2:]
|
ghostscript.Ghostscript(*args)
|
||||||
gs_call.insert(0, 'gswin{}c.exe'.format(bit))
|
|
||||||
else:
|
|
||||||
if 'ghostscript' in subprocess.check_output(['gs', '-version']).decode('utf-8').lower():
|
|
||||||
gs_call.insert(0, 'gs')
|
|
||||||
else:
|
|
||||||
gs_call.insert(0, "gsc")
|
|
||||||
subprocess.call(
|
|
||||||
gs_call, stdout=open(os.devnull, 'w'),
|
|
||||||
stderr=subprocess.STDOUT)
|
|
||||||
|
|
||||||
def _generate_table_bbox(self):
|
def _generate_table_bbox(self):
|
||||||
self.image, self.threshold = adaptive_threshold(
|
self.image, self.threshold = adaptive_threshold(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
click==6.7
|
click==6.7
|
||||||
|
ghostscript==0.6
|
||||||
matplotlib==2.2.3
|
matplotlib==2.2.3
|
||||||
numpy==1.15.2
|
numpy==1.15.2
|
||||||
opencv-python==3.4.2.17
|
opencv-python==3.4.2.17
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue