mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 06:21:15 +02:00
Use PATH environnement variable for searching binary
This commit is contained in:
1 parent
bf6f62e629
commit
8e307c8cbb
3 files changed
+35
-62
No files matched your search
@@ -28,6 +28,7 @@ import shutil
|
||||
import re
|
||||
import asyncio
|
||||
import socket
|
||||
import shutil
|
||||
|
||||
from pkg_resources import parse_version
|
||||
from .vpcs_error import VPCSError
|
||||
@@ -52,17 +53,17 @@ class VPCSDevice(BaseVM):
|
||||
:param console: TCP console port
|
||||
"""
|
||||
def __init__(self, name, vpcs_id, port_manager,
|
||||
path = None,
|
||||
working_dir = None,
|
||||
console=None):
|
||||
working_dir = None, console = None):
|
||||
super().__init__(name, vpcs_id, port_manager)
|
||||
|
||||
#self._path = path
|
||||
#self._working_dir = working_dir
|
||||
# TODO: Hardcodded for testing
|
||||
self._path = "/usr/local/bin/vpcs"
|
||||
self._working_dir = "/tmp"
|
||||
self._path = self._config.get_section_config("VPCS").get("path", "vpcs")
|
||||
|
||||
self._working_dir = "/tmp"
|
||||
self._console = console
|
||||
|
||||
self._command = []
|
||||
self._process = None
|
||||
self._vpcs_stdout_file = ""
|
||||
@@ -89,12 +90,15 @@ class VPCSDevice(BaseVM):
|
||||
raise VPCSError(e)
|
||||
|
||||
self._check_requirements()
|
||||
super().__init__(name, vpcs_id, port_manager)
|
||||
|
||||
def _check_requirements(self):
|
||||
"""
|
||||
Check if VPCS is available with the correct version
|
||||
"""
|
||||
if self._path == "vpcs":
|
||||
self._path = shutil.which("vpcs")
|
||||
|
||||
|
||||
if not self._path:
|
||||
raise VPCSError("No path to a VPCS executable has been set")
|
||||
|
||||
@@ -106,6 +110,16 @@ class VPCSDevice(BaseVM):
|
||||
|
||||
self._check_vpcs_version()
|
||||
|
||||
@property
|
||||
def console(self):
|
||||
"""
|
||||
Returns the console port of this VPCS device.
|
||||
|
||||
:returns: console port
|
||||
"""
|
||||
|
||||
return self._console
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user