1 # -------------------------------------------------------------------------
2 # Copyright (c) 2015-2017 AT&T Intellectual Property
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # -------------------------------------------------------------------------
21 from osdf.logging.osdf_logging import metrics_log, MH, warn_audit_error
24 def local_create_job_file(req_id, json_req, fname='osdf-req-data.json'):
25 """Creates a "work" folder for local processing and place relevant
26 job task file in there"""
28 work_dir = 'osdf-optim/work/' + req_id
29 work_file = '{}/{}'.format(work_dir, fname)
31 cur_task = "Making a local directory in the OSDF manager for req-id: {}".format(req_id)
32 metrics_log.info(MH.creating_local_env(cur_task))
33 os.makedirs(work_dir, exist_ok=True)
34 except Exception as err:
35 warn_audit_error(MH.error_local_env(req_id, "Can't create directory {}".format(work_dir), err))
38 with open(work_file, 'w') as fid:
39 fid.write(json_req['payload'])
41 except Exception as err:
42 warn_audit_error(MH.error_local_env(req_id, "can't create file {}".format(work_file), err))