add readline to client api request crafter

master
Kevin Froman 2020-08-23 05:53:43 -05:00
parent 61bc5fd34b
commit 15379a7c2f
4 changed files with 37 additions and 2 deletions

View File

@ -8,7 +8,8 @@ print("Please don't run this script on Onionr networks that include more than yo
import sys import sys
import os import os
os.chdir('../') if not os.path.exists('onionr.sh'):
os.chdir('../')
sys.path.append("src/") sys.path.append("src/")
import onionrblocks import onionrblocks

View File

@ -8,6 +8,19 @@ import os
if not os.path.exists('onionr.sh'): if not os.path.exists('onionr.sh'):
os.chdir('../') os.chdir('../')
sys.path.append("src/") 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 local_command
from onionrutils.localcommand import get_hostname from onionrutils.localcommand import get_hostname
@ -16,7 +29,7 @@ try:
except TypeError: except TypeError:
print('Onionr not running') print('Onionr not running')
sys.exit(1) sys.exit(1)
print('1. get request') print('1. get request (default)')
print('2. post request') print('2. post request')
choice = input(">").lower().strip() choice = input(">").lower().strip()
post = False post = False

View File

@ -7,6 +7,9 @@
<div class="quickview-block"> <div class="quickview-block">
Inserting blocks: <span id="insertingBlocks">unknown</span> Inserting blocks: <span id="insertingBlocks">unknown</span>
</div> </div>
<div class="quickview-block">
Blocks to upload: <span id="uploadBlocks">unknown</span>
</div>
</div> </div>
</div> </div>
<button class="button is-primary is-hidden sidebarBtn" data-show="quickview" data-target="quickviewDefault">Show quickview</button> <button class="button is-primary is-hidden sidebarBtn" data-show="quickview" data-target="quickviewDefault">Show quickview</button>

View File

@ -19,6 +19,7 @@ window.addEventListener("keydown", function(event) {
let refreshSideBar = function(){ let refreshSideBar = function(){
if (document.hidden){return} if (document.hidden){return}
var existingValue = document.getElementById("insertingBlocks").innerText var existingValue = document.getElementById("insertingBlocks").innerText
var existingUploadValue = document.getElementById("uploadBlocks")
fetch('/getgeneratingblocks', { fetch('/getgeneratingblocks', {
"method": "get", "method": "get",
headers: { headers: {
@ -36,6 +37,23 @@ window.addEventListener("keydown", function(event) {
} }
document.getElementById("insertingBlocks").innerText = resp.split(',').length - 1 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) setInterval(refreshSideBar, 3000)