Assorted fixes

- landscape.io was complaining, this fixes most easily fixable errors
This commit is contained in:
Peter Šurda 2017-01-11 18:13:00 +01:00
parent cdcdf11d59
commit c738d93056
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
12 changed files with 26 additions and 38 deletions

View File

@ -19,6 +19,7 @@ try:
except Exception as err: except Exception as err:
logmsg = 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download it from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\' (without quotes).' logmsg = 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download it from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\' (without quotes).'
logger.critical(logmsg, exc_info=True) logger.critical(logmsg, exc_info=True)
import sys
sys.exit() sys.exit()
try: try:
@ -1214,8 +1215,6 @@ class MyForm(settingsmixin.SMainWindow):
# When an unread inbox row is selected on then clear the messaging menu # When an unread inbox row is selected on then clear the messaging menu
def ubuntuMessagingMenuClear(self, inventoryHash): def ubuntuMessagingMenuClear(self, inventoryHash):
global withMessagingMenu
# if this isn't ubuntu then don't do anything # if this isn't ubuntu then don't do anything
if not self.isUbuntu(): if not self.isUbuntu():
return return
@ -1315,8 +1314,6 @@ class MyForm(settingsmixin.SMainWindow):
# update the Ubuntu messaging menu # update the Ubuntu messaging menu
def ubuntuMessagingMenuUpdate(self, drawAttention, newItem, toLabel): def ubuntuMessagingMenuUpdate(self, drawAttention, newItem, toLabel):
global withMessagingMenu
# if this isn't ubuntu then don't do anything # if this isn't ubuntu then don't do anything
if not self.isUbuntu(): if not self.isUbuntu():
return return
@ -1440,14 +1437,11 @@ class MyForm(settingsmixin.SMainWindow):
# initialise the message notifier # initialise the message notifier
def notifierInit(self): def notifierInit(self):
global withMessagingMenu
if withMessagingMenu: if withMessagingMenu:
Notify.init('pybitmessage') Notify.init('pybitmessage')
# shows a notification # shows a notification
def notifierShow(self, title, subtitle, fromCategory, label): def notifierShow(self, title, subtitle, fromCategory, label):
global withMessagingMenu
self.playSound(fromCategory, label) self.playSound(fromCategory, label)
if withMessagingMenu: if withMessagingMenu:
@ -1642,7 +1636,6 @@ class MyForm(settingsmixin.SMainWindow):
connected = False connected = False
def setStatusIcon(self, color): def setStatusIcon(self, color):
global withMessagingMenu
# print 'setting status icon color' # print 'setting status icon color'
if color == 'red': if color == 'red':
self.pushButtonStatusIcon.setIcon( self.pushButtonStatusIcon.setIcon(
@ -3057,7 +3050,7 @@ class MyForm(settingsmixin.SMainWindow):
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You cannot add the same address to your blacklist twice. Try renaming the existing one if you want."), 10000) "MainWindow", "Error: You cannot add the same address to your blacklist twice. Try renaming the existing one if you want."), 10000)
def deleteRowFromMessagelist(row = None, inventoryHash = None, ackData = None, messageLists = None): def deleteRowFromMessagelist(self, row = None, inventoryHash = None, ackData = None, messageLists = None):
if messageLists is None: if messageLists is None:
messageLists = (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions) messageLists = (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions)
elif type(messageLists) not in (list, tuple): elif type(messageLists) not in (list, tuple):
@ -4447,7 +4440,6 @@ class MySingleApplication(QApplication):
self.server.close() self.server.close()
def on_new_connection(self): def on_new_connection(self):
global myapp
if myapp: if myapp:
myapp.appIndicatorShow() myapp.appIndicatorShow()

View File

@ -147,7 +147,7 @@ class GatewayAccount(BMAccount):
ALL_OK = 0 ALL_OK = 0
REGISTRATION_DENIED = 1 REGISTRATION_DENIED = 1
def __init__(self, address): def __init__(self, address):
super(BMAccount, self).__init__(address) super(GatewayAccount, self).__init__(address)
def send(self): def send(self):
status, addressVersionNumber, streamNumber, ripe = decodeAddress(self.toAddress) status, addressVersionNumber, streamNumber, ripe = decodeAddress(self.toAddress)
@ -175,7 +175,7 @@ class GatewayAccount(BMAccount):
shared.workerQueue.put(('sendmessage', self.toAddress)) shared.workerQueue.put(('sendmessage', self.toAddress))
def parseMessage(self, toAddress, fromAddress, subject, message): def parseMessage(self, toAddress, fromAddress, subject, message):
super(BMAccount, self).parseMessage(toAddress, fromAddress, subject, message) super(GatewayAccount, self).parseMessage(toAddress, fromAddress, subject, message)
class MailchuckAccount(GatewayAccount): class MailchuckAccount(GatewayAccount):
# set "gateway" in keys.dat to this # set "gateway" in keys.dat to this
@ -186,7 +186,7 @@ class MailchuckAccount(GatewayAccount):
regExpIncoming = re.compile("(.*)MAILCHUCK-FROM::(\S+) \| (.*)") regExpIncoming = re.compile("(.*)MAILCHUCK-FROM::(\S+) \| (.*)")
regExpOutgoing = re.compile("(\S+) (.*)") regExpOutgoing = re.compile("(\S+) (.*)")
def __init__(self, address): def __init__(self, address):
super(GatewayAccount, self).__init__(address) super(MailchuckAccount, self).__init__(address)
self.feedback = self.ALL_OK self.feedback = self.ALL_OK
def createMessage(self, toAddress, fromAddress, subject, message): def createMessage(self, toAddress, fromAddress, subject, message):
@ -262,7 +262,7 @@ class MailchuckAccount(GatewayAccount):
self.fromAddress = self.address self.fromAddress = self.address
def parseMessage(self, toAddress, fromAddress, subject, message): def parseMessage(self, toAddress, fromAddress, subject, message):
super(GatewayAccount, self).parseMessage(toAddress, fromAddress, subject, message) super(MailchuckAccount, self).parseMessage(toAddress, fromAddress, subject, message)
if fromAddress == self.relayAddress: if fromAddress == self.relayAddress:
matches = self.regExpIncoming.search(subject) matches = self.regExpIncoming.search(subject)
if not matches is None: if not matches is None:

View File

@ -2,7 +2,6 @@ from PyQt4 import QtCore, QtGui
import shared import shared
from tr import _translate from tr import _translate
import l10n import l10n
from uisignaler import UISignaler
import widgets import widgets
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
from configparser import BMConfigParser from configparser import BMConfigParser

View File

@ -316,19 +316,19 @@ class NewAddressThread(QtCore.QThread):
def __del__(self): def __del__(self):
self.wait() self.wait()
def createDeterministic(): def createDeterministic(self):
pass pass
def createPassphrase(): def createPassphrase(self):
pass pass
def broadcastAddress(): def broadcastAddress(self):
pass pass
def registerMailchuck(): def registerMailchuck(self):
pass pass
def waitRegistration(): def waitRegistration(self):
pass pass
def run(self): def run(self):

View File

@ -41,7 +41,6 @@ class objectHashHolder(threading.Thread):
def hasHash(self, hash): def hasHash(self, hash):
if hash in (hashlist for hashlist in self.collectionOfHashLists): if hash in (hashlist for hashlist in self.collectionOfHashLists):
logger.debug("Hash in hashHolder")
return True return True
return False return False

View File

@ -270,9 +270,9 @@ class receiveDataThread(threading.Thread):
self.processData() self.processData()
def sendpong(self): def sendpong(self, payload):
logger.debug('Sending pong') logger.debug('Sending pong')
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.CreatePacket('pong'))) self.sendDataThreadQueue.put((0, 'sendRawData', protocol.CreatePacket('pong', payload)))
def recverack(self): def recverack(self):

