From 5e14f01cd5f87bf27fab9ebf8ab4db008a7e9a45 Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Wed, 5 Jun 2019 12:18:42 +0200 Subject: [PATCH 1/3] =?UTF-8?q?chemin=20du=20fichier=20de=20sortie=20relat?= =?UTF-8?q?if=20=C3=A0=20l'emplacement=20du=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/getchannels.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/script/getchannels.py b/script/getchannels.py index 8bcdcd1..9339b13 100644 --- a/script/getchannels.py +++ b/script/getchannels.py @@ -7,6 +7,8 @@ from pprint import pprint from rocketchat_API.rocketchat import RocketChat import json import dev_config as cfg +import os +import inspect def getNodesOrigin(channel): nodes = [] @@ -93,7 +95,18 @@ while True: break index += channels['count'] -with open('../public/data/channelslist.json', "w") as file_write: +# 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épertoire pour stocker le fichier de sortie +dataFolderPath = scriptFolderPath + '/../public/data' +# Faut il essayer de le créer au cas ou? +# os.makedirs(dataFolderPath, exist_ok=True) + +with open(dataFolderPath + '/channelslist.json', "w") as file_write: json.dump(datas, file_write) pprint("Nb displayed channels : " + str(nbChannels)) From 4aa3d47cf139ee4ef8dc17c162566375e0e5104d Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Wed, 5 Jun 2019 16:57:23 +0200 Subject: [PATCH 2/3] 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)) From 28d26452acffa21453c1e71ef0ae48edd16dc686 Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Wed, 5 Jun 2019 21:51:23 +0200 Subject: [PATCH 3/3] remove unused import --- script/getchannels.py | 1 - 1 file changed, 1 deletion(-) diff --git a/script/getchannels.py b/script/getchannels.py index 572c4d9..7905ec7 100644 --- a/script/getchannels.py +++ b/script/getchannels.py @@ -8,7 +8,6 @@ from rocketchat_API.rocketchat import RocketChat import json import dev_config as cfg import os -import inspect def getNodesOrigin(channel): nodes = []