@@ -80,30 +80,8 @@ def get_resource(self, filename):
80
80
81
81
return []
82
82
83
- def install_file_stub (self , target ):
84
- """
85
- Installs any data associated with the resource object that is going to be deployed from the **ecFlow** server.
86
-
87
- Parameters:
88
- target(Deployment): The target deployment where the resource data should be installed.
89
- """
90
-
91
- """
92
- n.b. If a resource does not need to save data at deployment time, it should not do so (e.g. WebResource)
93
- """
94
- # Install path is for the suite, so we don't need to include the suite name
95
- assert self .fullname .count ("/" ) > 1
96
- subpath = self .fullname [self .fullname .find ("/" , 1 ) + 1 :]
97
-
98
- self ._server_filename = os .path .join (
99
- target .files_install_path (), subpath , self .name
100
- )
101
-
102
- super ().install_file_stub (target )
103
83
104
- self .save_data (target , self ._server_filename )
105
-
106
- def build_script (self ):
84
+ def generate_script (self ):
107
85
"""
108
86
Returns the installer script for the data resource.
109
87
@@ -128,7 +106,7 @@ def build_script(self):
128
106
for h in self ._hosts :
129
107
lines += h .copy_file_to (self ._server_filename , self .location ()).split ("\n " )
130
108
131
- return lines
109
+ return lines , []
132
110
133
111
def location (self ):
134
112
"""
@@ -141,6 +119,7 @@ def location(self):
141
119
return os .path .join (self ._resource_directory , self .name )
142
120
143
121
122
+
144
123
class DataResource (Resource ):
145
124
"""
146
125
Provides a data resource to be deployed at suite generation time.
@@ -206,9 +185,8 @@ class FileResource(Resource):
206
185
"""
207
186
208
187
def __init__ (self , name , hosts , source_file ):
209
- self ._source = source_file
210
-
211
188
super ().__init__ (name , hosts )
189
+ self ._server_filename = source_file
212
190
213
191
def md5 (self ):
214
192
"""
@@ -219,19 +197,22 @@ def md5(self):
219
197
"""
220
198
221
199
m = hashlib .md5 ()
222
- m .update (self .data () )
200
+ m .update (self ._data )
223
201
return m .hexdigest ()
224
202
225
- def data (self ):
203
+ def get_resource (self , filename ):
226
204
"""
227
205
Returns the resource data from the provided file.
228
206
229
207
Returns:
230
208
The resource data.
231
209
"""
232
210
233
- with open (self ._source , "rb" ) as f :
234
- return f .read ()
211
+ with open (filename , "rb" ) as f :
212
+ return [
213
+ 'mkdir -p $(dirname "{}")' .format (filename ),
214
+ f .read ()
215
+ ]
235
216
236
217
def save_data (self , target , filename ):
237
218
"""
0 commit comments