mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Refactor scrape_uztracker call in GUI to handle no results more gracefully and improve debug output
This commit is contained in:
@@ -52,10 +52,8 @@ def scrape_uztracker(search, debug):
|
|||||||
return resulttitles, results
|
return resulttitles, results
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
if debug:
|
|
||||||
print(f'No Results found for "{search}"')
|
|
||||||
# add popup in gui for no result
|
# add popup in gui for no result
|
||||||
return
|
return None
|
||||||
|
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
if result:
|
if result:
|
||||||
|
|||||||
+11
-4
@@ -122,12 +122,19 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
def return_pressed(self):
|
def return_pressed(self):
|
||||||
search_text = self.searchbar.text()
|
search_text = self.searchbar.text()
|
||||||
self.postnames, self.postlinks = scrape_uztracker(search_text, debug)
|
|
||||||
self.softwareList.clear()
|
|
||||||
if self.postnames:
|
|
||||||
self.softwareList.addItems(self.postnames)
|
|
||||||
if debug:
|
if debug:
|
||||||
print("User searched for:", search_text)
|
print("User searched for:", search_text)
|
||||||
|
|
||||||
|
response = scrape_uztracker(search_text, debug)
|
||||||
|
if response:
|
||||||
|
self.postnames, self.postlinks = response
|
||||||
|
self.softwareList.clear()
|
||||||
|
if self.postnames:
|
||||||
|
self.softwareList.addItems(self.postnames)
|
||||||
|
elif debug:
|
||||||
|
print(f"No Results found for \"{search_text}\"")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user