Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/class_singleWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from struct import pack
from subprocess import call # nosec

from six.moves import configparser, queue
from six.moves.reprlib import repr

import defaults
import helper_inbox
import helper_msgcoding
Expand All @@ -28,8 +31,7 @@
from addresses import decodeAddress, decodeVarint, encodeVarint
from bmconfigparser import config
from helper_sql import sqlExecute, sqlQuery
from network import knownnodes, StoppableThread, invQueue
from six.moves import configparser, queue
from network import StoppableThread, invQueue, knownnodes


def sizeof_fmt(num, suffix='h/s'):
Expand Down
7 changes: 4 additions & 3 deletions src/class_smtpDeliver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
# pylint: disable=unused-variable

import smtplib
import urlparse
from email.header import Header
from email.mime.text import MIMEText

from six.moves import email_mime_text
from six.moves.urllib import parse as urlparse

import queues
import state
Expand Down Expand Up @@ -55,7 +56,7 @@ def run(self):
u = urlparse.urlparse(dest)
to = urlparse.parse_qs(u.query)['to']
client = smtplib.SMTP(u.hostname, u.port)
msg = MIMEText(body, 'plain', 'utf-8')
msg = email_mime_text(body, 'plain', 'utf-8')
msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = fromAddress + '@' + SMTPDOMAIN
toLabel = map(
Expand Down
2 changes: 2 additions & 0 deletions src/class_sqlThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import threading
import time

from six.moves.reprlib import repr

try:
import helper_sql
import helper_startup
Expand Down
5 changes: 3 additions & 2 deletions src/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import re
import sys

import six

# Only really old versions of Python don't have sys.hexversion. We don't
# support them. The logging module was introduced in Python 2.3
if not hasattr(sys, 'hexversion') or sys.hexversion < 0x20300F0:
Expand All @@ -18,7 +20,6 @@

import logging # noqa:E402
import subprocess # nosec B404

from importlib import import_module

# We can now use logging so set up a simple configuration
Expand Down Expand Up @@ -438,7 +439,7 @@ def check_dependencies(verbose=False, optional=False):
'PyBitmessage requires Python 2.7.4 or greater'
' (but not Python 3+)')
has_all_dependencies = False
if sys.hexversion >= 0x3000000:
if six.PY3:
logger.error(
'PyBitmessage does not support Python 3+. Python 2.7.4'
' or greater is required. Python 2.7.18 is recommended.')
Expand Down
6 changes: 3 additions & 3 deletions src/l10n.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import logging
import os
import re
import sys
import time

import six
from six.moves import range

from bmconfigparser import config
Expand Down Expand Up @@ -61,7 +61,7 @@

# It seems some systems lie about the encoding they use
# so we perform comprehensive decoding tests
elif sys.version_info[0] == 2:
elif six.PY2:
try:
# Check day names
for i in range(7):
Expand Down Expand Up @@ -118,7 +118,7 @@ def formatTimestamp(timestamp=None):
except ValueError:
timestring = time.strftime(time_format)

if sys.version_info[0] == 2:
if six.PY2:
return timestring.decode(encoding)
return timestring

Expand Down
5 changes: 3 additions & 2 deletions src/namecoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# pylint: disable=too-many-branches,protected-access

import base64
import httplib
import json
import os
import socket
import sys

from six.moves import http_client as httplib

import defaults
from addresses import decodeAddress
from bmconfigparser import config
Expand Down Expand Up @@ -296,7 +297,7 @@ def lookupNamecoinFolder():
"""

app = "namecoin"
from os import path, environ
from os import environ, path
if sys.platform == "darwin":
if "HOME" in environ:
dataFolder = path.join(os.environ["HOME"],
Expand Down
4 changes: 2 additions & 2 deletions src/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import defaults
import highlevelcrypto
import state
from addresses import (
encodeVarint, decodeVarint, decodeAddress, varintDecodeError)
from addresses import (decodeAddress, decodeVarint, encodeVarint,
varintDecodeError)
from bmconfigparser import config
from debug import logger
from helper_sql import sqlExecute
Expand Down
3 changes: 2 additions & 1 deletion src/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import sys
from binascii import hexlify

from six.moves.reprlib import repr

# Project imports.
import highlevelcrypto
import state
Expand All @@ -23,7 +25,6 @@
from debug import logger
from helper_sql import sqlQuery


myECCryptorObjects = {}
MyECSubscriptionCryptorObjects = {}
# The key in this dictionary is the RIPE hash which is encoded
Expand Down
14 changes: 9 additions & 5 deletions src/upnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
Reference: http://mattscodecave.com/posts/using-python-and-upnp-to-forward-a-port
"""

import httplib
import re
import socket
import time
import urllib2
from random import randint
from urlparse import urlparse
from xml.dom.minidom import Document # nosec B408

from defusedxml.minidom import parseString
from six.moves import http_client as httplib
from six.moves.urllib.parse import urlparse
from six.moves.urllib.request import urlopen

import queues
import state
import tr
from bmconfigparser import config
from debug import logger
from network import connectionpool, knownnodes, StoppableThread
from network import StoppableThread, connectionpool, knownnodes
from network.node import Peer


Expand Down Expand Up @@ -108,7 +109,10 @@ def __init__(self, ssdpResponse, address):
logger.error("UPnP: missing location header")

# get the profile xml file and read it into a variable
directory = urllib2.urlopen(header['location']).read()
parsed_url = urlparse(header['location'])
if parsed_url.scheme not in ['http', 'https']:
raise UPnPError("Unsupported URL scheme: %s" % parsed_url.scheme)
directory = urlopen(header['location']).read() # nosec B310

# create a DOM object that represents the `directory` document
dom = parseString(directory)
Expand Down