fixing webpic internal run + add executable metadata

This commit is contained in:
2022-09-06 14:30:04 +02:00
parent 25f10a8c50
commit 87ab654f55
6 changed files with 92 additions and 15 deletions

View File

@@ -38,7 +38,9 @@ class WebPicDownloader(Thread):
integrated entry point allowing it to be directly executed in terminal mode.
@author EndMove <contact@endmove.eu>
@link https://git.endmove.eu/EndMove/WebPicDownloader
@version 1.2.1
@since 2022-09-05
"""
# Variables
__callbacks: dict = None # Callback dictionary
@@ -63,9 +65,9 @@ class WebPicDownloader(Thread):
* :success: -> Callback function success (see setter).
* :failure: -> Callback function failure (see setter).
"""
super().__init__(daemon=True)
super().__init__(daemon=True, name='WebPic download worker')
self.__callbacks = {
'messenger': messenger if messenger else lambda msg: print(msg),
'messenger': messenger if messenger else lambda msg, type: print(msg),
'success': success if success else lambda: print("Success!"),
'failure': failure if failure else lambda: print("failure!")
}
@@ -306,13 +308,26 @@ class WebPicDownloader(Thread):
if __name__ == "__main__":
# Internal entry point for testing and consol use.
wpd = WebPicDownloader()
while True:
url = input("Website URL ? ")
name = input("Folder name ? ")
wpd.start_downloading(url, name)
if "n" == input("Do you want to continue [Y/n] ? ").lower():
break
wpd.stop_downloading(block=True)
print("Good bye !")
# Internal entry point for testing and console use.
import time
wpd = WebPicDownloader() # Instance of webpic
# Callback functions
def success():
print("\nDownload completed with success.")
def failed():
print("\nDownload completed with errors.")
# Set-up callback functions for webpic
wpd.set_success_callback(success)
wpd.set_failure_callback(failed)
# Ask for download
print("\nWelcome to WebPicDownloader!")
url = input("Website URL ? ")
name = input("Folder name ? ")
wpd.start_downloading(url, name) # Start downloading
time.sleep(1) # We wait for the download to start before ask to stop it
wpd.stop_downloading(block=True) # Stop downloading but block till the download end.