mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
Add debug feature
This commit is contained in:
@@ -4,6 +4,8 @@ from core.utils.data.state import state
|
|||||||
|
|
||||||
def scrape_rutracker(search_text):
|
def scrape_rutracker(search_text):
|
||||||
search = requests.get(f"{state.api_url}/search/{search_text}")
|
search = requests.get(f"{state.api_url}/search/{search_text}")
|
||||||
|
if state.debug:
|
||||||
|
print("Sent request to server")
|
||||||
if search:
|
if search:
|
||||||
try:
|
try:
|
||||||
return search.text
|
return search.text
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ async def init_uztracker():
|
|||||||
up = True
|
up = True
|
||||||
else:
|
else:
|
||||||
up = False
|
up = False
|
||||||
print(f"Uztracker seems down, status code: {response.status_code}")
|
if state.debug:
|
||||||
|
print(f"Uztracker seems down, status code: {response.status_code}")
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(f"\nRequest Exception on {url_uztracker}:")
|
if state.debug:
|
||||||
print(e)
|
print(f"\nRequest Exception on {url_uztracker}:")
|
||||||
print("\nIs the Site down?")
|
print(e)
|
||||||
|
print("\nIs the Site down?")
|
||||||
up = False
|
up = False
|
||||||
|
|
||||||
asyncio.run(init_uztracker())
|
asyncio.run(init_uztracker())
|
||||||
@@ -61,12 +63,13 @@ async def scrape_uztracker(search, max_results=450):
|
|||||||
break
|
break
|
||||||
|
|
||||||
except aiohttp.ClientError as e:
|
except aiohttp.ClientError as e:
|
||||||
if result:
|
if result and state.debug:
|
||||||
print(f"Failed to fetch {search_url}: {e}")
|
print(f"Failed to fetch {search_url}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Error: Uztracker down")
|
if state.debug:
|
||||||
|
print("Error: Uztracker down")
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
@@ -85,7 +88,8 @@ def get_post_title(post_url):
|
|||||||
if state.debug:
|
if state.debug:
|
||||||
print("Program not found")
|
print("Program not found")
|
||||||
else:
|
else:
|
||||||
print("Error: Uztracker down")
|
if state.debug:
|
||||||
|
print("Error: Uztracker down")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ def settings_dialog(self):
|
|||||||
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), speed_limit.value()))
|
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), speed_limit.value()))
|
||||||
|
|
||||||
cancel_btn.clicked.connect(dialog.reject)
|
cancel_btn.clicked.connect(dialog.reject)
|
||||||
print(thread_box.value())
|
|
||||||
layout.addWidget(cancel_btn)
|
layout.addWidget(cancel_btn)
|
||||||
layout.addWidget(save_btn)
|
layout.addWidget(save_btn)
|
||||||
|
|
||||||
|
|||||||
@@ -38,5 +38,5 @@ def return_pressed(self):
|
|||||||
self.softwareList.clear()
|
self.softwareList.clear()
|
||||||
self.softwareList.addItems(state.post_titles)
|
self.softwareList.addItems(state.post_titles)
|
||||||
if state.debug == True:
|
if state.debug == True:
|
||||||
print(f"Cached: {cached}")
|
print(f"Response Cached: {cached}")
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
from .aria2_integration import run_aria2p
|
from .aria2_integration import run_aria2p
|
||||||
|
from core.utils.data.state import state
|
||||||
|
|
||||||
def start_client():
|
def start_client():
|
||||||
global aria2
|
global aria2
|
||||||
aria2 = run_aria2p()
|
aria2 = run_aria2p()
|
||||||
|
if state.debug:
|
||||||
|
print("Started Aria2p")
|
||||||
|
|
||||||
def add_magnet(uri):
|
def add_magnet(uri):
|
||||||
aria2.add_magnet(uri)
|
aria2.add_magnet(uri)
|
||||||
|
if state.debug:
|
||||||
|
print("Magnet URI added to Aria2")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,21 @@ from core.utils.network.jsonhandler import format_data
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_item_url(item, posts, post_titles): # oftwarelist currentitem, post list (dict), post titles list
|
def get_item_url(item, posts, post_titles): # softwarelist currentitem, post list (dict), post titles list
|
||||||
post_index = post_titles.index(item)
|
post_index = post_titles.index(item)
|
||||||
if 0 <= post_index < len(post_titles):
|
if 0 <= post_index < len(post_titles):
|
||||||
if state.tracker == "uztracker":
|
if state.tracker == "uztracker":
|
||||||
item = "https://uztracker.net/" + state.post_urls[post_index].lstrip("./")
|
item = "https://uztracker.net/" + state.post_urls[post_index].lstrip("./")
|
||||||
|
if state.debug:
|
||||||
|
print("Found post URL: ", item)
|
||||||
return item
|
return item
|
||||||
if state.tracker == "rutracker":
|
if state.tracker == "rutracker":
|
||||||
item_dict = posts[post_index]
|
item_dict = posts[post_index]
|
||||||
_, post_links, _ = format_data([item_dict])
|
_, post_links, _ = format_data([item_dict])
|
||||||
|
if state.debug:
|
||||||
|
print("Found post URL: ", post_links[0])
|
||||||
return post_links[0]
|
return post_links[0]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -22,6 +27,8 @@ def get_item_url(item, posts, post_titles): # oftwarelist currentitem, post list
|
|||||||
def get_magnet_link(post_url):
|
def get_magnet_link(post_url):
|
||||||
try:
|
try:
|
||||||
response = requests.get(post_url) # eventually impl. cloudscraper
|
response = requests.get(post_url) # eventually impl. cloudscraper
|
||||||
|
if state.debug:
|
||||||
|
print("Sent Request to retrieve Magnet Link...")
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
soup = BeautifulSoup(response.text, 'html.parser')
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||||||
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def kill_aria2server():
|
|||||||
if proc.name() == process:
|
if proc.name() == process:
|
||||||
proc.kill()
|
proc.kill()
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Killed Aria2c")
|
print(f"Killed Aria2c (PID {proc.pid})")
|
||||||
except psutil.NoSuchProcess:
|
except psutil.NoSuchProcess:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import threading
|
|||||||
def download_selected(item, posts, post_titles):
|
def download_selected(item, posts, post_titles):
|
||||||
if item is not None:
|
if item is not None:
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print(f"network {item.text()}")
|
print(f"Downloading {item.text()}")
|
||||||
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ import qdarktheme
|
|||||||
import darkdetect
|
import darkdetect
|
||||||
import threading
|
import threading
|
||||||
import signal
|
import signal
|
||||||
import atexit
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Debug Output
|
|
||||||
state.debug = True
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--debug", action="store_true")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def run_gui():
|
def run_gui():
|
||||||
@@ -36,6 +39,7 @@ def keyboardinterrupthandler(signum, frame):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
read_config()
|
read_config()
|
||||||
|
state.debug = args.debug # override of read_config
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Starting Aria2 Server")
|
print("Starting Aria2 Server")
|
||||||
state.aria2process = run_aria2server()
|
state.aria2process = run_aria2server()
|
||||||
|
|||||||
Reference in New Issue
Block a user