From 302240df65dc9f7bc77aa2442dd67264ed579952 Mon Sep 17 00:00:00 2001 From: lelgenio Date: Mon, 5 Oct 2020 21:09:07 -0300 Subject: [PATCH] use a sorted PATH to avoid re-runs --- dotfiles/crontab | 2 +- funcs.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dotfiles/crontab b/dotfiles/crontab index a7dc135..6bc6259 100644 --- a/dotfiles/crontab +++ b/dotfiles/crontab @@ -1,5 +1,5 @@ # {{@@ header() @@}} -PATH={{@@ env["PATH"] @@}} +PATH={{@@ ordered_path() @@}} #minute hour day month day_week cmd */5 * * * * forecast json diff --git a/funcs.py b/funcs.py index 8499c6d..1af0f99 100644 --- a/funcs.py +++ b/funcs.py @@ -3,3 +3,14 @@ import os def parent_dir(path): return os.path.split(path)[0] + + +def ordered_path(): + PATH = os.environ['PATH'] + + newPATH = [] + for i in PATH.split(":"): + if i not in newPATH: + newPATH.append(i) + + return ':'.join(newPATH)