24
24
from .. import StateMachine
25
25
from ..Threading import Workers
26
26
27
+ from .PictureList import PictureList
27
28
from .PictureMailer import PictureMailer
28
29
from .PictureSaver import PictureSaver
30
+ from .PictureUploadWebdav import PictureUploadWebdav
29
31
30
32
31
33
class Worker :
@@ -34,6 +36,18 @@ def __init__(self, config, comm):
34
36
35
37
self ._comm = comm
36
38
39
+ # Picture list for assembled pictures
40
+ path = os .path .join (config .get ('Storage' , 'basedir' ),
41
+ config .get ('Storage' , 'basename' ))
42
+ basename = strftime (path , localtime ())
43
+ self ._pic_list = PictureList (basename )
44
+
45
+ # Picture list for individual shots
46
+ path = os .path .join (config .get ('Storage' , 'basedir' ),
47
+ config .get ('Storage' , 'basename' ) + '_shot_' )
48
+ basename = strftime (path , localtime ())
49
+ self ._shot_list = PictureList (basename )
50
+
37
51
self .initPostprocessTasks (config )
38
52
self .initPictureTasks (config )
39
53
@@ -42,24 +56,22 @@ def initPostprocessTasks(self, config):
42
56
self ._postprocess_tasks = []
43
57
44
58
# PictureSaver for assembled pictures
45
- path = os .path .join (config .get ('Storage' , 'basedir' ),
46
- config .get ('Storage' , 'basename' ))
47
- basename = strftime (path , localtime ())
48
- self ._postprocess_tasks .append (PictureSaver (basename ))
59
+ self ._postprocess_tasks .append (PictureSaver (self ._pic_list .basename ))
49
60
50
61
# PictureMailer for assembled pictures
51
62
if config .getBool ('Mailer' , 'enable' ):
52
63
self ._postprocess_tasks .append (PictureMailer (config ))
53
64
65
+ # PictureUploadWebdav to upload pictures to a webdav storage
66
+ if config .getBool ('UploadWebdav' , 'enable' ):
67
+ self ._postprocess_tasks .append (PictureUploadWebdav (config ))
68
+
54
69
def initPictureTasks (self , config ):
55
70
56
71
self ._picture_tasks = []
57
72
58
73
# PictureSaver for single shots
59
- path = os .path .join (config .get ('Storage' , 'basedir' ),
60
- config .get ('Storage' , 'basename' ) + '_shot_' )
61
- basename = strftime (path , localtime ())
62
- self ._picture_tasks .append (PictureSaver (basename ))
74
+ self ._picture_tasks .append (PictureSaver (self ._shot_list .basename ))
63
75
64
76
def run (self ):
65
77
@@ -73,23 +85,23 @@ def handleState(self, state):
73
85
if isinstance (state , StateMachine .TeardownState ):
74
86
self .teardown (state )
75
87
elif isinstance (state , StateMachine .ReviewState ):
76
- self .doPostprocessTasks (state .picture )
88
+ self .doPostprocessTasks (state .picture , self . _pic_list . getNext () )
77
89
elif isinstance (state , StateMachine .CameraEvent ):
78
90
if state .name == 'capture' :
79
- self .doPictureTasks (state .picture )
91
+ self .doPictureTasks (state .picture , self . _shot_list . getNext () )
80
92
else :
81
93
raise ValueError ('Unknown CameraEvent "{}"' .format (state ))
82
94
83
95
def teardown (self , state ):
84
96
85
97
pass
86
98
87
- def doPostprocessTasks (self , picture ):
99
+ def doPostprocessTasks (self , picture , filename ):
88
100
89
101
for task in self ._postprocess_tasks :
90
- task .do (picture )
102
+ task .do (picture , filename )
91
103
92
- def doPictureTasks (self , picture ):
104
+ def doPictureTasks (self , picture , filename ):
93
105
94
106
for task in self ._picture_tasks :
95
- task .do (picture )
107
+ task .do (picture , filename )
0 commit comments