Well, it works. In Python, at least.
This commit is contained in:
parent
66f4752409
commit
0b7ac9e0a4
2 changed files with 13 additions and 26 deletions
|
|
@ -28,7 +28,6 @@ from PyQt6.QtWidgets import (
|
|||
)
|
||||
from PyQt6.QtCore import Qt, QThread, pyqtSignal
|
||||
from PyQt6.QtGui import QFont
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
class WebDAVBrowser(QDialog):
|
||||
|
|
@ -95,29 +94,15 @@ class WebDAVBrowser(QDialog):
|
|||
self.current_path = path
|
||||
self.path_label.setText(path)
|
||||
|
||||
response = self.nc.list_folders(path=path) # type: ignore
|
||||
pprint(response.json_data)
|
||||
response = self.nc.get_folder(path=path) # type: ignore
|
||||
|
||||
# Try to extract data from webDavResponse
|
||||
file_list = []
|
||||
if hasattr(response, "__iter__") and not isinstance(response, (str, bytes)):
|
||||
try:
|
||||
file_list = list(response)
|
||||
except TypeError:
|
||||
# If direct iteration fails, try accessing as dict keys
|
||||
if isinstance(response, dict):
|
||||
file_list = list(response.keys())
|
||||
elif hasattr(response, "data"):
|
||||
file_list = (
|
||||
response.data
|
||||
if isinstance(response.data, list)
|
||||
else list(response.data)
|
||||
)
|
||||
file_list = response.list()
|
||||
|
||||
for item in sorted(file_list):
|
||||
name = str(item).rstrip("/")
|
||||
for item in sorted(file_list, key=lambda x: x.basename()):
|
||||
name = str(item.basename()).rstrip("/")
|
||||
if name:
|
||||
is_dir = str(item).endswith("/")
|
||||
is_dir = item.isdir()
|
||||
display_name = f"[DIR] {name}" if is_dir else name
|
||||
list_item = QListWidgetItem(display_name)
|
||||
list_item.setData(Qt.ItemDataRole.UserRole, (name, is_dir))
|
||||
|
|
@ -174,8 +159,9 @@ class RestoreWorker(QThread):
|
|||
cwd=os.path.dirname(os.path.abspath(__file__)),
|
||||
)
|
||||
|
||||
for line in process.stdout:
|
||||
self.output_signal.emit(line.rstrip())
|
||||
if process.stdout:
|
||||
for line in process.stdout:
|
||||
self.output_signal.emit(line.rstrip())
|
||||
|
||||
process.wait()
|
||||
|
||||
|
|
@ -423,9 +409,10 @@ class RestoreUI(QMainWindow):
|
|||
|
||||
def append_output(self, text):
|
||||
self.output_text.append(text)
|
||||
self.output_text.verticalScrollBar().setValue(
|
||||
self.output_text.verticalScrollBar().maximum()
|
||||
)
|
||||
if self.output_text.verticalScrollBar():
|
||||
self.output_text.verticalScrollBar().setValue( # type: ignore
|
||||
self.output_text.verticalScrollBar().maximum() # type: ignore
|
||||
)
|
||||
|
||||
def restore_finished(self, success, message):
|
||||
self.progress_bar.setVisible(False)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['restore_ui.py'],
|
||||
['restore_ui.py', 'restore_backup.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[('.env', '.')], # Include .env file
|
||||
|
|
|
|||
Loading…
Reference in a new issue