mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Some more (spring) cleaning.
This commit is contained in:
1 parent
f81d35cc29
commit
6cea6c9162
10 files changed
+67
-72
No files matched your search
@@ -15,16 +15,15 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
||||
from ..notification_queue import NotificationQueue
|
||||
|
||||
|
||||
class NotificationManager:
|
||||
"""
|
||||
Manage the notification queue where the controller
|
||||
will connect to get notifications from computes
|
||||
will connect to get notifications from compute servers
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -48,7 +47,7 @@ class NotificationManager:
|
||||
|
||||
:param action: Action name
|
||||
:param event: Event to send
|
||||
:param kwargs: Add this meta to the notif (project_id for example)
|
||||
:param kwargs: Add this meta to the notification (project_id for example)
|
||||
"""
|
||||
for listener in self._listeners:
|
||||
listener.put_nowait((action, event, kwargs))
|
||||
|
||||
@@ -24,8 +24,11 @@ import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# This ports are disallowed by Chrome and Firefox to avoid trouble with skip them
|
||||
BANNED_PORTS = set((1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, 143, 179, 389, 465, 512, 513, 514, 515, 526, 530, 531, 532, 540, 556, 563, 587, 601, 636, 993, 995, 2049, 3659, 4045, 6000, 6665, 6666, 6667, 6668, 6669))
|
||||
# This ports are disallowed by Chrome and Firefox to avoid issues, we skip them as well
|
||||
BANNED_PORTS = set((1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, 103,
|
||||
104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, 143, 179, 389, 465, 512, 513, 514, 515, 526,
|
||||
530, 531, 532, 540, 556, 563, 587, 601, 636, 993, 995, 2049, 3659, 4045, 6000, 6665, 6666, 6667,
|
||||
6668, 6669))
|
||||
|
||||
|
||||
class PortManager:
|
||||
@@ -106,7 +109,7 @@ class PortManager:
|
||||
return self._udp_host
|
||||
|
||||
@udp_host.setter
|
||||
def host(self, new_host):
|
||||
def udp_host(self, new_host):
|
||||
|
||||
self._udp_host = new_host
|
||||
|
||||
|
||||
@@ -201,8 +201,7 @@ class Project:
|
||||
|
||||
def _update_temporary_file(self):
|
||||
"""
|
||||
Update the .gns3_temporary file in order to reflect current
|
||||
project status.
|
||||
Update the .gns3_temporary file in order to reflect the current project status.
|
||||
"""
|
||||
|
||||
if not hasattr(self, "_path"):
|
||||
@@ -224,7 +223,7 @@ class Project:
|
||||
def module_working_directory(self, module_name):
|
||||
"""
|
||||
Returns a working directory for the module
|
||||
If the directory doesn't exist, the directory is created.
|
||||
The directory is created if the directory doesn't exist.
|
||||
|
||||
:param module_name: name for the module
|
||||
:returns: working directory
|
||||
@@ -335,7 +334,7 @@ class Project:
|
||||
"""
|
||||
Closes the project, and cleanup the disk if cleanup is True
|
||||
|
||||
:param cleanup: If True drop the project directory
|
||||
:param cleanup: Whether to delete the project directory
|
||||
"""
|
||||
|
||||
tasks = []
|
||||
@@ -431,7 +430,7 @@ class Project:
|
||||
@asyncio.coroutine
|
||||
def list_files(self):
|
||||
"""
|
||||
:returns: Array of files in project without temporary files. The files are dictionnary {"path": "test.bin", "md5sum": "aaaaa"}
|
||||
:returns: Array of files in project without temporary files. The files are dictionary {"path": "test.bin", "md5sum": "aaaaa"}
|
||||
"""
|
||||
|
||||
files = []
|
||||
@@ -479,8 +478,7 @@ class Project:
|
||||
"""
|
||||
|
||||
z = zipstream.ZipFile()
|
||||
# topdown allo to modify the list of directory in order to ignore
|
||||
# directory
|
||||
# topdown allows to modify the list of directory in order to ignore the directory
|
||||
for root, dirs, files in os.walk(self._path, topdown=True):
|
||||
# Remove snapshots and capture
|
||||
if os.path.split(root)[-1:][0] == "project-files":
|
||||
@@ -638,4 +636,4 @@ class Project:
|
||||
shutil.move(path, dst)
|
||||
|
||||
# Cleanup the project
|
||||
shutil.rmtree(root)
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
@@ -26,7 +26,7 @@ class Qcow2Error(Exception):
|
||||
|
||||
class Qcow2:
|
||||
"""
|
||||
Allow to parse a Qcow2 file
|
||||
Allows to parse a Qcow2 file
|
||||
"""
|
||||
|
||||
def __init__(self, path):
|
||||
|
||||
Reference in new issue
Block a user