Skip to content

Commit

Permalink
Respect the deleted image during the preview
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jul 18, 2021
1 parent 935f411 commit c37039d
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions scan_to_paperless/scan.py
Expand Up @@ -132,20 +132,6 @@ def main() -> None:
else:
call(scanimage)

images = []
for img in os.listdir(root_folder):
if not img.startswith("image-"):
continue
images.append(os.path.join("source", img))

regex = re.compile(r"^source\/image\-([0-9]+)\.png$")

def image_match(image_name: str) -> int:
match = regex.match(image_name)
assert match
return int(match.group(1))

images = sorted(images, key=image_match)
args_: stp_config.Arguments = {}
args_.update(config.get("default_args", {}))
args_cmd = dict(args._get_kwargs()) # pylint: disable=protected-access
Expand All @@ -154,6 +140,29 @@ def image_match(image_name: str) -> int:
del args_cmd["double_sided"]
del args_cmd["set_config"]
args_.update(cast(stp_config.Arguments, args_cmd))

except subprocess.CalledProcessError as exception:
print(exception)
sys.exit(1)

print(root_folder)
subprocess.call([config.get("viewer", "eog"), root_folder]) # nosec

images = []
for img in os.listdir(root_folder):
if not img.startswith("image-"):
continue
images.append(os.path.join("source", img))

regex = re.compile(r"^source\/image\-([0-9]+)\.png$")

def image_match(image_name: str) -> int:
match = regex.match(image_name)
assert match
return int(match.group(1))

images = sorted(images, key=image_match)
if images:
process_config = {
"images": images,
"destination": destination,
Expand All @@ -167,10 +176,6 @@ def image_match(image_name: str) -> int:
"/master/scan_to_paperless/process_schema.json\n\n"
)
yaml.dump(process_config, config_file)

except subprocess.CalledProcessError as exception:
print(exception)
sys.exit(1)

print(root_folder)
subprocess.call([config.get("viewer", "eog"), root_folder]) # nosec
else:
os.rmdir(root_folder)
os.rmdir(base_folder)

0 comments on commit c37039d

Please sign in to comment.