Compare commits
8 Commits
242d1b137f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
37a3beb757
|
|||
|
33040273fb
|
|||
|
c2236b099b
|
|||
|
b02c19b530
|
|||
|
4203d078c1
|
|||
|
ff90c72866
|
|||
|
69de61d724
|
|||
|
f4ee4adfb3
|
56
qt.py
56
qt.py
@@ -1052,6 +1052,8 @@ class BalWindow:
|
|||||||
|
|
||||||
error = False
|
error = False
|
||||||
for url in willexecutors:
|
for url in willexecutors:
|
||||||
|
if self.waiting_dialog._stopping:
|
||||||
|
return
|
||||||
willexecutor = willexecutors[url]
|
willexecutor = willexecutors[url]
|
||||||
self.waiting_dialog.update(getMsg(willexecutors))
|
self.waiting_dialog.update(getMsg(willexecutors))
|
||||||
if "txs" in willexecutor:
|
if "txs" in willexecutor:
|
||||||
@@ -1070,6 +1072,8 @@ class BalWindow:
|
|||||||
del willexecutor["txs"]
|
del willexecutor["txs"]
|
||||||
except Willexecutors.AlreadyPresentException:
|
except Willexecutors.AlreadyPresentException:
|
||||||
for wid in willexecutor["txsids"]:
|
for wid in willexecutor["txsids"]:
|
||||||
|
if self.waiting_dialog._stopping:
|
||||||
|
return
|
||||||
self.waiting_dialog.update(
|
self.waiting_dialog.update(
|
||||||
"checking {} - {} : {}".format(
|
"checking {} - {} : {}".format(
|
||||||
self.willitems[wid].we["url"], wid, "Waiting"
|
self.willitems[wid].we["url"], wid, "Waiting"
|
||||||
@@ -1124,6 +1128,8 @@ class BalWindow:
|
|||||||
def check_transactions_task(self, will):
|
def check_transactions_task(self, will):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
for wid, w in will.items():
|
for wid, w in will.items():
|
||||||
|
if self.waiting_dialog._stopping:
|
||||||
|
return
|
||||||
if w.we:
|
if w.we:
|
||||||
self.waiting_dialog.update(
|
self.waiting_dialog.update(
|
||||||
"checking transaction: {}\n willexecutor: {}".format(wid, w.we["url"])
|
"checking transaction: {}\n willexecutor: {}".format(wid, w.we["url"])
|
||||||
@@ -1164,7 +1170,7 @@ class BalWindow:
|
|||||||
def download_list(self, willexecutors, fn_on_success, fn_on_failure=None):
|
def download_list(self, willexecutors, fn_on_success, fn_on_failure=None):
|
||||||
|
|
||||||
def on_success(result):
|
def on_success(result):
|
||||||
# self.willexecutors.update(result)
|
self.willexecutors.update(result)
|
||||||
fn_on_success(result)
|
fn_on_success(result)
|
||||||
|
|
||||||
def on_failure(exec_info):
|
def on_failure(exec_info):
|
||||||
@@ -1758,6 +1764,7 @@ class WillSettingsWidget(QWidget):
|
|||||||
"END:VCALENDAR",
|
"END:VCALENDAR",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
lines = [s.rstrip("\r\n") for s in lines]
|
||||||
ics_content = "\r\n".join(lines) + "\r\n"
|
ics_content = "\r\n".join(lines) + "\r\n"
|
||||||
self.temp_path = BalCalendar.write_temp_ics(ics_content)
|
self.temp_path = BalCalendar.write_temp_ics(ics_content)
|
||||||
opened = BalCalendar.open_with_default_app(
|
opened = BalCalendar.open_with_default_app(
|
||||||
@@ -1874,7 +1881,15 @@ class PercAmountEdit(BTCAmountEdit):
|
|||||||
|
|
||||||
|
|
||||||
class BalDialog(QDialog,MessageBoxMixin):
|
class BalDialog(QDialog,MessageBoxMixin):
|
||||||
|
_stopping = False
|
||||||
def __init__(self, parent, bal_plugin, title=None, icon="icons/bal16x16.png"):
|
def __init__(self, parent, bal_plugin, title=None, icon="icons/bal16x16.png"):
|
||||||
|
import signal
|
||||||
|
from PyQt6.QtCore import QMetaObject, Qt
|
||||||
|
from PyQt6.QtWidgets import QApplication
|
||||||
|
def handler(signum, frame):
|
||||||
|
QMetaObject.invokeMethod(self, "close", Qt.ConnectionType.QueuedConnection)
|
||||||
|
|
||||||
|
#signal.signal(signal.SIGINT, handler)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.thread = None
|
self.thread = None
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@@ -1887,12 +1902,13 @@ class BalDialog(QDialog,MessageBoxMixin):
|
|||||||
self._stopping = True
|
self._stopping = True
|
||||||
#if self.thread:
|
#if self.thread:
|
||||||
# self.thread.stop()
|
# self.thread.stop()
|
||||||
|
super().closeEvent(event)
|
||||||
|
|
||||||
def hideEvent(self, event):
|
def hideEvent(self, event):
|
||||||
self._stopping = True
|
self._stopping = True
|
||||||
#if self.thread:
|
#if self.thread:
|
||||||
# self.thread.stop()
|
# self.thread.stop()
|
||||||
|
super().hideEvent(event)
|
||||||
|
|
||||||
class BalWizardDialog(BalDialog):
|
class BalWizardDialog(BalDialog):
|
||||||
def __init__(self, bal_window: "BalWindow"):
|
def __init__(self, bal_window: "BalWindow"):
|
||||||
@@ -2158,6 +2174,7 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
|
|||||||
# TODO DO NOTHING
|
# TODO DO NOTHING
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.bal_window.will_list_widget.update()
|
||||||
if self.validate():
|
if self.validate():
|
||||||
return self.on_next()
|
return self.on_next()
|
||||||
|
|
||||||
@@ -2248,11 +2265,11 @@ class BalWaitingDialog(BalDialog):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def finished(self):
|
def finished(self):
|
||||||
_logger.info("finished")
|
pass
|
||||||
|
|
||||||
|
|
||||||
def on_accepted(self):
|
def on_accepted(self):
|
||||||
self.thread.stop()
|
pass
|
||||||
|
|
||||||
def update_message(self, msg):
|
def update_message(self, msg):
|
||||||
self.message_label.setText(msg)
|
self.message_label.setText(msg)
|
||||||
@@ -2263,9 +2280,6 @@ class BalWaitingDialog(BalDialog):
|
|||||||
def getText(self):
|
def getText(self):
|
||||||
return self.message_label.text()
|
return self.message_label.text()
|
||||||
|
|
||||||
def closeEvent(self, event):
|
|
||||||
self._stopping = True
|
|
||||||
self.thread.stop()
|
|
||||||
|
|
||||||
|
|
||||||
class BalBlockingWaitingDialog(BalDialog):
|
class BalBlockingWaitingDialog(BalDialog):
|
||||||
@@ -2367,6 +2381,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.exec()
|
self.exec()
|
||||||
|
|
||||||
def task_phase1(self):
|
def task_phase1(self):
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
txs = None
|
txs = None
|
||||||
_logger.debug("close plugin phase 1 started")
|
_logger.debug("close plugin phase 1 started")
|
||||||
varrow = self.msg_set_status("checking variables")
|
varrow = self.msg_set_status("checking variables")
|
||||||
@@ -2510,6 +2526,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.msg_del_row(wait_row)
|
self.msg_del_row(wait_row)
|
||||||
|
|
||||||
def loop_broadcast_invalidating(self, tx):
|
def loop_broadcast_invalidating(self, tx):
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
self.msg_set_invalidating("Broadcasting")
|
self.msg_set_invalidating("Broadcasting")
|
||||||
try:
|
try:
|
||||||
tx.add_info_from_wallet(self.bal_window.wallet)
|
tx.add_info_from_wallet(self.bal_window.wallet)
|
||||||
@@ -2529,6 +2547,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.msg_set_invalidating(self.msg_error(e))
|
self.msg_set_invalidating(self.msg_error(e))
|
||||||
|
|
||||||
def loop_push(self):
|
def loop_push(self):
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
self.msg_set_pushing(_("Broadcasting"))
|
self.msg_set_pushing(_("Broadcasting"))
|
||||||
retry = False
|
retry = False
|
||||||
try:
|
try:
|
||||||
@@ -2537,6 +2557,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.bal_window.willitems
|
self.bal_window.willitems
|
||||||
)
|
)
|
||||||
for url, willexecutor in willexecutors.items():
|
for url, willexecutor in willexecutors.items():
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
if Willexecutors.is_selected(
|
if Willexecutors.is_selected(
|
||||||
self.bal_window.willexecutors.get(url)
|
self.bal_window.willexecutors.get(url)
|
||||||
@@ -2557,6 +2579,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
)
|
)
|
||||||
except Willexecutors.AlreadyPresentException:
|
except Willexecutors.AlreadyPresentException:
|
||||||
for wid in willexecutor["txsids"]:
|
for wid in willexecutor["txsids"]:
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
row = self.msg_edit_row(
|
row = self.msg_edit_row(
|
||||||
"checking {} - {} : {}".format(
|
"checking {} - {} : {}".format(
|
||||||
self.bal_window.willitems[wid].we["url"], wid, "Waiting"
|
self.bal_window.willitems[wid].we["url"], wid, "Waiting"
|
||||||
@@ -2591,6 +2615,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
# self.loop_push()
|
# self.loop_push()
|
||||||
|
|
||||||
def invalidate_task(self, password, bal_window, tx):
|
def invalidate_task(self, password, bal_window, tx):
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
_logger.debug(f"invalidate tx: {tx}")
|
_logger.debug(f"invalidate tx: {tx}")
|
||||||
# fee_per_byte = bal_window.will_settings.get("baltx_fees", 1)
|
# fee_per_byte = bal_window.will_settings.get("baltx_fees", 1)
|
||||||
tx = self.bal_window.wallet.sign_transaction(tx, password)
|
tx = self.bal_window.wallet.sign_transaction(tx, password)
|
||||||
@@ -2617,6 +2643,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_success_phase1(self, result):
|
def on_success_phase1(self, result):
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
self.have_to_sign, tx = list(result)
|
self.have_to_sign, tx = list(result)
|
||||||
# if not tx:
|
# if not tx:
|
||||||
# self.msg_edit_row(self.msg_error("Error, no tx was built"))
|
# self.msg_edit_row(self.msg_error("Error, no tx was built"))
|
||||||
@@ -2672,6 +2700,8 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.thread.stop()
|
self.thread.stop()
|
||||||
|
|
||||||
def task_phase2(self, password):
|
def task_phase2(self, password):
|
||||||
|
if self._stopping:
|
||||||
|
return
|
||||||
if self.have_to_sign:
|
if self.have_to_sign:
|
||||||
try:
|
try:
|
||||||
if txs := self.bal_window.sign_transactions(password):
|
if txs := self.bal_window.sign_transactions(password):
|
||||||
@@ -3996,10 +4026,16 @@ class CheckAliveError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
def log_error(exec_info, window=None):
|
def log_error(exec_info, window=None):
|
||||||
_logger.error(exec_info)
|
_logger.error(f"LOG_ERROR: {exec_info}")
|
||||||
#tb = traceback.format_exc()
|
#tb = traceback.format_exc()
|
||||||
|
try:
|
||||||
tb=exec_info[1]
|
tb=exec_info[1]
|
||||||
_logger.error(tb)
|
_logger.error(tb)
|
||||||
|
except Exception:
|
||||||
|
tb = traceback.format_exc()
|
||||||
|
_logger.error(tb)
|
||||||
|
|
||||||
|
|
||||||
if window is not None:
|
if window is not None:
|
||||||
window.show_error(exec_info)
|
window.show_error(exec_info)
|
||||||
|
|
||||||
@@ -4031,8 +4067,8 @@ class BalCalendar:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def write_temp_ics(content):
|
def write_temp_ics(content):
|
||||||
fd, path = tempfile.mkstemp(prefix="event_", suffix=".ics")
|
fd, path = tempfile.mkstemp(prefix="event_", suffix=".ics")
|
||||||
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
with os.fdopen(fd, "wb") as f:
|
||||||
f.write(content)
|
f.write(content.encode("utf-8"))
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -131,8 +131,6 @@ class Willexecutors:
|
|||||||
def send_request(
|
def send_request(
|
||||||
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
|
method, url, data=None, *, timeout=10, handle_response=None, count_reply=0
|
||||||
):
|
):
|
||||||
import time
|
|
||||||
time.sleep(10)
|
|
||||||
network = Network.get_instance()
|
network = Network.get_instance()
|
||||||
if not network:
|
if not network:
|
||||||
raise Exception("You are offline.")
|
raise Exception("You are offline.")
|
||||||
@@ -286,7 +284,7 @@ class Willexecutors:
|
|||||||
for w in willexecutors:
|
for w in willexecutors:
|
||||||
if w not in ("status", "url"):
|
if w not in ("status", "url"):
|
||||||
Willexecutors.initialize_willexecutor(
|
Willexecutors.initialize_willexecutor(
|
||||||
willexecutors[w], w, None, old_willexecutors.get(w,{})
|
willexecutors[w], w, None, old_willexecutors.get(w,None)
|
||||||
)
|
)
|
||||||
# bal_plugin.WILLEXECUTORS.set(l)
|
# bal_plugin.WILLEXECUTORS.set(l)
|
||||||
# bal_plugin.config.set_key(bal_plugin.WILLEXECUTORS,l,save=True)
|
# bal_plugin.config.set_key(bal_plugin.WILLEXECUTORS,l,save=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user