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,19 +6,18 @@ logger = logging.getLogger('Prismedia')
|
|||
|
||||
from . import utils
|
||||
|
||||
|
||||
def genconfig():
|
||||
path = join(dirname(__file__), 'config')
|
||||
files = [f for f in listdir(path) if isfile(join(path, f))]
|
||||
|
||||
for f in files:
|
||||
final_f = f.replace(".sample", "")
|
||||
overwrite = True
|
||||
if exists(final_f):
|
||||
overwrite = utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?")
|
||||
if exists(final_f) and not utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?"):
|
||||
continue
|
||||
|
||||
if overwrite:
|
||||
copyfile(join(path, f), final_f)
|
||||
logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
|
||||
copyfile(join(path, f), final_f)
|
||||
logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue