Beispiel #1
0
    def delegate(self, args, **kwargs):
        """
        Executes the command based on the given cli args.

        Parameters
        ----------
        args: Namespace
            The argparse cli arguments
        kwargs: dict
            The arguments to be passed to the handler
        """

        Log.raw_info(self.BANNER)

        if not args.dry_run:

            Log.info("Setting up proxy config")
            Log.info("Proxy IP:   {}".format(args.proxy_ip))
            Log.info("Proxy PORT: {}".format(args.proxy_port))

            TorProxy.setup(args.proxy_ip, args.proxy_port)
            tor = TorCheck()
            tor_status = ""

            Log.info("Checking Tor Status")

            success = tor.check_tor_status()
            if success:
                tor_status = "{}{}".format(Fore.GREEN, "\033[1mREADY\033[0m")
            else:
                tor_status = "{}{}".format(Fore.RED, "\033[1mNOT READY\033[0m")

            Log.info("Tor Status: {}".format(tor_status))
            Log.info("Checking IP Address")
            Log.info("IP: \033[1m{}{}\033[0m".format(Fore.GREEN,
                                                     tor.check_ip()))

            if not success:
                raise ValueError("Unable to route traffic through Tor")

        else:

            Log.warn("Dry run enabled, skipping proxy setup")

        result = self.handler(kwargs)
        result_std = "{}\n".format(result)

        if args.output:
            out = args.output
            out.write(result)
            out.close()

        if args.dry_run or (not args.output and IOUtils.is_piped_output()):
            sys.stdout.write(result_std)
Beispiel #2
0
    def delegate(self, args, **kwargs):
        """
        Executes the command based on the given cli args.

        Parameters
        ----------
        args: Namespace
            The argparse cli arguments
        kwargs: dict
            The arguments to be passed to the handler
        """

        Log.raw_info(self.BANNER)

        Log.info("Checking wine installation")
        if not self.__which("wine"):
            raise ValueError("Unable to continue: wine NOT FOUND")

        Log.info("wine status: OK")
        self.handler(args, kwargs)
Beispiel #3
0
        sys.stderr.close()

    except KeyError:
        parser.print_help(sys.stderr)
        sys.exit(1)

    except ValueError as error:
        Log.error(str(error))
        sys.exit(1)


if __name__ == "__main__":

    try:

        url = None

        if IOUtils.is_piped_input():
            url = IOUtils.read_piped_input()

        cli_args = parser.parse_args()
        cli_args.url = cli_args.url or url

        main(cli_args)

    except KeyboardInterrupt:
        Log.raw_info("")
        Log.warn("User requested to stop")
        Log.warn("Killing all processes")
        os._exit(0)