-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chg: [analysers] migrate apps parser to new model
- Loading branch information
1 parent
0a0e258
commit f5632a7
Showing
9 changed files
with
185 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,78 +2,19 @@ | |
|
||
# For Python3 | ||
# DEMO - Skeleton | ||
# Author: [email protected] | ||
|
||
import os | ||
import sys | ||
import json | ||
from datetime import datetime | ||
from optparse import OptionParser | ||
|
||
version_string = "sysdiagnose-demo-analyser.py v2023-04-28 Version 0.1" | ||
|
||
# ----- definition for analyse.py script -----# | ||
# ----- DO NOT DELETE ----# | ||
|
||
analyser_description = "Do something useful (DEMO)" | ||
analyser_call = "generate_something" | ||
analyser_format = "json" | ||
|
||
|
||
def generate_something(jsondir, filename): | ||
def analyse_path(case_folder: str, output_file: str = "demo-analyser.json") -> bool: | ||
""" | ||
Generate the timeline and save it to filename | ||
""" | ||
print("DO SOMETHING HERE") | ||
with open(output_file, 'w') as f: | ||
json.dump({"Hello": "World"}, f, indent=4) | ||
return | ||
|
||
|
||
# --------------------------------------------------------------------------- # | ||
""" | ||
Main function | ||
""" | ||
def main(): | ||
|
||
if sys.version_info[0] < 3: | ||
print("Must be using Python 3! Exiting ...") | ||
exit(-1) | ||
|
||
print(f"Running {version_string}\n") | ||
|
||
usage = "\n%prog -d JSON directory\n" | ||
|
||
parser = OptionParser(usage=usage) | ||
parser.add_option("-d", dest="inputdir", | ||
action="store", type="string", | ||
help="Directory containing JSON from parsers") | ||
parser.add_option("-o", dest="outputfile", | ||
action="store", type="string", | ||
help="JSON file to save output") | ||
(options, args) = parser.parse_args() | ||
|
||
# no arguments given by user, print help and exit | ||
if len(sys.argv) == 1: | ||
parser.print_help() | ||
sys.exit(-1) | ||
|
||
if options.inputdir: | ||
# do something | ||
if options.outputfile: | ||
print("Hello World") | ||
else: | ||
print("Something else") | ||
else: | ||
print("WARNING -i option is mandatory!") | ||
|
||
|
||
# --------------------------------------------------------------------------- # | ||
|
||
""" | ||
Call main function | ||
""" | ||
if __name__ == "__main__": | ||
|
||
# Create an instance of the Analysis class (called "base") and run main | ||
main() | ||
|
||
# That's all folks ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.