This commit is contained in:
shortcutme 2019-04-10 14:57:32 +02:00
commit 0c9ea8f580
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
5 changed files with 18 additions and 8 deletions

View file

@ -42,6 +42,9 @@ class ActionsPlugin(object):
ui_ip = config.ui_ip if config.ui_ip != "*" else "127.0.0.1"
if ":" in ui_ip:
ui_ip = "[" + ui_ip + "]"
icon.items = [
(self.titleIp, False),
(self.titleConnections, False),

0
plugins/__init__.py Normal file
View file

View file

@ -7,13 +7,16 @@ from collections import defaultdict
from Debug import Debug
from Config import config
import plugins
import importlib
class PluginManager:
def __init__(self):
self.log = logging.getLogger("PluginManager")
self.plugin_path = "plugins" # Plugin directory
self.plugin_path = os.path.abspath(os.path.dirname(plugins.__file__))
self.plugins = defaultdict(list) # Registered plugins (key: class name, value: list of plugins for class)
self.subclass_order = {} # Record the load order of the plugins, to keep it after reload
self.pluggable = {}
@ -40,6 +43,8 @@ class PluginManager:
s = time.time()
for dir_name in sorted(os.listdir(self.plugin_path)):
dir_path = os.path.join(self.plugin_path, dir_name)
if dir_name == "__pycache__":
continue # skip
if dir_name.startswith("disabled"):
continue # Dont load if disabled
if not os.path.isdir(dir_path):

View file

@ -4,16 +4,17 @@ import os
import pytest
from Site import SiteManager
TEST_DATA_PATH = "src/Test/testdata"
@pytest.mark.usefixtures("resetSettings")
class TestSite:
def testClone(self, site):
assert site.storage.directory == "src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"
assert site.storage.directory == TEST_DATA_PATH + "/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"
# Remove old files
if os.path.isdir("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL"):
shutil.rmtree("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
assert not os.path.isfile("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL/content.json")
if os.path.isdir(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL"):
shutil.rmtree(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
assert not os.path.isfile(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL/content.json")
# Clone 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT to 15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc
new_site = site.clone(
@ -61,7 +62,7 @@ class TestSite:
# Delete created files
new_site.storage.deleteFiles()
assert not os.path.isdir("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
assert not os.path.isdir(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
# Delete from site registry
assert new_site.address in SiteManager.site_manager.sites

View file

@ -72,7 +72,8 @@ fmt = logging.Formatter(fmt='+%(relative)ss %(levelname)-8s %(name)s %(message)s
# Load plugins
from Plugin import PluginManager
config.data_dir = "src/Test/testdata" # Use test data for unittests
TEST_DATA_PATH = 'src/Test/testdata'
config.data_dir = TEST_DATA_PATH # Use test data for unittests
os.chdir(os.path.abspath(os.path.dirname(__file__) + "/../..")) # Set working dir
@ -85,7 +86,7 @@ config.debug_socket = True # Use test data for unittests
config.verbose = True # Use test data for unittests
config.tor = "disable" # Don't start Tor client
config.trackers = []
config.data_dir = "src/Test/testdata" # Use test data for unittests
config.data_dir = TEST_DATA_PATH # Use test data for unittests
config.initLogging()
from Site import Site