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 pyelliptic import arithmetic
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
#from debug import logger
#There is another copy of this function in Bitmessagemain.py #There is another copy of this function in Bitmessagemain.py
def convertIntToString(n): def convertIntToString(n):

View File

@ -907,7 +907,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
with shared.printLock: with shared.printLock:
print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash) print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash)
protocol.broadcastToSendDataQueues(( protocol.broadcastToSendDataQueues((
streamNumber, 'advertiseobject', inventoryHash)) pubkeyStreamNumber, 'advertiseobject', inventoryHash))
def HandleGetMessageDataByDestinationHash(self, params): def HandleGetMessageDataByDestinationHash(self, params):
# Method will eventually be used by a particular Android app to # 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 return dataFolder
def configInit(): def configInit():
global keysName
BMConfigParser().add_section('bitmessagesettings') 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', '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 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' print ' You will now need to configure the ' + str(keysName) + ' file.\n'
def apiInit(apiEnabled): def apiInit(apiEnabled):
global keysPath
global usrPrompt global usrPrompt
BMConfigParser().read(keysPath) BMConfigParser().read(keysPath)
@ -1144,8 +1141,6 @@ def delSentMsg(msgNum): #Deletes a specified message from the outbox
return msgAck return msgAck
def getLabelForAddress(address): def getLabelForAddress(address):
global usrPrompt
if address in knownAddresses: if address in knownAddresses:
return knownAddresses[address] return knownAddresses[address]
else: else:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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