From 1f193055f63d547d094383749e582d9fdf99d1a0 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Tue, 21 Jun 2022 20:04:58 +0200 Subject: [PATCH] Draft for path and separation --- modules/agnostic_paths.py | 2 +- modules/spidey_detector.py | 31 +++++++++++++++++++------------ spideyDetector.py | 8 +++++--- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/agnostic_paths.py b/modules/agnostic_paths.py index 6749070..00894be 100644 --- a/modules/agnostic_paths.py +++ b/modules/agnostic_paths.py @@ -7,7 +7,7 @@ import sys class AgnosticPaths: - def __init__(self, ptb): + def __init__(self, ptb, forced_path=None): self.ptb = ptb self.os = self.get_os() self.main_path = self.get_path() diff --git a/modules/spidey_detector.py b/modules/spidey_detector.py index ae7d024..11bf972 100644 --- a/modules/spidey_detector.py +++ b/modules/spidey_detector.py @@ -4,19 +4,26 @@ import sys class SpideyDetector: - def __init__(self, args): + def __init__(self, args, agnpath): """ - :param ptb: Whether you're using discord Public Test Version - :type ptb: bool + Main spidey runner + :param args: List of arguments + :type args: argparse.Namespace + :param agnpath: The path to the discord folder + :type agnpath: agnostic_path.AgnosticPath """ - if args.ptb: - self.ptb = "PTB" - else: - self.ptb = "" - self.is_windows = self.check_os() + self.ptb = args.ptb + self.agnostic_path = agnpath + self.os_name = agnpath.os + self.main_path = agnpath.main_path + self.latest_version = agnpath.latest_version + # self.is_windows = self.check_os() self.is_infected = False - self.paths = self.check_paths(*self.get_path()) - self.spidey_check() + self.detections = 0 + self.test_run = {} + + # self.paths = self.check_paths(*self.get_path()) + # self.spidey_check() def check_os(self): # noqa if not sys.platform.startswith('win'): @@ -90,8 +97,8 @@ class SpideyDetector: return self.is_infected -def run_check(ptb): - spd = SpideyDetector(ptb) +def run_check(args, agnpath): + spd = SpideyDetector(args, agnpath) if not spd.is_infected: return 0 else: diff --git a/spideyDetector.py b/spideyDetector.py index f678e02..8ccab05 100644 --- a/spideyDetector.py +++ b/spideyDetector.py @@ -2,7 +2,7 @@ """ Main program """ -from modules import spidey_detector +from modules import spidey_detector, agnostic_paths import argparse import sys @@ -12,7 +12,7 @@ def parse(_args): prog="Spidey Detector", description='Checks for corrupt discord install' ) - parser.add_argument('--ptb', action='store_true', help='Use Public Test Version') + parser.add_argument('--ptb', action='store_const', const="PTB", default="", help='Use Public Test Version') parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') parser.add_argument('-d', '--debug', action='store_true', help='Debug mode') parser.add_argument('-s', '--silent', action='store_true', help='Silent mode') @@ -32,8 +32,10 @@ def parse(_args): if __name__ == "__main__": args = parse(sys.argv[1:]) + agnostic_path = agnostic_paths.AgnosticPaths(ptb=args.ptb) try: - spd = spidey_detector.run_check(args) + spd = spidey_detector.run_check(args, agnostic_path) + except FileNotFoundError as er: print(er) sys.exit(1)