onionr/onionr/onionrsetup/defaultpluginsetup.py

45 lines
1.7 KiB
Python
Raw Normal View History

"""
Onionr - Private P2P Communication
Installs default plugins
"""
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
2019-07-30 05:19:22 +00:00
import os, shutil
import onionrplugins as plugins
import logger
2019-09-23 22:56:05 +00:00
import filepaths
2019-07-30 05:19:22 +00:00
def setup_default_plugins():
# Copy default plugins into plugins folder
if not os.path.exists(plugins.get_plugins_folder()):
2019-09-23 22:56:05 +00:00
if os.path.exists('../static-data/default-plugins/'):
names = [f for f in os.listdir("../static-data/default-plugins/")]
shutil.copytree('../static-data/default-plugins/', plugins.get_plugins_folder())
2019-07-30 05:19:22 +00:00
# Enable plugins
for name in names:
if not name in plugins.get_enabled_plugins():
plugins.enable(name)
for name in plugins.get_enabled_plugins():
if not os.path.exists(plugins.get_plugin_data_folder(name)):
try:
os.mkdir(plugins.get_plugin_data_folder(name))
except Exception as e:
#logger.warn('Error enabling plugin: ' + str(e), terminal=True)
plugins.disable(name, stop_event = False)