Fix asyncio issue while searching for printers
This commit is contained in:
@@ -41,29 +41,21 @@ class PrinterScanner:
|
|||||||
except socket.herror:
|
except socket.herror:
|
||||||
hostname = "Unknown"
|
hostname = "Unknown"
|
||||||
|
|
||||||
printer_name = self.get_printer_name(ip)
|
return {
|
||||||
if printer_name:
|
"ip": ip,
|
||||||
return {
|
"hostname": hostname,
|
||||||
"ip": ip,
|
}
|
||||||
"hostname": hostname,
|
|
||||||
"name": printer_name
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
return {
|
|
||||||
"ip": ip,
|
|
||||||
"hostname": hostname,
|
|
||||||
"name": "Unknown"
|
|
||||||
}
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_all_printers(self, ip_addr="", local=False):
|
def get_all_printers(self, ip_addr="", local=False):
|
||||||
if ip_addr:
|
if ip_addr:
|
||||||
result = self.scan_ip(ip_addr)
|
result = self.scan_ip(ip_addr)
|
||||||
if result:
|
if result:
|
||||||
|
result["name"] = self.get_printer_name(result['ip'])
|
||||||
return [result]
|
return [result]
|
||||||
local_device_ip_list = socket.gethostbyname_ex(socket.gethostname())[2]
|
local_device_ip_list = socket.gethostbyname_ex(socket.gethostname())[2]
|
||||||
if local:
|
if local:
|
||||||
return local_device_ip_list
|
return local_device_ip_list # IP list
|
||||||
printers = []
|
printers = []
|
||||||
for local_device_ip in local_device_ip_list:
|
for local_device_ip in local_device_ip_list:
|
||||||
if ip_addr and not local_device_ip.startswith(ip_addr):
|
if ip_addr and not local_device_ip.startswith(ip_addr):
|
||||||
@@ -85,6 +77,8 @@ class PrinterScanner:
|
|||||||
for thread in threads:
|
for thread in threads:
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
for i in printers:
|
||||||
|
i["name"] = self.get_printer_name(i['ip'])
|
||||||
return printers
|
return printers
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
ui.py
3
ui.py
@@ -37,7 +37,7 @@ from find_printers import PrinterScanner
|
|||||||
from text_console import TextConsole
|
from text_console import TextConsole
|
||||||
|
|
||||||
|
|
||||||
VERSION = "6.0.1"
|
VERSION = "6.0.2"
|
||||||
|
|
||||||
NO_CONF_ERROR = (
|
NO_CONF_ERROR = (
|
||||||
" Please select a printer model and a valid IP address,"
|
" Please select a printer model and a valid IP address,"
|
||||||
@@ -3102,6 +3102,7 @@ Web site: https://github.com/Ircama/epson_print_conf
|
|||||||
self.detect_button.config(state=tk.DISABLED) # disable button while processing
|
self.detect_button.config(state=tk.DISABLED) # disable button while processing
|
||||||
self.show_status_text_view()
|
self.show_status_text_view()
|
||||||
try:
|
try:
|
||||||
|
# [{'ip': '...', 'hostname': '...', 'name': '...'}]
|
||||||
printers = self.printer_scanner.get_all_printers(
|
printers = self.printer_scanner.get_all_printers(
|
||||||
self.ip_var.get().strip()
|
self.ip_var.get().strip()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user