View File

@ -8,6 +8,7 @@ import urlparse
from configparser import BMConfigParser from configparser import BMConfigParser
from debug import logger from debug import logger
from helper_threading import * from helper_threading import *
from bitmessageqt.uisignaler import UISignaler
import shared import shared
SMTPDOMAIN = "bmaddr.lan" SMTPDOMAIN = "bmaddr.lan"

View File

@ -6,6 +6,7 @@ from email.header import decode_header
import re import re
import signal import signal
import smtpd import smtpd
import socket
import threading import threading
import time import time
@ -43,7 +44,7 @@ class smtpServerChannel(smtpd.SMTPChannel):
self.auth = True self.auth = True
self.push('235 2.7.0 Authentication successful') self.push('235 2.7.0 Authentication successful')
else: else:
raise Error("Auth fail") raise Exception("Auth fail")
except: except:
self.push('501 Authentication fail') self.push('501 Authentication fail')

View File

@ -53,16 +53,12 @@ def initCL():
enabledGpus = [] enabledGpus = []
def openclAvailable(): def openclAvailable():
global gpus
return (len(gpus) > 0) return (len(gpus) > 0)
def openclEnabled(): def openclEnabled():
global enabledGpus
return (len(enabledGpus) > 0) return (len(enabledGpus) > 0)
def do_opencl_pow(hash, target): def do_opencl_pow(hash, target):
global ctx, queue, program, enabledGpus, hash_dt
output = numpy.zeros(1, dtype=[('v', numpy.uint64, 1)]) output = numpy.zeros(1, dtype=[('v', numpy.uint64, 1)])
if (len(enabledGpus) == 0): if (len(enabledGpus) == 0):
return output[0][0] return output[0][0]

View File

@ -19,8 +19,7 @@ bitmsglib = 'bitmsghash.so'
def _set_idle(): def _set_idle():
if 'linux' in sys.platform: if 'linux' in sys.platform:
import os os.nice(20)
os.nice(20) # @UndefinedVariable
else: else:
try: try:
sys.getwindowsversion() sys.getwindowsversion()

View File

@ -211,7 +211,7 @@ def reloadBroadcastSendersForWhichImWatching():
MyECSubscriptionCryptorObjects[tag] = highlevelcrypto.makeCryptor(hexlify(privEncryptionKey)) MyECSubscriptionCryptorObjects[tag] = highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))
def doCleanShutdown(): def doCleanShutdown():
global shutdown, thisapp global shutdown
shutdown = 1 #Used to tell proof of work worker threads and the objectProcessorThread to exit. shutdown = 1 #Used to tell proof of work worker threads and the objectProcessorThread to exit.
try: try:
parserInputQueue.put(None, False) parserInputQueue.put(None, False)

View File

@ -11,7 +11,7 @@ from helper_threading import *
import shared import shared
import tr import tr
def createRequestXML(service, action, arguments=[]): def createRequestXML(service, action, arguments=None):
from xml.dom.minidom import Document from xml.dom.minidom import Document
doc = Document() doc = Document()
@ -37,6 +37,7 @@ def createRequestXML(service, action, arguments=[]):
# iterate over arguments, create nodes, create text nodes, # iterate over arguments, create nodes, create text nodes,
# append text nodes to nodes, and finally add the ready product # append text nodes to nodes, and finally add the ready product
# to argument_list # to argument_list
if arguments is not None:
for k, v in arguments: for k, v in arguments:
tmp_node = doc.createElement(k) tmp_node = doc.createElement(k)
tmp_text_node = doc.createTextNode(v) tmp_text_node = doc.createTextNode(v)
@ -140,7 +141,7 @@ class Router:
dom = parseString(resp) dom = parseString(resp)
return dom.getElementsByTagName('NewExternalIPAddress')[0].childNodes[0].data return dom.getElementsByTagName('NewExternalIPAddress')[0].childNodes[0].data
def soapRequest(self, service, action, arguments=[]): def soapRequest(self, service, action, arguments=None):
from xml.dom.minidom import parseString from xml.dom.minidom import parseString
from debug import logger from debug import logger
conn = httplib.HTTPConnection(self.routerPath.hostname, self.routerPath.port) conn = httplib.HTTPConnection(self.routerPath.hostname, self.routerPath.port)