Skip to content

Commit

Permalink
Get permissions correct for all output files
Browse files Browse the repository at this point in the history
  • Loading branch information
kwilcox committed Aug 14, 2017
1 parent 7caba73 commit 7937f72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions gutils/nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def create_netcdf(attrs, data, output_path, mode):

# Move to final destination
safe_makedirs(os.path.dirname(output_file))
os.chmod(tmp_path, 0o664)
shutil.move(tmp_path, output_file)
L.info('Created: {}'.format(output_file))
except BaseException as e:
Expand Down
15 changes: 12 additions & 3 deletions gutils/watch/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,24 @@ def create_and_update_content(self, event):

# Replace old datasets.xml
os.close(new_datasets_handle)
os.chmod(new_datasets_path, 0o664)
shutil.move(new_datasets_path, datasets_path)

finally:
# Write dataset update flag if it doesn't exist
if self.erddap_flag_path is not None:
flagfile = os.path.join(self.erddap_flag_path, deployment_name)
if not os.path.isfile(flagfile):
with open(flagfile, 'w') as ff:
flag_tmp_handle, flag_tmp_path = tempfile.mkstemp(prefix='gutils_errdap_', suffix='.flag')
final_flagfile = os.path.join(self.erddap_flag_path, deployment_name)

if not os.path.isfile(final_flagfile):
with open(flag_tmp_path, 'w') as ff:
ff.write(datetime.utcnow().isoformat())
os.chmod(flag_tmp_path, 0o666)
shutil.move(flag_tmp_path, final_flagfile)

os.close(flag_tmp_handle)
if os.path.exists(flag_tmp_path):
os.remove(flag_tmp_path)

os.close(tmp_handle)
if os.path.exists(tmp_path):
Expand Down

0 comments on commit 7937f72

Please sign in to comment.