Merge pull request #1 from idle-org/dev-dan

Draft for path and separation
This commit is contained in:
Maximilien Rigaut 2022-06-21 20:06:25 +02:00 committed by GitHub
commit f5e98dc628
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 16 deletions

View File

@ -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()

View File

@ -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:

View File

@ -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)