From ea13238049880d095cbde254f24307cec99f1acd Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Fri, 18 Mar 2016 21:08:10 +0100 Subject: [PATCH] Move function to setuptools for reusability --- setuptools/__init__.py | 7 ++++++- sslexpiry.py | 4 ++-- tweet.py | 8 -------- 3 files changed, 8 insertions(+), 11 deletions(-) delete mode 100755 tweet.py diff --git a/setuptools/__init__.py b/setuptools/__init__.py index f0801b1..dce80c0 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -1,4 +1,4 @@ -import configparser +import ast, configparser conffile = "config.cfg" @@ -11,3 +11,8 @@ def getSetting(section, setting): config.read(conffile) return config.get(section, setting) +def getListSetting(section, setting): + config = configparser.RawConfigParser() + config.read(conffile) + lit = config.get(section, setting) + return ast.literal_eval(lit) diff --git a/sslexpiry.py b/sslexpiry.py index 76efb3f..c6a6360 100755 --- a/sslexpiry.py +++ b/sslexpiry.py @@ -1,9 +1,9 @@ #!/usr/bin/python3 -import ast, datetime, setuptools, ssltools, twitools +import datetime, setuptools, ssltools, twitools if __name__ == "__main__": - hosts = ast.literal_eval(setuptools.getSetting("SSL", "hosts")) + hosts = setuptools.getListSetting("SSL", "hosts") pbefore = int(setuptools.getSetting("SSL", "pbefore")) pafter = int(setuptools.getSetting("SSL", "pafter")) two = twitools.twObject() diff --git a/tweet.py b/tweet.py deleted file mode 100755 index 4ca687c..0000000 --- a/tweet.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python3 - -import twitools - -if __name__ == "__main__": - two = twitools.twObject() - text = input("> ") - two.tweet(text)