Improve first-run and add default plugins
This commit is contained in:
parent
098abb8e55
commit
bd0a175dfc
35
onionr/default-plugins/pluginmanager/main.py
Normal file
35
onionr/default-plugins/pluginmanager/main.py
Normal file
@ -0,0 +1,35 @@
|
||||
'''
|
||||
This is the future Onionr plugin manager. TODO: Add better description.
|
||||
'''
|
||||
|
||||
# useful libraries
|
||||
import logger, config
|
||||
|
||||
# useful functions
|
||||
|
||||
def installPlugin():
|
||||
logger.info('This feature has not been created yet. Please check back later.')
|
||||
return
|
||||
|
||||
def uninstallPlugin():
|
||||
logger.info('This feature has not been created yet. Please check back later.')
|
||||
return
|
||||
|
||||
def searchPlugin():
|
||||
logger.info('This feature has not been created yet. Please check back later.')
|
||||
return
|
||||
|
||||
# event listeners
|
||||
|
||||
def on_init(api, data = None):
|
||||
global pluginapi
|
||||
pluginapi = api
|
||||
|
||||
# register some commands
|
||||
api.commands.register(['install-plugin', 'installplugin', 'plugin-install', 'install', 'plugininstall'], installPlugin)
|
||||
api.commands.register(['remove-plugin', 'removeplugin', 'plugin-remove', 'uninstall-plugin', 'uninstallplugin', 'plugin-uninstall', 'uninstall', 'remove', 'pluginremove'], uninstallPlugin)
|
||||
api.commands.register(['search', 'filter-plugins', 'search-plugins', 'searchplugins', 'search-plugin', 'searchplugin', 'findplugin', 'find-plugin', 'filterplugin', 'plugin-search', 'pluginsearch'], searchPlugin)
|
||||
|
||||
# add help menus once the features are actually implemented
|
||||
|
||||
return
|
@ -14,8 +14,10 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
|
||||
from tkinter import *
|
||||
import os, sqlite3, core
|
||||
|
||||
class OnionrGUI:
|
||||
def __init__(self, myCore):
|
||||
self.root = Tk()
|
||||
|
@ -20,6 +20,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
|
||||
import sys, os, base64, random, getpass, shutil, subprocess, requests, time, platform, datetime, re
|
||||
import api, core, config, logger, onionrplugins as plugins, onionrevents as events
|
||||
from onionrutils import OnionrUtils
|
||||
@ -54,8 +55,15 @@ class Onionr:
|
||||
|
||||
# Load global configuration data
|
||||
|
||||
data_exists = os.path.exists('data/')
|
||||
|
||||
if not data_exists:
|
||||
os.mkdir('data/')
|
||||
|
||||
exists = os.path.exists(config.get_config_file())
|
||||
config.set_config({'devmode': True, 'log': {'file': {'output': True, 'path': 'data/output.log'}, 'console': {'output': True, 'color': True}}}) # this is the default config, it will be overwritten if a config file already exists. Else, it saves it
|
||||
if not exists:
|
||||
config.save()
|
||||
config.reload() # this will read the configuration file into memory
|
||||
|
||||
settings = 0b000
|
||||
@ -92,9 +100,19 @@ class Onionr:
|
||||
else:
|
||||
logger.error('Failed to decrypt: ' + result[1], timestamp = False)
|
||||
else:
|
||||
if not os.path.exists('data/'):
|
||||
os.mkdir('data/')
|
||||
os.mkdir('data/blocks/')
|
||||
# If data folder does not exist
|
||||
if not data_exists:
|
||||
if not os.path.exists('data/blocks/'):
|
||||
os.mkdir('data/blocks/')
|
||||
|
||||
# Copy default plugins into plugins folder
|
||||
if os.path.exists('default-plugins/'):
|
||||
names = [f for f in os.listdir("default-plugins/") if not os.path.isfile(f)]
|
||||
shutil.copytree('default-plugins/', 'data/plugins/')
|
||||
|
||||
# Enable plugins
|
||||
for name in names:
|
||||
plugins.enable(name, self)
|
||||
|
||||
if not os.path.exists(self.onionrCore.peerDB):
|
||||
self.onionrCore.createPeerDB()
|
||||
|
@ -66,11 +66,14 @@ class PluginAPI:
|
||||
def disable(self, name):
|
||||
plugins.disable(name)
|
||||
|
||||
def event(self, name, data = {}):
|
||||
events.event(name, data = data, onionr = self.pluginapi.get_onionr())
|
||||
|
||||
def is_enabled(self, name):
|
||||
return plugins.is_enabled(name)
|
||||
|
||||
def get_enabled_plugins(self):
|
||||
return plugins.get_enabled_plugins()
|
||||
return plugins.get_enabled()
|
||||
|
||||
class CommandAPI:
|
||||
def __init__(self, pluginapi):
|
||||
|
Loading…
Reference in New Issue
Block a user