checking in python3 progress...
This commit is contained in:
parent
309fa40120
commit
83ccc9e39a
|
@ -1,4 +1,6 @@
|
|||
configparser
|
||||
coverage
|
||||
future
|
||||
psutil
|
||||
pycrypto
|
||||
python_prctl
|
||||
|
|
|
@ -471,8 +471,8 @@ class Main:
|
|||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
||||
def usage(self):
|
||||
print 'Usage: ' + sys.argv[0] + ' [OPTIONS]'
|
||||
print '''
|
||||
print('Usage: ' + sys.argv[0] + ' [OPTIONS]')
|
||||
print('''
|
||||
Options:
|
||||
-h, --help show this help message and exit
|
||||
-c, --curses use curses (text mode) interface
|
||||
|
@ -481,6 +481,7 @@ Options:
|
|||
|
||||
All parameters are optional.
|
||||
'''
|
||||
)
|
||||
|
||||
def stop(self):
|
||||
with shared.printLock:
|
||||
|
|
|
@ -16,7 +16,7 @@ standard_library.install_aliases()
|
|||
from builtins import *
|
||||
from PyQt4 import QtCore
|
||||
|
||||
qt_resource_data = "\
|
||||
qt_resource_data = b"\
|
||||
\x00\x00\x03\x66\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
|
@ -1541,7 +1541,7 @@ qt_resource_data = "\
|
|||
\x82\
|
||||
"
|
||||
|
||||
qt_resource_name = "\
|
||||
qt_resource_name = b"\
|
||||
\x00\x09\
|
||||
\x0c\x78\x54\x88\
|
||||
\x00\x6e\
|
||||
|
@ -1646,7 +1646,7 @@ qt_resource_name = "\
|
|||
\x00\x70\x00\x6e\x00\x67\
|
||||
"
|
||||
|
||||
qt_resource_struct = "\
|
||||
qt_resource_struct = b"\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
|
||||
\x00\x00\x00\x18\x00\x02\x00\x00\x00\x15\x00\x00\x00\x03\
|
||||
|
|
|
@ -2,13 +2,20 @@
|
|||
BMConfigParser class definition and default configuration settings
|
||||
"""
|
||||
|
||||
import ConfigParser
|
||||
import shutil
|
||||
import os
|
||||
from configparser import (
|
||||
ConfigParser,
|
||||
InterpolationError,
|
||||
NoOptionError,
|
||||
NoSectionError,
|
||||
)
|
||||
from datetime import datetime
|
||||
import os
|
||||
from past.builtins import basestring
|
||||
import shutil
|
||||
from singleton import Singleton
|
||||
|
||||
import state
|
||||
from singleton import Singleton
|
||||
|
||||
|
||||
BMConfigDefaults = {
|
||||
"bitmessagesettings": {
|
||||
|
@ -42,9 +49,9 @@ BMConfigDefaults = {
|
|||
|
||||
|
||||
@Singleton
|
||||
class BMConfigParser(ConfigParser.SafeConfigParser):
|
||||
"""Singleton class inherited from ConfigParser.SafeConfigParser
|
||||
with additional methods specific to bitmessage config."""
|
||||
class BMConfigParser(ConfigParser):
|
||||
"""Singleton class inherited from ConfigParser with additional methods
|
||||
specific to bitmessage config."""
|
||||
|
||||
def set(self, section, option, value=None):
|
||||
if self._optcre is self.OPTCRE or value:
|
||||
|
@ -52,19 +59,16 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
|
|||
raise TypeError("option values must be strings")
|
||||
if not self.validate(section, option, value):
|
||||
raise ValueError("Invalid value %s" % value)
|
||||
return ConfigParser.ConfigParser.set(self, section, option, value)
|
||||
return ConfigParser.set(self, section, option, value)
|
||||
|
||||
def get(self, section, option, raw=False, variables=None):
|
||||
def get(self, section, option, *args, raw=False, vars=None, **kwargs):
|
||||
try:
|
||||
if section == "bitmessagesettings" and option == "timeformat":
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option, raw, variables)
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option, True, variables)
|
||||
except ConfigParser.InterpolationError:
|
||||
return ConfigParser.ConfigParser.get(
|
||||
self, section, option, True, variables)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
|
||||
return ConfigParser.get(self, section, option, raw=raw, vars=vars)
|
||||
return ConfigParser.get(self, section, option, raw=True, vars=vars)
|
||||
except InterpolationError:
|
||||
return ConfigParser.get(self, section, option, raw=True, vars=vars)
|
||||
except (NoSectionError, NoOptionError) as e:
|
||||
try:
|
||||
return BMConfigDefaults[section][option]
|
||||
except (KeyError, ValueError, AttributeError):
|
||||
|
@ -73,47 +77,45 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
|
|||
def safeGetBoolean(self, section, field):
|
||||
try:
|
||||
return self.getboolean(section, field)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
|
||||
ValueError, AttributeError):
|
||||
except (NoSectionError, NoOptionError, ValueError, AttributeError):
|
||||
return False
|
||||
|
||||
def safeGetInt(self, section, field, default=0):
|
||||
try:
|
||||
return self.getint(section, field)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
|
||||
except (NoSectionError, NoOptionError,
|
||||
ValueError, AttributeError):
|
||||
return default
|
||||
|
||||
def safeGet(self, section, option, default=None):
|
||||
try:
|
||||
return self.get(section, option)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError,
|
||||
except (NoSectionError, NoOptionError,
|
||||
ValueError, AttributeError):
|
||||
return default
|
||||
|
||||
def items(self, section, raw=False, variables=None):
|
||||
return ConfigParser.ConfigParser.items(self, section, True, variables)
|
||||
def items(self, section, vars=None, **kwargs):
|
||||
return ConfigParser.items(self, section, raw=True, vars=vars)
|
||||
|
||||
def addresses(self):
|
||||
return filter(
|
||||
lambda x: x.startswith('BM-'), BMConfigParser().sections())
|
||||
|
||||
def read(self, filenames):
|
||||
ConfigParser.ConfigParser.read(self, filenames)
|
||||
ConfigParser.read(self, filenames)
|
||||
for section in self.sections():
|
||||
for option in self.options(section):
|
||||
try:
|
||||
if not self.validate(
|
||||
section, option,
|
||||
ConfigParser.ConfigParser.get(self, section, option)
|
||||
self.get(section, option)
|
||||
):
|
||||
try:
|
||||
newVal = BMConfigDefaults[section][option]
|
||||
except KeyError:
|
||||
continue
|
||||
ConfigParser.ConfigParser.set(
|
||||
self, section, option, newVal)
|
||||
except ConfigParser.InterpolationError:
|
||||
self.set(section, option, newVal)
|
||||
except InterpolationError:
|
||||
continue
|
||||
|
||||
def save(self):
|
||||
|
@ -131,7 +133,7 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
|
|||
# didn't exist before.
|
||||
fileNameExisted = False
|
||||
# write the file
|
||||
with open(fileName, 'wb') as configfile:
|
||||
with open(fileName, 'w') as configfile:
|
||||
self.write(configfile)
|
||||
# delete the backup
|
||||
if fileNameExisted:
|
||||
|
|
|
@ -22,8 +22,7 @@ Use: `from debug import logger` to import this facility into whatever module you
|
|||
Logging is thread-safe so you don't have to worry about locks, just import and log.
|
||||
|
||||
"""
|
||||
|
||||
import ConfigParser
|
||||
import configparser
|
||||
import logging
|
||||
import logging.config
|
||||
import os
|
||||
|
@ -53,7 +52,7 @@ def configureLogging():
|
|||
False,
|
||||
'Loaded logger configuration from %s' % logging_config
|
||||
)
|
||||
except (OSError, ConfigParser.NoSectionError):
|
||||
except (KeyError, OSError, configparser.NoSectionError):
|
||||
if os.path.isfile(logging_config):
|
||||
fail_msg = \
|
||||
'Failed to load logger configuration from %s, using default' \
|
||||
|
|
|
@ -299,7 +299,7 @@ def check_openssl():
|
|||
' OpenSSL 0.9.8b or later with AES, Elliptic Curves (EC),'
|
||||
' ECDH, and ECDSA enabled.')
|
||||
return False
|
||||
matches = cflags_regex.findall(openssl_cflags)
|
||||
matches = cflags_regex.findall(openssl_cflags.decode())
|
||||
if len(matches) > 0:
|
||||
logger.error(
|
||||
'This OpenSSL library is missing the following required'
|
||||
|
@ -408,19 +408,12 @@ def check_dependencies(verbose=False, optional=False):
|
|||
|
||||
# Python 2.7.4 is the required minimum.
|
||||
# (https://bitmessage.org/forum/index.php?topic=4081.0)
|
||||
# Python 3+ is not supported, but it is still useful to provide
|
||||
# information about our other requirements.
|
||||
logger.info('Python version: %s', sys.version)
|
||||
if sys.hexversion < 0x20704F0:
|
||||
logger.error(
|
||||
'PyBitmessage requires Python 2.7.4 or greater'
|
||||
' (but not Python 3+)')
|
||||
has_all_dependencies = False
|
||||
if sys.hexversion >= 0x3000000:
|
||||
logger.error(
|
||||
'PyBitmessage does not support Python 3+. Python 2.7.4'
|
||||
' or greater is required.')
|
||||
has_all_dependencies = False
|
||||
|
||||
check_functions = [check_ripemd160, check_sqlite, check_openssl]
|
||||
if optional:
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""Helper Sql performs sql operations."""
|
||||
|
||||
import threading
|
||||
import Queue
|
||||
from queue import Queue
|
||||
|
||||
sqlSubmitQueue = Queue.Queue()
|
||||
sqlSubmitQueue = Queue()
|
||||
# SQLITE3 is so thread-unsafe that they won't even let you call it from different threads using your own locks.
|
||||
# SQL objects #can only be called from one thread.
|
||||
sqlReturnQueue = Queue.Queue()
|
||||
sqlReturnQueue = Queue()
|
||||
sqlLock = threading.Lock()
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Helper Start performs all the startup operations.
|
|||
# pylint: disable=too-many-branches,too-many-statements
|
||||
from __future__ import print_function
|
||||
|
||||
import ConfigParser
|
||||
import configparser
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
@ -27,7 +27,7 @@ StoreConfigFilesInSameDirectoryAsProgramByDefault = False
|
|||
def _loadTrustedPeer():
|
||||
try:
|
||||
trustedPeer = BMConfigParser().get('bitmessagesettings', 'trustedpeer')
|
||||
except ConfigParser.Error:
|
||||
except configparser.Error:
|
||||
# This probably means the trusted peer wasn't specified so we
|
||||
# can just leave it as None
|
||||
return
|
||||
|
|
|
@ -35,7 +35,7 @@ def lookupAppdataFolder():
|
|||
if 'logger' in globals():
|
||||
logger.critical(stringToLog)
|
||||
else:
|
||||
print stringToLog
|
||||
print(stringToLog)
|
||||
sys.exit()
|
||||
|
||||
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
|
@ -54,7 +54,7 @@ def lookupAppdataFolder():
|
|||
if 'logger' in globals():
|
||||
logger.info(stringToLog)
|
||||
else:
|
||||
print stringToLog
|
||||
print(stringToLog)
|
||||
except IOError:
|
||||
# Old directory may not exist.
|
||||
pass
|
||||
|
|
|
@ -82,7 +82,7 @@ class _OpenSSL(object):
|
|||
"""
|
||||
self._lib = ctypes.CDLL(library)
|
||||
self._version, self._hexversion, self._cflags = get_version(self._lib)
|
||||
self._libreSSL = self._version.startswith("LibreSSL")
|
||||
self._libreSSL = self._version.startswith(b"LibreSSL")
|
||||
|
||||
self.pointer = ctypes.pointer
|
||||
self.c_int = ctypes.c_int
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import queue
|
||||
import os
|
||||
import Queue
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
@ -73,7 +73,7 @@ def doCleanShutdown():
|
|||
try:
|
||||
queue.get(False)
|
||||
queue.task_done()
|
||||
except Queue.Empty:
|
||||
except queue.Empty:
|
||||
break
|
||||
|
||||
if shared.thisapp.daemon or not state.enableGUI: # FIXME redundant?
|
||||
|
|
|
@ -74,7 +74,7 @@ class singleinstance:
|
|||
fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
self.lockPid = os.getpid()
|
||||
except IOError:
|
||||
print 'Another instance of this application is already running'
|
||||
print('Another instance of this application is already running')
|
||||
sys.exit(-1)
|
||||
else:
|
||||
pidLine = "%i\n" % self.lockPid
|
||||
|
@ -93,11 +93,11 @@ class singleinstance:
|
|||
os.close(self.fd)
|
||||
else:
|
||||
fcntl.lockf(self.fp, fcntl.LOCK_UN)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return
|
||||
print "Cleaning up lockfile"
|
||||
print("Cleaning up lockfile")
|
||||
try:
|
||||
if sys.platform == 'win32':
|
||||
if hasattr(self, 'fd'):
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
|
||||
"""SocksiPy - Python SOCKS module.
|
||||
Version 1.00
|
||||
|
||||
|
@ -40,10 +45,6 @@ Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/)
|
|||
mainly to merge bug fixes found in Sourceforge
|
||||
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
|
|
Loading…
Reference in New Issue
Block a user