From 4aa3d47cf139ee4ef8dc17c162566375e0e5104d Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Wed, 5 Jun 2019 16:57:23 +0200 Subject: [PATCH] use __file__ instead of inspect add .gitignore --- script/.gitignore | 1 + script/getchannels.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 script/.gitignore diff --git a/script/.gitignore b/script/.gitignore new file mode 100644 index 0000000..c564293 --- /dev/null +++ b/script/.gitignore @@ -0,0 +1 @@ +dev_config.py diff --git a/script/getchannels.py b/script/getchannels.py index 9339b13..572c4d9 100644 --- a/script/getchannels.py +++ b/script/getchannels.py @@ -95,18 +95,17 @@ while True: break index += channels['count'] -# Récupération du chemin ou est installé le script -scriptFileName = pprint(inspect.getfile(inspect.currentframe())) -# scriptFileName contiens habituellement le chemin complet mais pas toujours -# (ce n'est pas le cas sur Mac OSX par exemple). -scriptFolderPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) - +# Récupération du répertoire racine du repo +rootFolder = os.path.join(os.path.dirname(__file__), '..') # Répertoire pour stocker le fichier de sortie -dataFolderPath = scriptFolderPath + '/../public/data' +dataFolder = os.path.join(rootFolder, 'public','data') # Faut il essayer de le créer au cas ou? # os.makedirs(dataFolderPath, exist_ok=True) +channelsFilePath = os.path.abspath(os.path.join(dataFolder,'channelslist.json')) -with open(dataFolderPath + '/channelslist.json', "w") as file_write: +#print("Ecriture dans : "+channelsFilePath) + +with open(channelsFilePath, "w") as file_write: json.dump(datas, file_write) pprint("Nb displayed channels : " + str(nbChannels))