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