Upgrade yt_dlp and download script
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Python imports
|
||||
import builtins
|
||||
import traceback
|
||||
import threading
|
||||
import sys
|
||||
|
||||
@@ -29,6 +30,18 @@ def daemon_threaded_wrapper(fn):
|
||||
return thread
|
||||
return wrapper
|
||||
|
||||
def call_chain_wrapper(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
print()
|
||||
print()
|
||||
for line in traceback.format_stack():
|
||||
print( line.strip() )
|
||||
print()
|
||||
print()
|
||||
|
||||
return fn(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
def sizeof_fmt_def(num, suffix="B"):
|
||||
for unit in ["", "K", "M", "G", "T", "Pi", "Ei", "Zi"]:
|
||||
if abs(num) < 1024.0:
|
||||
@@ -54,6 +67,7 @@ builtins.logger = Logger(settings_manager.get_home_config_path(), \
|
||||
|
||||
builtins.threaded = threaded_wrapper
|
||||
builtins.daemon_threaded = daemon_threaded_wrapper
|
||||
builtins.call_chain = call_chain_wrapper
|
||||
builtins.sizeof_fmt = sizeof_fmt_def
|
||||
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Python imports
|
||||
import resource
|
||||
import argparse
|
||||
import faulthandler
|
||||
import traceback
|
||||
@@ -17,8 +18,14 @@ from app import Application
|
||||
|
||||
|
||||
|
||||
def limit_memory(maxsize):
|
||||
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
|
||||
resource.setrlimit(resource.RLIMIT_AS, (maxsize, hard))
|
||||
|
||||
|
||||
def main(args, unknownargs):
|
||||
setproctitle(f'{app_name}')
|
||||
# limit_memory(248 * (1024 * 1024 * 42))
|
||||
|
||||
if args.debug == "true":
|
||||
settings_manager.set_debug(True)
|
||||
@@ -51,4 +58,4 @@ if __name__ == "__main__":
|
||||
main(args, unknownargs)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
quit()
|
||||
quit()
|
@@ -116,21 +116,20 @@ class HandlerMixin:
|
||||
io_list.show_all()
|
||||
|
||||
if action == "copy":
|
||||
file.copy_async(destination=target,
|
||||
flags=Gio.FileCopyFlags.BACKUP,
|
||||
io_priority=45,
|
||||
cancellable=io_widget.cancle_eve,
|
||||
progress_callback=io_widget.update_progress,
|
||||
callback=io_widget.finish_callback)
|
||||
file.copy_async(target,
|
||||
Gio.FileCopyFlags.BACKUP,
|
||||
45,
|
||||
io_widget.cancle_eve,
|
||||
io_widget.update_progress,
|
||||
io_widget.finish_callback)
|
||||
|
||||
if action == "move" or action == "rename":
|
||||
file.move_async(destination=target,
|
||||
flags=Gio.FileCopyFlags.BACKUP,
|
||||
io_priority=45,
|
||||
cancellable=io_widget.cancle_eve,
|
||||
# NOTE: progress_callback here causes seg fault when set
|
||||
progress_callback=None,
|
||||
callback=io_widget.finish_callback)
|
||||
file.move_async(target,
|
||||
Gio.FileCopyFlags.BACKUP,
|
||||
45,
|
||||
io_widget.cancle_eve,
|
||||
None,
|
||||
io_widget.finish_callback)
|
||||
|
||||
io_widget = None
|
||||
io_list = None
|
||||
|
@@ -20,17 +20,6 @@ class GridMixin:
|
||||
"""docstring for GridMixin"""
|
||||
|
||||
def load_store(self, tab, store, save_state = False, use_generator = False):
|
||||
# dir = tab.get_current_directory()
|
||||
# file = Gio.File.new_for_path(dir)
|
||||
# dir_list = Gtk.DirectoryList.new("standard::*", file)
|
||||
# store.set(dir_list)
|
||||
|
||||
# file = Gio.File.new_for_path(dir)
|
||||
# for file in file.enumerate_children("standard::*", Gio.FILE_ATTRIBUTE_STANDARD_NAME, None):
|
||||
# store.append(file)
|
||||
|
||||
# return
|
||||
|
||||
dir = tab.get_current_directory()
|
||||
files = tab.get_files()
|
||||
|
||||
@@ -39,7 +28,6 @@ class GridMixin:
|
||||
|
||||
Gtk.main_iteration()
|
||||
self.generate_icons(tab, store, dir, files)
|
||||
# GLib.Thread("", self.generate_icons, tab, store, dir, files)
|
||||
|
||||
# NOTE: Not likely called often from here but it could be useful
|
||||
if save_state and not trace_debug:
|
||||
@@ -48,10 +36,8 @@ class GridMixin:
|
||||
dir = None
|
||||
files = None
|
||||
|
||||
@daemon_threaded
|
||||
def generate_icons(self, tab, store, dir, files):
|
||||
for i, file in enumerate(files):
|
||||
# GLib.Thread(f"{i}", self.make_and_load_icon, i, store, tab, dir, file[0])
|
||||
self.make_and_load_icon( i, store, tab, dir, file[0])
|
||||
|
||||
def update_store(self, i, store, icon):
|
||||
@@ -63,40 +49,12 @@ class GridMixin:
|
||||
@daemon_threaded
|
||||
def make_and_load_icon(self, i, store, tab, dir, file):
|
||||
icon = tab.create_icon(dir, file)
|
||||
self.update_store(i, store, icon)
|
||||
GLib.idle_add(self.update_store, i, store, icon)
|
||||
icon = None
|
||||
|
||||
def get_icon(self, tab, dir, file):
|
||||
tab.create_icon(dir, file)
|
||||
|
||||
|
||||
# @daemon_threaded
|
||||
# def generate_icons(self, tab, store, dir, files):
|
||||
# try:
|
||||
# loop = asyncio.get_running_loop()
|
||||
# except RuntimeError:
|
||||
# loop = None
|
||||
|
||||
# if loop and loop.is_running():
|
||||
# loop = asyncio.get_event_loop()
|
||||
# loop.create_task( self.create_icons(tab, store, dir, files) )
|
||||
# else:
|
||||
# asyncio.run( self.create_icons(tab, store, dir, files) )
|
||||
|
||||
# async def create_icons(self, tab, store, dir, files):
|
||||
# icons = [self.get_icon(tab, dir, file[0]) for file in files]
|
||||
# data = await asyncio.gather(*icons)
|
||||
# tasks = [self.update_store(i, store, icon) for i, icon in enumerate(data)]
|
||||
# asyncio.gather(*tasks)
|
||||
|
||||
# async def update_store(self, i, store, icon):
|
||||
# itr = store.get_iter(i)
|
||||
# GLib.idle_add(self.insert_store, store, itr, icon)
|
||||
|
||||
# async def get_icon(self, tab, dir, file):
|
||||
# return tab.create_icon(dir, file)
|
||||
|
||||
|
||||
def insert_store(self, store, itr, icon):
|
||||
store.set_value(itr, 0, icon)
|
||||
|
||||
@@ -105,6 +63,7 @@ class GridMixin:
|
||||
|
||||
def do_ui_update(self):
|
||||
Gtk.main_iteration()
|
||||
# Note: If the function returns GLib.SOURCE_REMOVE or False it is automatically removed from the list of event sources and will not be called again.
|
||||
return False
|
||||
|
||||
def create_tab_widget(self):
|
||||
@@ -173,4 +132,4 @@ class GridMixin:
|
||||
icon_grid = obj.get_children()[0]
|
||||
name = icon_grid.get_name()
|
||||
if name == _name:
|
||||
return icon_grid
|
||||
return icon_grid
|
@@ -78,6 +78,7 @@ class UIMixin(PaneMixin, WindowMixin):
|
||||
elif not self.is_pane1_hidden:
|
||||
notebook = self.window1
|
||||
|
||||
# Todo: Maybe use 'realize' signal to focus widget instead...
|
||||
scroll_win = notebook.get_children()[-1]
|
||||
icon_grid = scroll_win.get_children()[0]
|
||||
GLib.Thread("", self._focus_last_visible_notebook, icon_grid)
|
||||
@@ -88,4 +89,4 @@ class UIMixin(PaneMixin, WindowMixin):
|
||||
for j in range(0, 4):
|
||||
i = j + 1
|
||||
self.fm_controller.create_window()
|
||||
self.create_new_tab_notebook(None, i, None)
|
||||
self.create_new_tab_notebook(None, i, None)
|
@@ -91,4 +91,4 @@ class IconGridWidget(Gtk.IconView):
|
||||
store = Gtk.ListStore(GdkPixbuf.Pixbuf or GdkPixbuf.PixbufAnimation or None, str or None)
|
||||
# store = Gtk.ListStore(Gtk.DirectoryList)
|
||||
self.set_model(store)
|
||||
store = None
|
||||
store = None
|
@@ -9,7 +9,6 @@ gi.require_version('Gdk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GLib
|
||||
from gi.repository import GObject
|
||||
|
||||
# Application imports
|
||||
from core.controller import Controller
|
||||
@@ -24,9 +23,9 @@ class Window(Gtk.ApplicationWindow):
|
||||
"""docstring for Window."""
|
||||
|
||||
def __init__(self, args, unknownargs):
|
||||
GObject.threads_init()
|
||||
Gtk.ApplicationWindow.__init__(self)
|
||||
# super(Window, self).__init__()
|
||||
|
||||
super(Window, self).__init__()
|
||||
settings_manager.set_main_window(self)
|
||||
|
||||
self._controller = None
|
||||
@@ -122,4 +121,4 @@ class Window(Gtk.ApplicationWindow):
|
||||
Gtk.main_quit()
|
||||
|
||||
def main(self):
|
||||
Gtk.main()
|
||||
Gtk.main()
|
Reference in New Issue
Block a user