def execute(self, app):
        """
        Handle the command line arguments then execute the app.

        :param app: the application instance
        :type app: refactor_imports.RefactorImportsApp
        """
        with RefactorImportsSettings() as settings:
            try:
                results = app.execute(settings)
                if results is not None:
                    self.report(results)
                exit(0)
            except ArgumentError as ex:
                error(str(ex))
                exit(1)
    def execute(self, app):
        """
        Handle the command line arguments then execute the app.

        :param app: the application instance
        :type app: pythonidae_scat.Pythonidae ScatApp
        """
        with PythonidaeScatSettings() as settings:
            try:
                results = app.execute(settings)
                if results is not None:
                    self.report(results)
                exit(0)
            except ArgumentError as ex:
                error(str(ex))
                exit(1)
Example #3
0
    def module_trace(module_spec, file_spec, tracer, q):
        """
        Load self.file_path and trace the imports

        :param module_spec: module path
        :type module_spec: str
        :param tracer: tracer context
        :type tracer: ImportTracer.ModuleTracer
        """

        # trace the import of the module
        info("__import__({name})".format(name=module_spec))
        sys.settrace(tracer.trace_imports)
        try:
            __import__(module_spec)
        except ImportError as ex:
            error("Error tracing import.  " + str(ex))
        sys.settrace(None)
        q.put(tracer.to_patch(file_spec))
Example #4
0
def self_signed_certs_allowed():
    try:

        import requests

        requests.packages.urllib3.disable_warnings()

        import ssl

        try:
            _create_unverified_https_context = ssl._create_unverified_context
        except AttributeError:
            # Legacy Python that doesn't verify HTTPS certificates by default
            pass
        else:
            # Handle target environment that doesn't support HTTPS verification
            ssl._create_default_https_context = _create_unverified_https_context

    except ImportError as ex:
        error(str(ex))