Skip to content

Commit 89c3355

Browse files
authored
Merge pull request #20 from zkhan12/master
change logic towards writing to log file when replace is no
2 parents 705e140 + 41b544d commit 89c3355

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

accel_code/run.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ def main():
9595

9696
# copy the file to the new project specific location
9797
try:
98-
utils.make_directory(opts.old_file_path, new_file_path, opts.replace)
98+
file_copied = utils.make_directory(opts.old_file_path, new_file_path, opts.replace)
9999
except Exception as e:
100100
msg = "could not copy file: {} ({})"
101101
logger.exception(msg.format(lab_id, str(date)))
102102
raise(e)
103-
104-
logger.info("{of} -> {nf}".format(of=opts.old_file_path, nf=new_file_path))
103+
104+
if file_copied:
105+
logger.info("{of} -> {nf}".format(of=opts.old_file_path, nf=new_file_path))
105106

106107
return
107108

accel_code/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,14 @@ def get_test_data_path(project):
159159
def make_directory(old_path, new_path, replace):
160160
if os.path.exists(new_path):
161161
if replace == 'no':
162-
raise ValueError('replace option was not specified and output file exists', new_path)
162+
print('replace option was set to no and output file exists', new_path)
163+
return False
164+
163165
if replace == 'yes':
164166
os.remove(new_path)
165167
copyfile(old_path, new_path)
168+
return True
166169
else:
167170
os.makedirs(os.path.dirname(new_path), exist_ok=True)
168171
copyfile(old_path, new_path)
172+
return True

0 commit comments

Comments
 (0)