forked from bodleian/goobi.scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep_tester.py
86 lines (49 loc) · 1.65 KB
/
step_tester.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Tester
Test the python step code.
Command line:
needs: process_id, and tiff_folder
optional: auto_complete, step_id, correction_step_name
Relies on steps:
none
Example run :
In Goobi:
/usr/bin/python /opt/digiverso/goobi/scripts/bdlss/step_tester.py process_id={processid} tiff_folder={tifpath}
From command line:
sudo -u tomcat6 python step_tester.py process_id=54 tiff_folder=/opt/digiverso/goobi/metadata/54/images/_7654321_tif
'''
from goobi.goobi_step import Step
class Step_Tester( Step ) :
def setup( s ):
s.name = "Test-a-step"
s.config_main_section = "step_tester"
s.essential_config_sections = set( [] )
s.essential_commandlines = {
"process_id":"number",
"tiff_path":"folder"
}
def step( s ):
"""
This just tests the step code
Try using, debug, auto_complete, detach and report_problem on commandline
"""
error = None
s.debug_message( "I'm some debug in Step_Tester" )
s.info_message( "I'm some info in Step_Tester" )
s.warning_message( "I'm some warning in Step_Tester" )
print "Doing nothing. Except printing this..."
if s.command_line.has( "create_error" ) :
print "Pretending something has gone wrong..."
error = "I'm some error in Step_Tester"
if s.detach :
# pretend we are doing something that takes a long time
import time
time.sleep( 5 )
s.info_message( "Completed something that took 15 seconds." )
s.warning_message( "Let's pretend there's a warning here." )
return error
if __name__ == '__main__' :
import config_ini
Step_Tester( config_ini.file ).begin()