Commit a3aa09da authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Rename existing output dir in psum module

Also warn the user when an output was renamed.
parent 77d92d87
......@@ -17,11 +17,11 @@ and the best fitting model (the one with the least reduced χ²) is given.
"""
import os
import sys
import atpy
import json
import numpy as np
from collections import OrderedDict
from datetime import datetime
from copy import deepcopy
from scipy import stats
from progressbar import ProgressBar
......@@ -129,13 +129,14 @@ class Module(common.AnalysisModule):
"""
# Create the output directory and stop it exists.
try:
os.mkdir(OUT_DIR)
except OSError:
print("pcigale can't create the {} directory, maybe "
"it already exists.".format(OUT_DIR))
sys.exit()
if os.path.exists(OUT_DIR):
new_name = datetime.now().strftime("%Y%m%d%H%M") + "_" + OUT_DIR
os.rename(OUT_DIR, new_name)
print("The existing {} directory was renamed to {}".format(
OUT_DIR,
new_name
))
os.mkdir(OUT_DIR)
# Open the warehouse
sed_warehouse = SedWarehouse(
......
......@@ -85,6 +85,10 @@ class Module(common.AnalysisModule):
if os.path.isfile(out_file):
new_name = datetime.now().strftime("%Y%m%d%H%M") + "_" + out_file
os.rename(out_file, new_name)
print("The existing {} file was renamed to {}".format(
out_file,
new_name
))
# Get the filters in the database
filter_names = [name for name in column_list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment