Imports, typos, syntax errors

- remove obsolete imports
- add missing imports
- fix typos
- fix syntax errors
- thanks to landscape.io for report
This commit is contained in:
Peter Šurda 2017-02-08 14:19:02 +01:00
parent 59f3a2fbe7
commit 2cc4435cfc
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
15 changed files with 17 additions and 33 deletions

View File

@ -3,7 +3,7 @@ from struct import *
from pyelliptic import arithmetic
from binascii import hexlify, unhexlify
#from debug import logger
#There is another copy of this function in Bitmessagemain.py
def convertIntToString(n):

View File

@ -907,7 +907,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
with shared.printLock:
print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash)
protocol.broadcastToSendDataQueues((
streamNumber, 'advertiseobject', inventoryHash))
pubkeyStreamNumber, 'advertiseobject', inventoryHash))
def HandleGetMessageDataByDestinationHash(self, params):
# Method will eventually be used by a particular Android app to

View File

@ -63,8 +63,6 @@ def lookupAppdataFolder(): #gets the appropriate folders for the .dat files depe
return dataFolder
def configInit():
global keysName
BMConfigParser().add_section('bitmessagesettings')
BMConfigParser().set('bitmessagesettings', 'port', '8444') #Sets the bitmessage port to stop the warning about the api not properly being setup. This is in the event that the keys.dat is in a different directory or is created locally to connect to a machine remotely.
BMConfigParser().set('bitmessagesettings','apienabled','true') #Sets apienabled to true in keys.dat
@ -76,7 +74,6 @@ def configInit():
print ' You will now need to configure the ' + str(keysName) + ' file.\n'
def apiInit(apiEnabled):
global keysPath
global usrPrompt
BMConfigParser().read(keysPath)
@ -1144,8 +1141,6 @@ def delSentMsg(msgNum): #Deletes a specified message from the outbox
return msgAck
def getLabelForAddress(address):
global usrPrompt
if address in knownAddresses:
return knownAddresses[address]
else:

View File

@ -333,7 +333,6 @@ def handlech(c, stdscr):
sendMessage(fromaddr, toaddr, ischan, subject, body, True)
dialogreset(stdscr)
elif t == "4": # Add to Address Book
global addrbook
addr = inbox[inboxcur][4]
if addr not in [item[1] for i,item in enumerate(addrbook)]:
r, t = d.inputbox("Label for address \""+addr+"\"")
@ -572,7 +571,7 @@ def handlech(c, stdscr):
subscriptions.append([label, addr, True])
subscriptions.reverse()
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, address, True)
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, addr, True)
shared.reloadBroadcastSendersForWhichImWatching()
elif t == "2":
r, t = d.inpuxbox("Type in \"I want to delete this subscription\"")
@ -611,7 +610,7 @@ def handlech(c, stdscr):
subscriptions.append([label, addr, True])
subscriptions.reverse()
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, address, True)
sqlExecute("INSERT INTO subscriptions VALUES (?,?,?)", label, addr, True)
shared.reloadBroadcastSendersForWhichImWatching()
elif t == "3":
r, t = d.inputbox("Input new address")
@ -836,7 +835,6 @@ def loadInbox():
FROM inbox WHERE folder='inbox' AND %s LIKE ?
ORDER BY received
""" % (where,), what)
global inbox
for row in ret:
msgid, toaddr, fromaddr, subject, received, read = row
subject = ascii(shared.fixPotentiallyInvalidUTF8Data(subject))
@ -886,7 +884,6 @@ def loadSent():
FROM sent WHERE folder='sent' AND %s LIKE ?
ORDER BY lastactiontime
""" % (where,), what)
global sent
for row in ret:
toaddr, fromaddr, subject, status, ackdata, lastactiontime = row
subject = ascii(shared.fixPotentiallyInvalidUTF8Data(subject))
@ -958,7 +955,6 @@ def loadAddrBook():
sys.stdout = printlog
ret = sqlQuery("SELECT label, address FROM addressbook")
global addrbook
for row in ret:
label, addr = row
label = shared.fixPotentiallyInvalidUTF8Data(label)
@ -1003,7 +999,7 @@ def runwrapper():
stdscr.timeout(1000)
curses.wrapper(run)
shutdown()
doShutdown()
def run(stdscr):
# Schedule inventory lookup data
@ -1050,7 +1046,7 @@ def run(stdscr):
drawtab(stdscr)
handlech(stdscr.getch(), stdscr)
def shutdown():
def doShutdown():
sys.stdout = sys.__stdout__
print("Shutting down...")
sys.stdout = printlog

View File

@ -110,7 +110,7 @@ class SafeHTMLParser(HTMLParser):
self.sanitised += "&" + name + ";"
def feed(self, data):
global parserLock, parserProcess, parserInputQueue, parserOutputQueue
global parserProcess
HTMLParser.feed(self, data)
tmp = SafeHTMLParser.multi_replace(data)
tmp = unicode(tmp, 'utf-8', 'replace')

View File

@ -56,7 +56,7 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
shutil.copyfile(fileName, fileNameBak)
# The backup succeeded.
fileNameExisted = True
except (IOError, Error):
except (IOError, Exception):
# The backup failed. This can happen if the file didn't exist before.
fileNameExisted = False
# write the file

View File

@ -1,4 +1,3 @@
import shared
import socket
import defaultKnownNodes
import pickle

View File

@ -23,7 +23,7 @@ class Message(MsgBase):
self.data["subject"] = data["subject"]
self.data["body"] = data["body"]
except KeyError as e:
logger.error("Missing key ", e.name)
logger.error("Missing key %s", e.name)
return self.data
def process(self):

View File

@ -15,7 +15,7 @@ class Vote(MsgBase):
self.data["msgid"] = data["msgid"]
self.data["vote"] = data["vote"]
except KeyError as e:
logger.error("Missing key ", e.name)
logger.error("Missing key %s", e.name)
return self.data
def process(self):

View File

@ -1,3 +1,5 @@
import asyncore
class AdvancedDispatcher(asyncore.dispatcher):
_buf_len = 131072
@ -7,13 +9,13 @@ class AdvancedDispatcher(asyncore.dispatcher):
self.write_buf = ""
self.state = "init"
def slice_read_buf(length=0):
def slice_read_buf(self, length=0):
self.read_buf = self.read_buf[length:]
def slice_write_buf(length=0):
def slice_write_buf(self, length=0):
self.write_buf = self.read_buf[length:]
def read_buf_sufficient(length=0):
def read_buf_sufficient(self, length=0):
if len(self.read_buf) < length:
return False
else:

View File

@ -26,7 +26,7 @@ except:
libAvailable = False
def initCL():
global ctx, queue, program, gpus, enabledGpus, hash_dt, vendors
global ctx, queue, program, enabledGpus, hash_dt
try:
hash_dt = numpy.dtype([('target', numpy.uint64), ('v', numpy.str_, 73)])
try:

View File

@ -157,8 +157,6 @@ def getPowType():
return "python"
def notifyBuild(tried=False):
global bmpow
if bmpow:
queues.UISignalQueue.put(('updateStatusBar', (tr._translate("proofofwork", "C PoW module built successfully."), 1)))
elif tried:
@ -167,8 +165,6 @@ def notifyBuild(tried=False):
queues.UISignalQueue.put(('updateStatusBar', (tr._translate("proofofwork", "C PoW module unavailable. Please build it."), 1)))
def buildCPoW():
global bmpow
if bmpow is not None:
return
if paths.frozen is not None:

View File

@ -15,6 +15,7 @@ from debug import logger
from helper_sql import sqlExecute
import highlevelcrypto
from inventory import Inventory
from queues import objectProcessorQueue
import state
from version import softwareVersion

View File

@ -9,9 +9,6 @@ useVeryEasyProofOfWorkForTesting = False # If you set this to True while on the
# Libraries.
import os
import pickle
import Queue
from multiprocessing import active_children, Queue as mpQueue, Lock as mpLock
import sys
import stat
import threading
@ -25,7 +22,6 @@ from configparser import BMConfigParser
import highlevelcrypto
#import helper_startup
from helper_sql import *
from helper_threading import *
from inventory import Inventory, PendingDownload
from queues import objectProcessorQueue
import protocol

View File

@ -1,5 +1,4 @@
import collections
import threading
neededPubkeys = {}
streamsInWhichIAmParticipating = []