0001-mdel-make-connector-s-input-and-output-dirs-properti.patch
passerelle/apps/mdel/models.py | ||
---|---|---|
151 | 151 |
return {'data': [item for item in CERTIFICATE_TYPES |
152 | 152 |
if item.get('id') not in without.split(',')]} |
153 | 153 | |
154 |
@property |
|
155 |
def input_dir(self): |
|
156 |
return os.path.join(mdel.get_resource_base_dir(), |
|
157 |
self.slug, 'inputs') |
|
158 | ||
159 |
@property |
|
160 |
def output_dir(self): |
|
161 |
return os.path.join(mdel.get_resource_base_dir(), |
|
162 |
self.slug, 'outputs') |
|
163 | ||
154 | 164 | |
155 | 165 |
@six.python_2_unicode_compatible |
156 | 166 |
class Demand(models.Model): |
... | ... | |
193 | 203 |
flow_type = self.flow_type |
194 | 204 |
demand_num = self.num |
195 | 205 | |
196 |
resource_base_dir = mdel.get_resource_base_dir() |
|
197 | ||
198 |
inputs_dir = os.path.join(resource_base_dir, self.resource.slug, |
|
199 |
'inputs', self.name) |
|
206 |
inputs_dir = os.path.join(self.resource.input_dir, self.name) |
|
200 | 207 |
input_files = {} |
201 | 208 |
attached_files = [] |
202 | 209 | |
... | ... | |
351 | 358 | |
352 | 359 |
namespace = {'ns2': 'http://finances.gouv.fr/dgme/pec/message/v1'} |
353 | 360 | |
354 |
resource_base_dir = mdel.get_resource_base_dir() |
|
355 |
output_dir = os.path.join(resource_base_dir, self.resource.slug, 'outputs') |
|
356 | ||
357 |
if not os.path.exists(output_dir): |
|
358 |
os.makedirs(output_dir) |
|
361 |
if not os.path.exists(self.resource.output_dir): |
|
362 |
os.makedirs(self.resource.output_dir) |
|
359 | 363 | |
360 | 364 |
# list all demand response zip files |
361 | 365 |
zip_files = {} |
362 |
for zfile in os.listdir(output_dir): |
|
366 |
for zfile in os.listdir(self.resource.output_dir):
|
|
363 | 367 |
if zfile.lower().startswith(self.demand_id.lower()) and zfile.lower().endswith('.zip'): |
364 | 368 |
fname = os.path.splitext(zfile)[0] |
365 | 369 |
try: |
... | ... | |
375 | 379 |
else: |
376 | 380 |
return result |
377 | 381 | |
378 |
path = os.path.join(output_dir, zip_file) |
|
382 |
path = os.path.join(self.resource.output_dir, zip_file)
|
|
379 | 383 | |
380 | 384 |
content = get_file_content_from_zip(path, 'message.xml') |
381 | 385 |
element = mdel.etree.fromstring(content) |
382 |
- |