mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 01:19:15 +02:00
Better resilience for the genconfig function thanks to happy path and @Zykino suggestion!
This commit is contained in:
parent
85f0fe9b6f
commit
cf3d4c32c3
1 changed files with 5 additions and 6 deletions
|
@ -6,17 +6,16 @@ logger = logging.getLogger('Prismedia')
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
def genconfig():
|
def genconfig():
|
||||||
path = join(dirname(__file__), 'config')
|
path = join(dirname(__file__), 'config')
|
||||||
files = [f for f in listdir(path) if isfile(join(path, f))]
|
files = [f for f in listdir(path) if isfile(join(path, f))]
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
final_f = f.replace(".sample", "")
|
final_f = f.replace(".sample", "")
|
||||||
overwrite = True
|
if exists(final_f) and not utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?"):
|
||||||
if exists(final_f):
|
continue
|
||||||
overwrite = utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?")
|
|
||||||
|
|
||||||
if overwrite:
|
|
||||||
copyfile(join(path, f), final_f)
|
copyfile(join(path, f), final_f)
|
||||||
logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
|
logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue