Patch 2ffs (#2)
* without that global, BM will crash * pep fix pep is quite the stickler * that warning was cut short a bit "Because you are not currently connected to the network, the BM will not be sent right now" * little fixes * pep * removed global streamNumber will be autoset I guess * pylint :-( * disa lint * no "because" * lint :-( * omg * oh my * f it * avoid addr * [] * # pylint: disable=W0291 # very helpful against overzealous checks * spaces * yy
This commit is contained in:
parent
b20849dc7f
commit
d1f76712c0
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -8,7 +8,7 @@ src/.project
|
||||||
src/.pydevproject
|
src/.pydevproject
|
||||||
src/.settings/
|
src/.settings/
|
||||||
src/**/.dll
|
src/**/.dll
|
||||||
src/**/*.o
|
src/**/*.o
|
||||||
src/**/*.so
|
src/**/*.so
|
||||||
build/lib.*
|
build/lib.*
|
||||||
build/temp.*
|
build/temp.*
|
||||||
|
@ -16,5 +16,4 @@ dist
|
||||||
*.egg-info
|
*.egg-info
|
||||||
docs/_*/*
|
docs/_*/*
|
||||||
docs/autodoc/
|
docs/autodoc/
|
||||||
pyan/
|
pyan/
|
||||||
src/**/.log
|
|
|
@ -1,10 +1,23 @@
|
||||||
|
# in case of trouble with pylint, disable error msg
|
||||||
|
# with a line like (remove the _ s):
|
||||||
|
# _p_y_l_i_n_t_:_ dis_able=W_0_2_9_1 , W291 # trailing spaces
|
||||||
|
|
||||||
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
|
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
|
||||||
# This file adds a alternative commandline interface, feel free to critique and fork
|
# & The Bitmessage Developers
|
||||||
#
|
# This file adds an alternative commandline interface ("CLI")
|
||||||
# This has only been tested on Arch Linux and Linux Mint
|
# and the menu is easy to extend and modify
|
||||||
|
# run as: python2 bitmessagemain.py --curses
|
||||||
|
|
||||||
|
# There is no need for Qt4 and this mode can be run easier e.g. on
|
||||||
|
# rental webservers without GUI
|
||||||
|
# It does not use the BM-API like bitmessagecli.py does.
|
||||||
|
# Feel free to critique and fork on github.
|
||||||
|
|
||||||
|
# This has been tested on Arch Linux, Linux Mint, Manjaro, KDE neon (only),
|
||||||
|
# try Xterm if Konsole is not working
|
||||||
# Dependencies:
|
# Dependencies:
|
||||||
# * from python2-pip
|
# * python2-pip
|
||||||
# * python2-pythondialog
|
# * python2-pythondialog
|
||||||
# * dialog
|
# * dialog
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -264,9 +277,10 @@ def dialogreset(stdscr):
|
||||||
stdscr.keypad(1)
|
stdscr.keypad(1)
|
||||||
curses.curs_set(0)
|
curses.curs_set(0)
|
||||||
def handlech(c, stdscr):
|
def handlech(c, stdscr):
|
||||||
|
addr=""
|
||||||
if c != curses.ERR:
|
if c != curses.ERR:
|
||||||
global inboxcur, addrcur, sentcur, subcur, abookcur, blackcur
|
global inboxcur, addrcur, sentcur, subcur, abookcur, blackcur
|
||||||
if c in range(256):
|
if c in range(256):
|
||||||
if chr(c) in '12345678':
|
if chr(c) in '12345678':
|
||||||
global menutab
|
global menutab
|
||||||
menutab = int(chr(c))
|
menutab = int(chr(c))
|
||||||
|
@ -608,7 +622,8 @@ def handlech(c, stdscr):
|
||||||
label = t
|
label = t
|
||||||
# Prepend entry
|
# Prepend entry
|
||||||
subscriptions.reverse()
|
subscriptions.reverse()
|
||||||
subscriptions.append([label, addr, True])
|
# subscriptions.append([label, addr , True])
|
||||||
|
subscriptions.append([label, addrbook[abookcur][1], True])
|
||||||
subscriptions.reverse()
|
subscriptions.reverse()
|
||||||
|
|
||||||
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, addr, True)
|
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, addr, True)
|
||||||
|
@ -623,7 +638,7 @@ def handlech(c, stdscr):
|
||||||
sqlExecute("INSERT INTO addressbook VALUES (?,?)", t, addr)
|
sqlExecute("INSERT INTO addressbook VALUES (?,?)", t, addr)
|
||||||
# Prepend entry
|
# Prepend entry
|
||||||
addrbook.reverse()
|
addrbook.reverse()
|
||||||
addrbook.append([t, addr])
|
addrbook.append([t, addrbook[abookcur][1]]) # addr])
|
||||||
addrbook.reverse()
|
addrbook.reverse()
|
||||||
else:
|
else:
|
||||||
scrollbox(d, unicode("The selected address is already in the Address Book."))
|
scrollbox(d, unicode("The selected address is already in the Address Book."))
|
||||||
|
@ -647,7 +662,7 @@ def handlech(c, stdscr):
|
||||||
elif t == "2":
|
elif t == "2":
|
||||||
sqlExecute("UPDATE blacklist SET enabled=1 WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
sqlExecute("UPDATE blacklist SET enabled=1 WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
||||||
blacklist[blackcur][2] = True
|
blacklist[blackcur][2] = True
|
||||||
elif t== "3":
|
elif t == "3":
|
||||||
sqlExecute("UPDATE blacklist SET enabled=0 WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
sqlExecute("UPDATE blacklist SET enabled=0 WHERE label=? AND address=?", blacklist[blackcur][0], blacklist[blackcur][1])
|
||||||
blacklist[blackcur][2] = False
|
blacklist[blackcur][2] = False
|
||||||
dialogreset(stdscr)
|
dialogreset(stdscr)
|
||||||
|
@ -705,7 +720,12 @@ def handlech(c, stdscr):
|
||||||
if menutab == 7:
|
if menutab == 7:
|
||||||
blackcur = len(blackcur)-1
|
blackcur = len(blackcur)-1
|
||||||
redraw(stdscr)
|
redraw(stdscr)
|
||||||
|
|
||||||
|
|
||||||
def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=False):
|
def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=False):
|
||||||
|
# global streamNumber
|
||||||
|
# streamNumber = 0
|
||||||
|
# 0 = Auto , 1 = stream 1 is the only supported stream currently
|
||||||
if sender == "":
|
if sender == "":
|
||||||
return
|
return
|
||||||
d = Dialog(dialog="dialog")
|
d = Dialog(dialog="dialog")
|
||||||
|
@ -778,26 +798,19 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
continue
|
continue
|
||||||
if len(shared.connectedHostsList) == 0:
|
if len(shared.connectedHostsList) == 0:
|
||||||
set_background_title(d, "Not connected warning")
|
set_background_title(d, "Not connected warning")
|
||||||
scrollbox(d, unicode("Because you are not currently connected to the network, "))
|
scrollbox(d, unicode("Since you are not currently connected \
|
||||||
|
to the network, the BM will not be sent right now"))
|
||||||
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
||||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
# ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
sqlExecute(
|
ackdata = genAckPayload(stealthLevel=stealthLevel)
|
||||||
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
sqlExecute("INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||||
"",
|
"", addr, ripe, sender, subject, body, ackdata,
|
||||||
addr,
|
int(time.time()), # sentTime (this will never change)
|
||||||
ripe,
|
int(time.time()), # lastActionTime
|
||||||
sender,
|
0, # sleepTill time. This will get set when the POW gets done.
|
||||||
subject,
|
"msgqueued", 0, # retryNumber
|
||||||
body,
|
"sent", 2, # encodingType
|
||||||
ackdata,
|
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||||
int(time.time()), # sentTime (this will never change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0, # sleepTill time. This will get set when the POW gets done.
|
|
||||||
"msgqueued",
|
|
||||||
0, # retryNumber
|
|
||||||
"sent",
|
|
||||||
2, # encodingType
|
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
|
||||||
queues.workerQueue.put(("sendmessage", addr))
|
queues.workerQueue.put(("sendmessage", addr))
|
||||||
else: # Broadcast
|
else: # Broadcast
|
||||||
if recv == "":
|
if recv == "":
|
||||||
|
|
Reference in New Issue
Block a user