update setup.py to python 3, implement config file settings
authorAndrew Lorimer <andrew@charles.cortex>
Mon, 26 Aug 2019 12:03:04 +0000 (22:03 +1000)
committerAndrew Lorimer <andrew@charles.cortex>
Mon, 26 Aug 2019 12:03:04 +0000 (22:03 +1000)
logparse/interface.py
setup.py
index f2d5c7f79a033ae35835245fc46d15b87e7dd47e..f9a76b2b4c1c7a40dbb63361380543c5a4526388 100644 (file)
@@ -146,8 +146,12 @@ def main():
             else:
                 logger.warning("No output written")
 
-    if argparser.parse_args().to:
-       mail.sendmail(mailbin=prefs['mail']['mailbin'], body=mail.mailprep(output_html, prefs['css']), recipient=argparser.parse_args().to, subject=formatting.fsubject(config.prefs['mail']['subject']))
+    if argparser.parse_args().to or prefs['mail']['to']:
+        if argparser.parse_args().to:
+            to = argparser.parse_args().to
+        else:
+            to = prefs['mail']['to']
+        mail.sendmail(mailbin=prefs['mail']['mailbin'], body=mail.mailprep(output_html, prefs['css']), recipient=to, subject=formatting.fsubject(config.prefs['mail']['subject']))
     
     # Print end message
     finish = datetime.now()
index 42b28e0848a9ddd32201841535c98c6a8b9d12d7..5790025acc6ec76a04687df9c89d4080cc27a5c8 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,44 +1,36 @@
 from setuptools import setup
 from os import path
-# io.open is needed for projects that support Python 2.7
-# It ensures open() defaults to text mode with universal newlines,
-# and accepts an argument to specify the text encoding
-# Python 3 only projects can skip this import
-from io import open
 
 # Import main module so we can set the version
 import logparse
 
 here = path.abspath(path.dirname(__file__))
-__version__ = logparse.__version__      # https://www.python.org/dev/peps/pep-0440/   https://packaging.python.org/en/latest/single_source_version.html
+__version__ = logparse.__version__
 
 # Get the long description from the README file
 with open(path.join(here, 'README.md'), encoding='utf-8') as f:
     long_description = f.read()
 
 setup(
-    name='logparse',    # https://packaging.python.org/specifications/core-metadata/#name
-    version=logparse.__version__,      # https://www.python.org/dev/peps/pep-0440/   https://packaging.python.org/en/latest/single_source_version.html
+    name='logparse',                    # https://packaging.python.org/specifications/core-metadata/#name
+    version=logparse.__version__,       # https://www.python.org/dev/peps/pep-0440/   https://packaging.python.org/en/latest/single_source_version.html
     description='Summarise server logs',
     long_description_content_type='text/markdown',
     url='https://git.lorimer.id.au/logparse.git',
     author='Andrew Lorimer',
     author_email='andrew@lorimer.id.au',
-    classifiers=[       # https://pypi.org/classifiers/
+    classifiers=[                       # https://pypi.org/classifiers/
         'Development Status :: 4 - Beta',
         'Intended Audience :: System Administrators',
         'Topic :: System :: Systems Administration',
         'License :: OSI Approved :: MIT License',
-        'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
     ],
     keywords='logparse log parse analysis summary monitor email server',
     packages=['logparse', 'logparse.parsers'],
-#   python_requires='=2.5.*, =2.7.*',   # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
-    python_requires='>=3',   # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
-    install_requires=['premailer', 'requests', 'pyyaml'],  # https://packaging.python.org/en/latest/requirements.html
-#   extras_require={'dev': ['check-manifest'], 'test': ['coverage']},   # Additional dependencies; install with `pip install sampleproject[dev]`
-    data_files=[('/etc/logparse', ['logparse.conf', 'header.html', 'main.css'])],                  # installed to /etc/logparse
+    python_requires='>=3',              # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
+    install_requires=['premailer', 'requests', 'pyyaml'],   # https://packaging.python.org/en/latest/requirements.html
+    data_files=[('/etc/logparse', ['logparse.conf', 'header.html', 'main.css'])],   # installed to /etc/logparse
     project_urls={
         'Readme': 'https://git.lorimer.id.au/logparse.git/about',
         'Source': 'https://git.lorimer.id.au/logparse.git',