mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Suppport ~/GNS3/symbols
This commit is contained in:
3 files changed
+48
-3
No files matched your search
@@ -19,6 +19,7 @@ import os
|
||||
|
||||
|
||||
from ..utils.get_resource import get_resource
|
||||
from ..config import Config
|
||||
|
||||
|
||||
class Symbols:
|
||||
@@ -42,10 +43,29 @@ class Symbols:
|
||||
'builtin': True,
|
||||
})
|
||||
self._symbols_path[symbol_id] = os.path.join(get_resource("symbols"), file)
|
||||
directory = self._symbol_path()
|
||||
if directory:
|
||||
for file in os.listdir(directory):
|
||||
if file.startswith('.'):
|
||||
continue
|
||||
symbol_id = file
|
||||
symbols.append({
|
||||
'symbol_id': symbol_id,
|
||||
'filename': file,
|
||||
'builtin': False,
|
||||
})
|
||||
self._symbols_path[symbol_id] = os.path.join(get_resource("symbols"), file)
|
||||
|
||||
|
||||
symbols.sort(key=lambda x: x["filename"])
|
||||
|
||||
#TODO: support ~/GNS3/symbols directory
|
||||
return symbols
|
||||
|
||||
def _symbol_path(self):
|
||||
directory = os.path.expanduser(Config.instance().get_section_config("Server").get("symbols_path", "~/GNS3/symbols"))
|
||||
if directory:
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
return directory
|
||||
|
||||
def get_path(self, symbol_id):
|
||||
return self._symbols_path[symbol_id]
|
||||
Reference in new issue
Block a user