Skip to content

Commit a9aa3e0

Browse files
committed
Fix bug checking output writable (MF)
1 parent d386379 commit a9aa3e0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

stormdb/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
from six import string_types
1212

1313

14+
def check_destination_exists(dest):
15+
return(os.access, os.F_OK)
16+
17+
1418
def check_destination_writable(dest):
1519
try:
1620
open(dest, 'w')

stormdb/process/maxfilter.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from .utils import _get_absolute_proj_path
2222
from ..base import (check_destination_writable, check_source_readable,
23-
mkdir_p)
23+
check_destination_exists, mkdir_p)
2424
from ..cluster import ClusterBatch
2525

2626

@@ -135,14 +135,13 @@ def build_cmd(self, in_fname, out_fname, origin='0 0 40',
135135
"""
136136
if not check_source_readable(in_fname):
137137
raise IOError('Input file {} not readable!'.format(in_fname))
138-
if not check_destination_writable(out_fname):
139-
if check_source_readable(out_fname) and not force:
138+
if check_destination_exists(out_fname):
139+
if not force:
140140
raise IOError('Output file {} exists, use force=True to '
141-
'overwrite!'.format(out_fname))
142-
else:
143-
raise IOError('Output file {} not writable!'.format(out_fname))
144-
else:
145-
output_dir = op.dirname(out_fname)
141+
'overwrite!'.format(out_fname))
142+
elif not check_destination_writable(out_fname):
143+
raise IOError('Output file {} not writable!'.format(out_fname))
144+
output_dir = op.dirname(out_fname)
146145

147146
# determine the head origin if necessary
148147
if origin is None:

0 commit comments

Comments
 (0)