Beispiel #1
0
    def project_closed(self, project):
        """
        Called when a project is closed.

        :param project: Project instance
        """

        yield from super().project_closed(project)
        # delete useless Dynamips files
        project_dir = project.module_working_path(self.module_name.lower())
        files = glob.glob(os.path.join(project_dir, "*.ghost"))
        files += glob.glob(os.path.join(project_dir, "*_lock"))
        files += glob.glob(os.path.join(project_dir, "ilt_*"))
        files += glob.glob(os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_i[0-9]*_rommon_vars"))
        files += glob.glob(os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_i[0-9]*_ssa"))
        files += glob.glob(os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_i[0-9]*_log.txt"))
        files += glob.glob(os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_i[0-9]*_rom"))
        files += glob.glob(os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_i[0-9]*_bootflash"))
        for file in files:
            try:
                log.debug("Deleting file {}".format(file))
                if file in self._ghost_files:
                    self._ghost_files.remove(file)
                yield from wait_run_in_executor(os.remove, file)
            except OSError as e:
                log.warn("Could not delete file {}: {}".format(file, e))
                continue
Beispiel #2
0
    def project_closed(self, project):
        """
        Called when a project is closed.

        :param project: Project instance
        """

        yield from super().project_closed(project)
        # delete useless Dynamips files
        project_dir = project.module_working_path(self.module_name.lower())
        files = glob.glob(os.path.join(project_dir, "*.ghost"))
        files += glob.glob(os.path.join(project_dir, "*_lock"))
        files += glob.glob(os.path.join(project_dir, "ilt_*"))
        files += glob.glob(
            os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_*_rommon_vars"))
        files += glob.glob(
            os.path.join(project_dir, "c[0-9][0-9][0-9][0-9]_*_ssa"))
        for file in files:
            try:
                log.debug("Deleting file {}".format(file))
                if file in self._ghost_files:
                    self._ghost_files.remove(file)
                yield from wait_run_in_executor(os.remove, file)
            except OSError as e:
                log.warn("Could not delete file {}: {}".format(file, e))
                continue
    def project_closed(self, project):
        """
        Called when a project is closed.

        :param project: Project instance
        """
        yield from super().project_closed(project)
        # delete useless Dynamips files
        project_dir = project.module_working_path(self.module_name.lower())
        files = glob.glob(os.path.join(glob_escape(project_dir), "*.ghost"))
        files += glob.glob(os.path.join(glob_escape(project_dir), "*_lock"))
        files += glob.glob(os.path.join(glob_escape(project_dir), "ilt_*"))
        files += glob.glob(os.path.join(glob_escape(project_dir), "c[0-9][0-9][0-9][0-9]_i[0-9]*_rommon_vars"))
        files += glob.glob(os.path.join(glob_escape(project_dir), "c[0-9][0-9][0-9][0-9]_i[0-9]*_log.txt"))
        for file in files:
            try:
                log.debug("Deleting file {}".format(file))
                if file in self._ghost_files:
                    self._ghost_files.remove(file)
                yield from wait_run_in_executor(os.remove, file)
            except OSError as e:
                log.warn("Could not delete file {}: {}".format(file, e))
                continue

        # Release the dynamips ids if we want to reload the same project
        #  later
        if project.id in self._dynamips_ids:
            del self._dynamips_ids[project.id]
Beispiel #4
0
def test_exception_wait_run_in_executor(loop):
    def raise_exception():
        raise Exception("test")

    exec = wait_run_in_executor(raise_exception)
    with pytest.raises(Exception):
        result = loop.run_until_complete(asyncio. async (exec))
Beispiel #5
0
def test_wait_run_in_executor(loop):
    def change_var(param):
        return param

    exec = wait_run_in_executor(change_var, "test")
    result = loop.run_until_complete(asyncio. async (exec))
    assert result == "test"
Beispiel #6
0
    def project_closed(self, project):
        """
        Called when a project is closed.

        :param project: Project instance
        """
        yield from super().project_closed(project)
        # delete useless Dynamips files
        project_dir = project.module_working_path(self.module_name.lower())

        files = glob.glob(os.path.join(glob.escape(project_dir), "*.ghost"))
        files += glob.glob(os.path.join(glob.escape(project_dir), "*_lock"))
        files += glob.glob(os.path.join(glob.escape(project_dir), "ilt_*"))
        files += glob.glob(
            os.path.join(glob.escape(project_dir),
                         "c[0-9][0-9][0-9][0-9]_i[0-9]*_rommon_vars"))
        files += glob.glob(
            os.path.join(glob.escape(project_dir),
                         "c[0-9][0-9][0-9][0-9]_i[0-9]*_log.txt"))
        for file in files:
            try:
                log.debug("Deleting file {}".format(file))
                if file in self._ghost_files:
                    self._ghost_files.remove(file)
                yield from wait_run_in_executor(os.remove, file)
            except OSError as e:
                log.warn("Could not delete file {}: {}".format(file, e))
                continue

        # Release the dynamips ids if we want to reload the same project
        # later
        if project.id in self._dynamips_ids:
            del self._dynamips_ids[project.id]
Beispiel #7
0
def test_exception_wait_run_in_executor(loop):

    def raise_exception():
        raise Exception("test")

    exec = wait_run_in_executor(raise_exception)
    with pytest.raises(Exception):
        result = loop.run_until_complete(asyncio.async(exec))
Beispiel #8
0
def test_wait_run_in_executor(loop):

    def change_var(param):
        return param

    exec = wait_run_in_executor(change_var, "test")
    result = loop.run_until_complete(asyncio.async(exec))
    assert result == "test"