-
Notifications
You must be signed in to change notification settings - Fork 17
/
status
executable file
·42 lines (37 loc) · 1.4 KB
/
status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import glob
import re
import subprocess
import yaml
for folder in glob.glob('/home/sbrunner/dsl/paperless/scan/*/'):
print(re.sub(r'.', '-', folder))
print(folder)
if not os.path.exists(os.path.join(folder, 'config.yaml')):
print("No config")
else:
with open(os.path.join(folder, 'config.yaml')) as config_file:
config = yaml.load(config_file.read())
if os.path.exists(os.path.join(folder, 'error.yaml')):
with open(os.path.join(folder, 'error.yaml')) as error_file:
error = yaml.load(error_file.read())
if 'error' in error:
print(error['error'])
if isinstance(error, subprocess.CalledProcessError):
print(e.output.decode())
if e.stderr:
print(e.stderr)
if 'traceback' in error:
print('\n'.join(error['traceback']))
else:
print('Unknown error')
print(error)
else:
if config.get('waiting', False):
if os.path.exists(os.path.join(folder, 'waiting')):
print('To be validated')
else:
print('Waiting to be imported')
else:
print('Not ready')