From ed22fe7d124ef3305547ec707e855b29ef763657 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Tue, 12 Jan 2021 08:48:40 +0200 Subject: [PATCH] Fix missing events, show seconds delayed. --- .travis.yml | 18 +++++++++--------- basicswap/basicswap.py | 3 +-- basicswap/js_server.py | 3 +-- basicswap/ui.py | 7 +++---- basicswap/util.py | 7 +++++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index f29268b..d414c4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,17 @@ stages: - test env: global: - - TEST_PREPARE_PATH: ~/test_basicswap-prepare - - TEST_DIR=~/test_basicswap2 + - TEST_PREPARE_PATH=~/test_basicswap-prepare + - TEST_DIR=${HOME}/test_basicswap2 - TEST_RELOAD_PATH=~/test_basicswap1 - - BIN_DIRS=~/cached_bin - - PARTICL_BINDIR=${BIN_DIRS}/particl - - BITCOIN_BINDIR=${BIN_DIRS}/bitcoin - - LITECOIN_BINDIR=${BIN_DIRS}/litecoin - - XMR_BINDIR=${BIN_DIRS}/monero + - BIN_DIR=~/cached_bin + - PARTICL_BINDIR=${BIN_DIR}/particl + - BITCOIN_BINDIR=${BIN_DIR}/bitcoin + - LITECOIN_BINDIR=${BIN_DIR}/litecoin + - XMR_BINDIR=${BIN_DIR}/monero cache: directories: - - "$BIN_DIRS" + - "$BIN_DIR" before_install: - sudo apt-get install -y wget python3-pip gnupg unzip protobuf-compiler automake libtool pkg-config install: @@ -30,7 +30,7 @@ before_script: script: - cd $TRAVIS_BUILD_DIR - python3 setup.py install - - basicswap-prepare --bindir=${BIN_DIRS} --preparebinonly --withcoins=particl,bitcoin,litecoin,monero + - basicswap-prepare --bindir=${BIN_DIR} --preparebinonly --withcoins=particl,bitcoin,litecoin,monero - export DATADIRS="${TEST_DIR}" - mkdir -p "${DATADIRS}/bin" - cp -r ${BIN_DIR} "${DATADIRS}/bin" diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 658346e..1de36e1 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -1725,9 +1725,8 @@ class BasicSwap(BaseApp): query_str = 'SELECT created_at, trigger_at FROM eventqueue ' + \ 'WHERE active_ind = 1 AND linked_id = x\'{}\' '.format(bid_id.hex()) q = session.execute(query_str) - events = [] for row in q: - events.append({'at': row[0], 'desc': 'Delaying until: {}'.format(format_timestamp(row[1]))}) + events.append({'at': row[0], 'desc': 'Delaying until: {}'.format(format_timestamp(row[1], with_seconds=True))}) return events diff --git a/basicswap/js_server.py b/basicswap/js_server.py index 3698b61..b063186 100644 --- a/basicswap/js_server.py +++ b/basicswap/js_server.py @@ -5,7 +5,6 @@ # file LICENSE or http://www.opensource.org/licenses/mit-license.php. import json -import time import urllib.parse from .util import ( @@ -84,7 +83,7 @@ def js_offers(self, url_split, post_string, sent=False): ci_to = self.server.swap_client.ci(o.coin_to) rv.append({ 'offer_id': o.offer_id.hex(), - 'created_at': time.strftime('%Y-%m-%d %H:%M', time.localtime(o.created_at)), + 'created_at': format_timestamp(o.created_at), 'coin_from': ci_from.coin_name(), 'coin_to': ci_to.coin_name(), 'amount_from': ci_from.format_amount(o.amount_from), diff --git a/basicswap/ui.py b/basicswap/ui.py index 9480abf..6151a43 100644 --- a/basicswap/ui.py +++ b/basicswap/ui.py @@ -4,10 +4,9 @@ # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. -import time - from .util import ( make_int, + format_timestamp, ) from .chainparams import ( Coins, @@ -133,8 +132,8 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b 'offer_id': bid.offer_id.hex(), 'addr_from': bid.bid_addr, 'addr_fund_proof': bid.proof_address, - 'created_at': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(bid.created_at)), - 'expired_at': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(bid.expire_at)), + 'created_at': format_timestamp(bid.created_at, with_seconds=True), + 'expired_at': format_timestamp(bid.expire_at, with_seconds=True), 'was_sent': 'True' if bid.was_sent else 'False', 'was_received': 'True' if bid.was_received else 'False', 'initiate_tx': getTxIdHex(bid, TxTypes.ITX, ' ' + ticker_from), diff --git a/basicswap/util.py b/basicswap/util.py index 52111ff..4572775 100644 --- a/basicswap/util.py +++ b/basicswap/util.py @@ -306,8 +306,11 @@ def format_amount(i, display_scale, scale=None): return rv -def format_timestamp(value): - return time.strftime('%Y-%m-%d %H:%M', time.localtime(value)) +def format_timestamp(value, with_seconds=False): + str_format = '%Y-%m-%d %H:%M' + if with_seconds: + str_format += ':%S' + return time.strftime(str_format, time.localtime(value)) def getP2SHScriptForHash(p2sh):