aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2021-03-09 00:55:04 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2021-03-09 00:55:04 -0500
commitfee4186f4ad11ec78f745d13665e45fd84625420 (patch)
tree83a6c29c1892c54c551932fda40142bd7e7da887
parent83d8c742065e4c453a3b6e58209ecf7c887ffe8e (diff)
downloadlog_raider-fee4186f4ad11ec78f745d13665e45fd84625420.tar.gz
Convert to package
-rw-r--r--.gitignore10
-rw-r--r--LICENSE.txt29
-rw-r--r--README.md1
-rw-r--r--log_raider/__init__.py1
-rw-r--r--log_raider/jenkins.py (renamed from jenkins_log_raider.py)30
-rw-r--r--pyproject.toml6
-rw-r--r--setup.py21
7 files changed, 89 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..29cc18b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+*.pyc
+__pycache__
+.idea
+build
+dist
+*.egg-info
+pip-*
+venv
+version.py
+consoleText*
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..63c8315
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2021, Association of Universities for Research in Astronomy
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1ab17c1
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# Log Raider
diff --git a/log_raider/__init__.py b/log_raider/__init__.py
new file mode 100644
index 0000000..87fbdb0
--- /dev/null
+++ b/log_raider/__init__.py
@@ -0,0 +1 @@
+from .version import version as __version__
diff --git a/jenkins_log_raider.py b/log_raider/jenkins.py
index 6fd9126..16096a5 100644
--- a/jenkins_log_raider.py
+++ b/log_raider/jenkins.py
@@ -1,7 +1,8 @@
import argparse
+import json
import os
import sys
-
+from . import __version__
PIPELINE_VERBOSE = False
PIPELINE_MARKER = "[Pipeline]"
@@ -165,20 +166,31 @@ def parse_log(filename):
def main():
global PIPELINE_VERBOSE
parser = argparse.ArgumentParser()
- parser.add_argument("logfile")
- parser.add_argument("-v", "--verbose", help="Increase verbosity")
+ parser.add_argument("-j", "--json", action="store_true", help="Emit JSON")
+ parser.add_argument("-v", "--verbose", action="store_true", help="Increase verbosity")
+ parser.add_argument("-V", "--version", action="store_true", help="Show version")
+ parser.add_argument("logfile", nargs='?')
+
args = parser.parse_args()
+ if args.version:
+ print(__version__)
+ exit(0)
+
if not os.path.exists(args.logfile):
print(f"{args.logfile}: does not exist")
- PIPELINE_VERBOSE = True
+ PIPELINE_VERBOSE = args.verbose
data = parse_log(args.logfile)
- for x in data:
- print("#" * 79)
- print(f"{x['type']} - {x['name']} (line @ {x['line']})")
- print("#" * 79)
- print(f"{x['data']}")
+
+ if args.json:
+ print(json.dumps(data, indent=2))
+ else:
+ for x in data:
+ print("#" * 79)
+ print(f"{x['type']} - {x['name']} (line @ {x['line']})")
+ print("#" * 79)
+ print(f"{x['data']}")
if __name__ == "__main__":
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..4a3eab1
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,6 @@
+[build-system]
+requires = [
+ "setuptools>=30.3.0",
+ "wheel",
+ "setuptools_scm"
+]
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..1f72777
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,21 @@
+from setuptools import setup
+from setuptools import find_packages
+
+setup(
+ name="log_raider",
+ use_scm_version={
+ "write_to": "log_raider/version.py",
+ },
+ packages=find_packages(),
+ setup_requires=[
+ "setuptools_scm",
+ ],
+ entry_points={
+ "console_scripts": [
+ "log_raider_jenkins = log_raider.jenkins:main",
+ ],
+ },
+ author="Joseph Hunkeler",
+ author_email="jhunk@stsci.edu",
+ url="https://github.com/spactelescope/log_raider",
+)