From 15379a7c2f54055beb585a6c13fb5a84142f1b48 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 23 Aug 2020 05:53:43 -0500 Subject: [PATCH] add readline to client api request crafter --- scripts/block-spammer.py | 3 ++- scripts/client-api-request-crafter.py | 15 ++++++++++++++- static-data/www/shared/sidebar/sidebar.html | 3 +++ static-data/www/shared/sidebar/sidebar.js | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/scripts/block-spammer.py b/scripts/block-spammer.py index 69273c8d..51ae6b37 100755 --- a/scripts/block-spammer.py +++ b/scripts/block-spammer.py @@ -8,7 +8,8 @@ print("Please don't run this script on Onionr networks that include more than yo import sys import os -os.chdir('../') +if not os.path.exists('onionr.sh'): + os.chdir('../') sys.path.append("src/") import onionrblocks diff --git a/scripts/client-api-request-crafter.py b/scripts/client-api-request-crafter.py index 73f55b33..a5780fb0 100644 --- a/scripts/client-api-request-crafter.py +++ b/scripts/client-api-request-crafter.py @@ -8,6 +8,19 @@ import os if not os.path.exists('onionr.sh'): os.chdir('../') sys.path.append("src/") + +import atexit +import readline + +histfile = os.path.join(os.path.expanduser("~"), ".onionr_history") +try: + readline.read_history_file(histfile) + # default history len is -1 (infinite), which may grow unruly + readline.set_history_length(1000) +except FileNotFoundError: + pass + +atexit.register(readline.write_history_file, histfile) from onionrutils.localcommand import local_command from onionrutils.localcommand import get_hostname @@ -16,7 +29,7 @@ try: except TypeError: print('Onionr not running') sys.exit(1) -print('1. get request') +print('1. get request (default)') print('2. post request') choice = input(">").lower().strip() post = False diff --git a/static-data/www/shared/sidebar/sidebar.html b/static-data/www/shared/sidebar/sidebar.html index 75e5cbe4..dea7078e 100644 --- a/static-data/www/shared/sidebar/sidebar.html +++ b/static-data/www/shared/sidebar/sidebar.html @@ -7,6 +7,9 @@
Inserting blocks: unknown
+
+ Blocks to upload: unknown +
diff --git a/static-data/www/shared/sidebar/sidebar.js b/static-data/www/shared/sidebar/sidebar.js index de97d4d4..8c5d1253 100644 --- a/static-data/www/shared/sidebar/sidebar.js +++ b/static-data/www/shared/sidebar/sidebar.js @@ -19,6 +19,7 @@ window.addEventListener("keydown", function(event) { let refreshSideBar = function(){ if (document.hidden){return} var existingValue = document.getElementById("insertingBlocks").innerText + var existingUploadValue = document.getElementById("uploadBlocks") fetch('/getgeneratingblocks', { "method": "get", headers: { @@ -36,6 +37,23 @@ window.addEventListener("keydown", function(event) { } document.getElementById("insertingBlocks").innerText = resp.split(',').length - 1 }) + fetch('/getblockstoupload', { + "method": "get", + headers: { + "token": webpass + }}) + .then((resp) => resp.text()) + .then(function(resp) { + console.debug(resp.length, existingUploadValue) + if (resp.length <= 2 && existingUploadValue !== "0"){ + document.getElementById("uploadBlocks").innerText = "0" + return + } + if (existingUploadValue === resp.split(',').length){ + return + } + document.getElementById("uploadBlocks").innerText = resp.split(',').length - 1 + }) } setInterval(refreshSideBar, 3000)