Updated code quality binary operator, added UnicodeDecodeError specific exception, replaced unicode by decode function changes in shared.py
Replaced unicode by decode function & added UnicodeDecodeError specific exception
This commit is contained in:
parent
3f10348620
commit
894e9fc0b2
|
@ -133,8 +133,8 @@ def reloadMyAddressHashes():
|
||||||
highlevelcrypto.makeCryptor(privEncryptionKey)
|
highlevelcrypto.makeCryptor(privEncryptionKey)
|
||||||
myAddressesByHash[hashobj] = addressInKeysFile
|
myAddressesByHash[hashobj] = addressInKeysFile
|
||||||
tag = hashlib.sha512(hashlib.sha512(
|
tag = hashlib.sha512(hashlib.sha512(
|
||||||
encodeVarint(addressVersionNumber) +
|
encodeVarint(addressVersionNumber)
|
||||||
encodeVarint(streamNumber) + hashobj).digest()).digest()[32:]
|
+ encodeVarint(streamNumber) + hashobj).digest()).digest()[32:]
|
||||||
myAddressesByTag[tag] = addressInKeysFile
|
myAddressesByTag[tag] = addressInKeysFile
|
||||||
else:
|
else:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -168,15 +168,15 @@ def reloadBroadcastSendersForWhichImWatching():
|
||||||
|
|
||||||
if addressVersionNumber <= 3:
|
if addressVersionNumber <= 3:
|
||||||
privEncryptionKey = hashlib.sha512(
|
privEncryptionKey = hashlib.sha512(
|
||||||
encodeVarint(addressVersionNumber) +
|
encodeVarint(addressVersionNumber)
|
||||||
encodeVarint(streamNumber) + hashobj
|
+ encodeVarint(streamNumber) + hashobj
|
||||||
).digest()[:32]
|
).digest()[:32]
|
||||||
MyECSubscriptionCryptorObjects[hashobj] = \
|
MyECSubscriptionCryptorObjects[hashobj] = \
|
||||||
highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))
|
highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))
|
||||||
else:
|
else:
|
||||||
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(
|
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(
|
||||||
encodeVarint(addressVersionNumber) +
|
encodeVarint(addressVersionNumber)
|
||||||
encodeVarint(streamNumber) + hashobj
|
+ encodeVarint(streamNumber) + hashobj
|
||||||
).digest()).digest()
|
).digest()).digest()
|
||||||
tag = doubleHashOfAddressData[32:]
|
tag = doubleHashOfAddressData[32:]
|
||||||
privEncryptionKey = doubleHashOfAddressData[:32]
|
privEncryptionKey = doubleHashOfAddressData[:32]
|
||||||
|
@ -187,9 +187,9 @@ def reloadBroadcastSendersForWhichImWatching():
|
||||||
def fixPotentiallyInvalidUTF8Data(text):
|
def fixPotentiallyInvalidUTF8Data(text):
|
||||||
"""Sanitise invalid UTF-8 strings"""
|
"""Sanitise invalid UTF-8 strings"""
|
||||||
try:
|
try:
|
||||||
unicode(text, 'utf-8')
|
text.decode('utf-8')
|
||||||
return text
|
return text
|
||||||
except:
|
except UnicodeDecodeError:
|
||||||
return 'Part of the message is corrupt. The message cannot be' \
|
return 'Part of the message is corrupt. The message cannot be' \
|
||||||
' displayed the normal way.\n\n' + repr(text)
|
' displayed the normal way.\n\n' + repr(text)
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ def checkSensitiveFilePermissions(filename):
|
||||||
'Skipping file permissions check for %s.'
|
'Skipping file permissions check for %s.'
|
||||||
' Filesystem fuseblk detected.', filename)
|
' Filesystem fuseblk detected.', filename)
|
||||||
return True
|
return True
|
||||||
except:
|
except: # noqa:E722
|
||||||
# Swallow exception here, but we might run into trouble later!
|
# Swallow exception here, but we might run into trouble later!
|
||||||
logger.error('Could not determine filesystem type. %s', filename)
|
logger.error('Could not determine filesystem type. %s', filename)
|
||||||
present_permissions = os.stat(filename)[0]
|
present_permissions = os.stat(filename)[0]
|
||||||
|
|
Reference in New Issue
Block a user