Beispiel #1
0
class Ph0enix:
    def __init__(self):
        self.Config = CoreConfig()
        self.Cmd = Command()
        self.Validator = Validation()
        self.Request = RequestHandler()
        self.Error = ErrorHandler()

    def BuildLinks(self, Username: str):
        self.Username: str = Username

        self.BuiltLinks = self.Validator.LinkFormatter(self.Username)
        if (len(self.BuiltLinks) > 0):
            return self.BuiltLinks
        else:
            self.Cmd.Clear()
            print(f"{sd.eBan} No data found")
            Initiate()

    def StartSearch(self, Username, FormattedLinks: list):
        self.Username = Username
        self.Links: list = FormattedLinks

        self.FoundCount = 0
        self.Matches = []

        print(f"{sd.sBan} Searching for {bc.GC}{Username}{bc.BC}\n")
        for self.Link in self.Links:
            self.Website = self.Validator.GetWebsiteName(self.Link)
            self.IsInSite = self.Request.Search(self.Link, self.Username)

            if (self.IsInSite):
                self.FoundCount += 1
                self.Matches.append(self.Link)
                print(
                    f" | Website: {bc.GC}{self.Website}{bc.BC}\n | Status: {bc.GC}Match Found{bc.BC}\n | Location: {bc.GC}{self.Link}{bc.BC}\n"
                )
            else:
                print(
                    f" | Website: {bc.RC}{self.Website}{bc.BC}\n | Status: {bc.RC}Not Found{bc.BC}\n | Location: {bc.RC}{self.Link}{bc.BC}\n"
                )

        return self.Matches, self.FoundCount

    def PrintResults(self, Results: list, FoundNum: int, TotalLinkCount: int):
        self.Cmd.Clear()
        self.Results: list = Results
        self.FoundCount = FoundNum
        self.TotalLinkCount = TotalLinkCount

        print(
            f"{sd.sBan} Found {bc.GC}{str(self.FoundCount)}{bc.BC} matches out of {bc.GC}{self.TotalLinkCount}{bc.BC} websites\n"
        )
        for self.Match in self.Results:
            print(
                f" | Website: {bc.GC}{self.Validator.GetWebsiteName(self.Match)}{bc.BC}"
            )
            print(f" | Location: {bc.GC}{self.Match}{bc.BC}\n")

        Initiate(True)
Beispiel #2
0
    def commit(cls, message):
        command = ["git", "commit", "-m", "{}".format(message)]
        out = Command(command, cls.path, split=False)
        if not out.returncode == 0:
            print("git commit: {}".format(out.stderroutput))

        return out
Beispiel #3
0
    def apply_and_stage(cls, patch):
        with open(cls.path + "/commit", 'wb') as file:
            file.write(patch)
        out = Command("git apply commit", cls.path)
        res = out.returncode == 0
        if not out.returncode == 0:
            print("git apply: {}".format(out.stderroutput))

        out = Command("git add .", cls.path)
        res = res and out.returncode == 0
        if not out.returncode == 0:
            print("git add: {}".format(out.stderroutput))
        out = Command("git reset -- commit", cls.path)
        res = res and out.returncode == 0
        if not out.returncode == 0:
            print("git reset: {}".format(out.stderroutput))
        return res
Beispiel #4
0
 def __init__(self):
     self.Config = CoreConfig()
     self.Cmd = Command()
     self.Validator = Validation()
     self.Request = RequestHandler()
     self.Error = ErrorHandler()
Beispiel #5
0
                f" | Website: {bc.GC}{self.Validator.GetWebsiteName(self.Match)}{bc.BC}"
            )
            print(f" | Location: {bc.GC}{self.Match}{bc.BC}\n")

        Initiate(True)


if __name__ == '__main__':

    def Initiate(SeenIntro=False):
        try:
            Run = Ph0enix()

            if (not SeenIntro):
                print(
                    f"{sd.iBan} Matches may not always be specific to the user you are looking for"
                )
                print(
                    f"{sd.iBan} For example, someone else could have used the same username elsewhere\n"
                )

            Username = InputManager().SetUsername()
            WebsiteLinks = Run.BuildLinks(Username)
            SearchResults, FoundCount = Run.StartSearch(Username, WebsiteLinks)
            Run.PrintResults(SearchResults, FoundCount, len(WebsiteLinks))
        except KeyboardInterrupt:
            quit()

    Command().Clear()
    Initiate()
Beispiel #6
0
    def valid_repository(cls):
        if cls.path == "" or not os.path.isdir(cls.path):
            return False
        status = Command("git status", cls.path)

        return status.returncode == 0
Beispiel #7
0
 def reset_to(cls, commit):
     res = Command("git reset --hard {}".format(commit), cls.path)
     return res.stderroutput == ""
Beispiel #8
0
 def stash(cls):
     res = Command("git stash -u", cls.path)
     return res.stderroutput == ""
Beispiel #9
0
 def stash_pop(cls):
     res = Command("git stash pop", cls.path)
     return res.stderroutput == ""
Beispiel #10
0
 def tag(cls, tag):
     res = Command("git tag {}".format(tag), cls.path)
     return res.stderroutput == ""
Beispiel #11
0
 def raw_diff(cls, commit):
     res = Command("git diff-tree -p {}".format(commit),
                   cls.path,
                   decodeUtf8=False)
     return res.stdoutput.split(b'\n')[1:-1]
Beispiel #12
0
 def message(cls, commit):
     res = Command("git log -n 1 --pretty=format:%s {}".format(commit),
                   cls.path)
     return res.stdoutput
Beispiel #13
0
 def parents(cls, commit):
     res = Command("git rev-list --parents -n 1 {}".format(commit),
                   cls.path)
     return res.stdoutput.strip().split(" ")[1:]
Beispiel #14
0
 def current_hash(cls):
     return Command("git rev-parse HEAD", cls.path).stdoutput.strip()