Merge branch 'py3' of https://github.com/HelloZeroNet/ZeroNet into py3
This commit is contained in:
commit
0c9ea8f580
5 changed files with 18 additions and 8 deletions
|
@ -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
0
plugins/__init__.py
Normal 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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue