From 1248584841e77dee07b4b7d9191f93d6654ebc36 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 9 Nov 2015 12:14:25 +0100 Subject: [PATCH] Cleanup unused and duplicates --- gns3server/handlers/api/project_handler.py | 5 ++--- gns3server/handlers/api/virtualbox_handler.py | 3 +-- gns3server/handlers/api/vmware_handler.py | 2 +- gns3server/modules/dynamips/__init__.py | 8 -------- gns3server/modules/nios/nio.py | 2 -- gns3server/modules/project.py | 4 ---- gns3server/modules/qemu/qemu_vm.py | 1 - gns3server/run.py | 2 +- gns3server/ubridge/hypervisor.py | 2 -- tests/handlers/api/test_qemu.py | 10 ---------- tests/test_config.py | 19 ------------------- tox.ini | 4 ++++ 12 files changed, 9 insertions(+), 53 deletions(-) diff --git a/gns3server/handlers/api/project_handler.py b/gns3server/handlers/api/project_handler.py index 00346f05..f4460511 100644 --- a/gns3server/handlers/api/project_handler.py +++ b/gns3server/handlers/api/project_handler.py @@ -24,7 +24,6 @@ from ...web.route import Route from ...schemas.project import PROJECT_OBJECT_SCHEMA, PROJECT_CREATE_SCHEMA, PROJECT_UPDATE_SCHEMA, PROJECT_FILE_LIST_SCHEMA, PROJECT_LIST_SCHEMA from ...modules.project_manager import ProjectManager from ...modules import MODULES -from ...utils.asyncio import wait_run_in_executor import logging log = logging.getLogger() @@ -41,8 +40,8 @@ class ProjectHandler: description="List projects opened on the server", status_codes={ 200: "Project list", - } - # output=PROJECT_LIST_SCHEMA) + }, + output=PROJECT_LIST_SCHEMA ) def list_projects(request, response): diff --git a/gns3server/handlers/api/virtualbox_handler.py b/gns3server/handlers/api/virtualbox_handler.py index c5c4e244..f93d4db3 100644 --- a/gns3server/handlers/api/virtualbox_handler.py +++ b/gns3server/handlers/api/virtualbox_handler.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import os -import sys from aiohttp.web import HTTPConflict from ...web.route import Route @@ -42,7 +41,7 @@ class VirtualBoxHandler: 200: "Success", }, description="Get all VirtualBox VMs available") - def show(request, response): + def index(request, response): vbox_manager = VirtualBox.instance() vms = yield from vbox_manager.list_images() diff --git a/gns3server/handlers/api/vmware_handler.py b/gns3server/handlers/api/vmware_handler.py index b9f6f0b4..8512d53d 100644 --- a/gns3server/handlers/api/vmware_handler.py +++ b/gns3server/handlers/api/vmware_handler.py @@ -41,7 +41,7 @@ class VMwareHandler: 200: "Success", }, description="Get all VMware VMs available") - def show(request, response): + def index(request, response): vmware_manager = VMware.instance() vms = yield from vmware_manager.list_vms() diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 5f27090c..7de7a755 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -479,14 +479,6 @@ class Dynamips(BaseManager): yield from nio.create() return nio - @asyncio.coroutine - def ghost_ios_support(self, vm): - - ghost_ios_support = self.config.get_section_config("Dynamips").getboolean("ghost_ios_support", True) - if ghost_ios_support: - with (yield from Dynamips._ghost_ios_lock): - yield from self._set_ghost_ios(vm) - @asyncio.coroutine def _set_ghost_ios(self, vm): """ diff --git a/gns3server/modules/nios/nio.py b/gns3server/modules/nios/nio.py index b77fbf64..b1ab24ae 100644 --- a/gns3server/modules/nios/nio.py +++ b/gns3server/modules/nios/nio.py @@ -19,8 +19,6 @@ Base interface for NIOs. """ -import uuid - class NIO(object): diff --git a/gns3server/modules/project.py b/gns3server/modules/project.py index a689b658..4e758406 100644 --- a/gns3server/modules/project.py +++ b/gns3server/modules/project.py @@ -143,10 +143,6 @@ class Project: if path != self._path and self.is_local() is False: raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory location") - old_path = None - if hasattr(self, "_path"): - old_path = self._path - self._path = path self._update_temporary_file() diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index dff946d5..a2bcca0b 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -1454,7 +1454,6 @@ class QemuVM(BaseVM): if self._run_with_kvm(self.qemu_path, self._options): command.extend(["-enable-kvm"]) command.extend(["-boot", "order={}".format(self._boot_priority)]) - disk_options = yield from self._disk_options() cdrom_option = self._cdrom_option() command.extend(cdrom_option) command.extend((yield from self._disk_options())) diff --git a/gns3server/run.py b/gns3server/run.py index f9706e17..cd4c0939 100644 --- a/gns3server/run.py +++ b/gns3server/run.py @@ -162,7 +162,7 @@ def pid_lock(path): except OSError: pid = None except OSError as e: - log.critical("Can't open pid file %s: %s", args.pid, str(e)) + log.critical("Can't open pid file %s: %s", pid, str(e)) sys.exit(1) if pid: diff --git a/gns3server/ubridge/hypervisor.py b/gns3server/ubridge/hypervisor.py index a550fe85..39bca997 100644 --- a/gns3server/ubridge/hypervisor.py +++ b/gns3server/ubridge/hypervisor.py @@ -27,7 +27,6 @@ import re from pkg_resources import parse_version from gns3server.utils.asyncio import wait_for_process_termination -from gns3server.utils.asyncio import monitor_process from gns3server.utils.asyncio import subprocess_check_output from .ubridge_hypervisor import UBridgeHypervisor from .ubridge_error import UbridgeError @@ -152,7 +151,6 @@ class Hypervisor(UBridgeHypervisor): stderr=subprocess.STDOUT, cwd=self._working_dir) - #monitor_process(self._process, self._termination_callback) log.info("ubridge started PID={}".format(self._process.pid)) except (OSError, subprocess.SubprocessError) as e: ubridge_stdout = self.read_stdout() diff --git a/tests/handlers/api/test_qemu.py b/tests/handlers/api/test_qemu.py index 46614d9b..01d6c1bc 100644 --- a/tests/handlers/api/test_qemu.py +++ b/tests/handlers/api/test_qemu.py @@ -49,16 +49,6 @@ def base_params(tmpdir, fake_qemu_bin): return {"name": "PC TEST 1", "qemu_path": fake_qemu_bin} -@pytest.fixture -def fake_qemu_bin(): - - bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64") - with open(bin_path, "w+") as f: - f.write("1") - os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) - return bin_path - - @pytest.fixture def vm(server, project, base_params): response = server.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params) diff --git a/tests/test_config.py b/tests/test_config.py index a1a0c33e..cd8e8c23 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -90,25 +90,6 @@ def test_set(tmpdir): assert dict(config.get_section_config("Server")) == {"host": "192.168.1.1"} -def test_reload(tmpdir): - - config = load_config(tmpdir, { - "Server": { - "host": "127.0.0.1" - } - }) - assert dict(config.get_section_config("Server")) == {"host": "127.0.0.1"} - - path = write_config(tmpdir, { - "Server": { - "host": "192.168.1.1" - } - }) - - config.reload() - assert dict(config.get_section_config("Server")) == {"host": "192.168.1.1"} - - def test_reload(tmpdir): config = load_config(tmpdir, { diff --git a/tox.ini b/tox.ini index e5480bfc..7eb55857 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,10 @@ deps = -rdev-requirements.txt [pep8] ignore = E501,E402 +[flake8] +ignore = E265,E501 +exclude = tests/* + [pytest] norecursedirs = .tox timeout = 5