From b18d25eaa42bcb185657e3a3a5bc5ee37c39d68b Mon Sep 17 00:00:00 2001 From: Hong Jiang Date: Sun, 10 Sep 2023 12:53:40 +0800 Subject: [PATCH 1/2] only create directory for stocks when necessary This avoids printing an inacurate error every time. --- inkycal/modules/inkycal_stocks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inkycal/modules/inkycal_stocks.py b/inkycal/modules/inkycal_stocks.py index 0aedfcf..ca00cc9 100755 --- a/inkycal/modules/inkycal_stocks.py +++ b/inkycal/modules/inkycal_stocks.py @@ -82,7 +82,8 @@ class Stocks(inkycal_module): tmpPath = '/tmp/inkycal_stocks/' try: - os.mkdir(tmpPath) + if not os.path.exists(tmpPath): + os.mkdir(tmpPath) except OSError: print(f"Creation of tmp directory {tmpPath} failed") else: From b57d60bab9edf2b7f8674bbef7b316899adf0afd Mon Sep 17 00:00:00 2001 From: Hong Jiang Date: Sun, 10 Sep 2023 13:03:30 +0800 Subject: [PATCH 2/2] only print dir creation log when it actually happens --- inkycal/modules/inkycal_stocks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inkycal/modules/inkycal_stocks.py b/inkycal/modules/inkycal_stocks.py index ca00cc9..39002b2 100755 --- a/inkycal/modules/inkycal_stocks.py +++ b/inkycal/modules/inkycal_stocks.py @@ -84,10 +84,9 @@ class Stocks(inkycal_module): try: if not os.path.exists(tmpPath): os.mkdir(tmpPath) + print(f"Successfully created tmp directory {tmpPath} ") except OSError: print(f"Creation of tmp directory {tmpPath} failed") - else: - print(f"Successfully created tmp directory {tmpPath} ") # Check if internet is available if internet_available() == True: