mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2026-08-15 13:03:08 +00:00
Update plugin_manager.py
This commit is contained in:
parent
c90face51e
commit
5c86064223
1 changed files with 15 additions and 34 deletions
|
|
@ -43,26 +43,7 @@ HEADERS = {
|
|||
"User-Agent": _env["legacy_user_agent_string"],
|
||||
}
|
||||
PLUGIN_DIRECTORY = _env["python_directory_user"]
|
||||
|
||||
|
||||
def get_event_loop():
|
||||
# loop = asyncio.ProactorEventLoop() if sys.platform == 'win32' else asyncio.new_event_loop()
|
||||
return babase._asyncio._asyncio_event_loop
|
||||
# try:
|
||||
# running = asyncio.get_running_loop()
|
||||
# except RuntimeError:
|
||||
# return loop
|
||||
# if running.is_closed():
|
||||
# return loop
|
||||
# else:
|
||||
# if sys.platform in ('linux', 'darwin'):
|
||||
# return running
|
||||
# if sys.platform == 'win32':
|
||||
# if isinstance(running, asyncio.ProactorEventLoop):
|
||||
# return running
|
||||
# else:
|
||||
# return loop
|
||||
|
||||
loop = babase._asyncio._asyncio_event_loop
|
||||
|
||||
def _regexp_friendly_class_name_shortcut(string): return string.replace(".", "\\.")
|
||||
|
||||
|
|
@ -120,7 +101,7 @@ def send_network_request(request):
|
|||
|
||||
|
||||
async def async_send_network_request(request):
|
||||
loop = get_event_loop()
|
||||
|
||||
response = await loop.run_in_executor(None, send_network_request, request)
|
||||
return response
|
||||
|
||||
|
|
@ -149,7 +130,7 @@ def stream_network_response_to_file(request, file, md5sum=None, retries=3):
|
|||
|
||||
|
||||
async def async_stream_network_response_to_file(request, file, md5sum=None, retries=3):
|
||||
loop = get_event_loop()
|
||||
|
||||
content = await loop.run_in_executor(
|
||||
None,
|
||||
stream_network_response_to_file,
|
||||
|
|
@ -557,7 +538,7 @@ class PluginLocal:
|
|||
if self._content is None:
|
||||
if not self.is_installed:
|
||||
raise PluginNotInstalled("Plugin is not available locally.")
|
||||
loop = get_event_loop()
|
||||
|
||||
self._content = await loop.run_in_executor(None, self._get_content)
|
||||
return self._content
|
||||
|
||||
|
|
@ -689,7 +670,7 @@ class PluginLocal:
|
|||
|
||||
async def set_content(self, content):
|
||||
if not self._content:
|
||||
loop = get_event_loop()
|
||||
|
||||
await loop.run_in_executor(None, self._set_content, content)
|
||||
self._content = content
|
||||
return self
|
||||
|
|
@ -875,7 +856,7 @@ class PluginWindow(popup.PopupWindow):
|
|||
self.plugin = plugin
|
||||
self.button_callback = button_callback
|
||||
self.scale_origin = origin_widget.get_screen_space_center()
|
||||
loop = get_event_loop()
|
||||
|
||||
loop.create_task(self.draw_ui())
|
||||
|
||||
def get_description(self, minimum_character_offset=40):
|
||||
|
|
@ -1127,7 +1108,7 @@ class PluginWindow(popup.PopupWindow):
|
|||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
self._ok()
|
||||
loop = get_event_loop()
|
||||
|
||||
if asyncio.iscoroutinefunction(fn):
|
||||
loop.create_task(asyncio_handler(fn, self, *args, **kwargs))
|
||||
else:
|
||||
|
|
@ -1389,7 +1370,7 @@ class PluginSourcesWindow(popup.PopupWindow):
|
|||
# autoselect=True,
|
||||
description="Add Source")
|
||||
|
||||
loop = get_event_loop()
|
||||
|
||||
|
||||
bui.buttonwidget(parent=self._root_widget,
|
||||
position=(330, 28),
|
||||
|
|
@ -1495,7 +1476,7 @@ class PluginCategoryWindow(popup.PopupMenuWindow):
|
|||
on_activate_call=self.show_sources_window)
|
||||
|
||||
def popup_menu_selected_choice(self, window, choice):
|
||||
loop = get_event_loop()
|
||||
|
||||
loop.create_task(self._asyncio_callback(choice))
|
||||
|
||||
def popup_menu_closing(self, window):
|
||||
|
|
@ -1517,7 +1498,7 @@ class PluginManagerWindow(bui.Window):
|
|||
self.selected_category = None
|
||||
self.plugins_in_current_view = {}
|
||||
|
||||
loop = get_event_loop()
|
||||
|
||||
loop.create_task(self.draw_index())
|
||||
|
||||
self._width = (700 if _uiscale is babase.UIScale.SMALL
|
||||
|
|
@ -1712,7 +1693,7 @@ class PluginManagerWindow(bui.Window):
|
|||
description=filter_txt)
|
||||
self._last_filter_text = None
|
||||
self._last_filter_plugins = []
|
||||
loop = get_event_loop()
|
||||
|
||||
loop.create_task(self.process_search_term())
|
||||
|
||||
async def process_search_term(self):
|
||||
|
|
@ -1771,7 +1752,7 @@ class PluginManagerWindow(bui.Window):
|
|||
500 if _uiscale is babase.UIScale.MEDIUM else 510)
|
||||
refresh_pos_y = (180 if _uiscale is babase.UIScale.SMALL else
|
||||
108 if _uiscale is babase.UIScale.MEDIUM else 120)
|
||||
loop = get_event_loop()
|
||||
|
||||
controller_button = bui.buttonwidget(parent=self._root_widget,
|
||||
# autoselect=True,
|
||||
position=(refresh_pos_x, refresh_pos_y),
|
||||
|
|
@ -1928,7 +1909,7 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
|
|||
self._plugin_manager = plugin_manager
|
||||
self.scale_origin = origin_widget.get_screen_space_center()
|
||||
self.settings = babase.app.config["Community Plugin Manager"]["Settings"].copy()
|
||||
loop = get_event_loop()
|
||||
|
||||
loop.create_task(self.draw_ui())
|
||||
|
||||
async def draw_ui(self):
|
||||
|
|
@ -2048,7 +2029,7 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
|
|||
plugin_manager_update_available = False
|
||||
if plugin_manager_update_available:
|
||||
text_color = (0.75, 0.2, 0.2)
|
||||
loop = get_event_loop()
|
||||
|
||||
button_size = (95 * s, 32 * s)
|
||||
update_button_label = f'Update to v{plugin_manager_update_available[0]}'
|
||||
self._update_button = bui.buttonwidget(parent=self._root_widget,
|
||||
|
|
@ -2503,5 +2484,5 @@ class EntryPoint(babase.Plugin):
|
|||
DNSBlockWorkaround.apply()
|
||||
asyncio.set_event_loop(babase._asyncio._asyncio_event_loop)
|
||||
startup_tasks = StartupTasks()
|
||||
loop = get_event_loop()
|
||||
|
||||
loop.create_task(startup_tasks.execute())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue