2019-09-21 22:45:46 +00:00
|
|
|
"""
|
|
|
|
Onionr - Private P2P Communication
|
|
|
|
|
|
|
|
Installs default plugins
|
|
|
|
"""
|
|
|
|
"""
|
2022-03-18 00:56:31 +00:00
|
|
|
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.
|
2019-09-21 22:45:46 +00:00
|
|
|
|
2022-03-18 00:56:31 +00:00
|
|
|
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.
|
2019-09-21 22:45:46 +00:00
|
|
|
|
2022-03-18 00:56:31 +00:00
|
|
|
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-09-21 22:45:46 +00:00
|
|
|
"""
|
2019-07-30 05:19:22 +00:00
|
|
|
import os, shutil
|
2019-09-21 22:45:46 +00:00
|
|
|
|
|
|
|
import onionrplugins as plugins
|
|
|
|
import logger
|
2019-09-23 22:56:05 +00:00
|
|
|
import filepaths
|
2020-02-08 09:07:07 +00:00
|
|
|
from utils.readstatic import get_static_dir
|
2019-09-21 22:45:46 +00:00
|
|
|
|
2019-07-30 05:19:22 +00:00
|
|
|
def setup_default_plugins():
|
|
|
|
# Copy default plugins into plugins folder
|
2022-05-01 21:06:32 +00:00
|
|
|
if os.path.exists(get_static_dir() + '/default-plugins/'):
|
|
|
|
names = [f for f in os.listdir(get_static_dir() + '/default-plugins/')]
|
|
|
|
shutil.copytree(
|
|
|
|
get_static_dir() + '/default-plugins/',
|
|
|
|
plugins.get_plugins_folder(), dirs_exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Enable plugins
|
|
|
|
for name in names:
|
|
|
|
if not name in plugins.get_enabled_plugins():
|
|
|
|
plugins.enable(name)
|
|
|
|
else:
|
|
|
|
logger.error(
|
|
|
|
"Plugin source directory does not exist!" +
|
|
|
|
"Onionr needs plugins to be useful", terminal=True)
|
2019-07-30 05:19:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
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))
|
2020-02-08 09:07:07 +00:00
|
|
|
except FileExistsError:
|
|
|
|
pass
|
2019-07-30 05:19:22 +00:00
|
|
|
except Exception as e:
|
|
|
|
#logger.warn('Error enabling plugin: ' + str(e), terminal=True)
|
2019-09-21 22:45:46 +00:00
|
|
|
plugins.disable(name, stop_event = False)
|