Commit d9471e2e authored by Julien Muchembled's avatar Julien Muchembled

Use relative imports inside each virtual package

parent 0ad980c8
......@@ -21,7 +21,7 @@ from neo.lib.node import NodeManager
from neo.lib.event import EventManager
from neo.lib.connection import ListeningConnection
from neo.lib.exception import PrimaryFailure
from neo.admin.handler import AdminEventHandler, MasterEventHandler, \
from .handler import AdminEventHandler, MasterEventHandler, \
MasterRequestEventHandler
from neo.lib.connector import getConnectorHandler
from neo.lib.bootstrap import BootstrapManager
......
......@@ -24,9 +24,8 @@ from functools import wraps
from neo.lib import setupLog
from neo.lib.util import add64
from neo.lib.protocol import ZERO_TID
from neo.client.app import Application
from neo.client.exception import NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
from .app import Application
from .exception import NEOStorageNotFoundError, NEOStorageDoesNotExistError
def check_read_only(func):
def wrapped(self, *args, **kw):
......
......@@ -36,19 +36,19 @@ from neo.lib.locking import Lock
from neo.lib.connection import MTClientConnection, OnTimeout, ConnectionClosed
from neo.lib.node import NodeManager
from neo.lib.connector import getConnectorHandler
from neo.client.exception import NEOStorageError, NEOStorageCreationUndoneError
from neo.client.exception import NEOStorageNotFoundError
from .exception import NEOStorageError, NEOStorageCreationUndoneError
from .exception import NEOStorageNotFoundError
from neo.lib.exception import NeoException
from neo.client.handlers import storage, master
from .handlers import storage, master
from neo.lib.dispatcher import Dispatcher, ForgottenPacket
from neo.client.poll import ThreadedPoll, psThreadedPoll
from neo.client.iterator import Iterator
from neo.client.cache import ClientCache
from neo.client.pool import ConnectionPool
from .poll import ThreadedPoll, psThreadedPoll
from .iterator import Iterator
from .cache import ClientCache
from .pool import ConnectionPool
from neo.lib.util import u64, parseMasterList
from neo.lib.profiling import profiler_decorator, PROFILING_ENABLED
from neo.lib.debug import register as registerLiveDebugger
from neo.client.container import ThreadContainer, TransactionContainer
from .container import ThreadContainer, TransactionContainer
if PROFILING_ENABLED:
# Those functions require a "real" python function wrapper before they can
......
......@@ -20,7 +20,7 @@ from ZODB.config import BaseConfig
class NeoStorage(BaseConfig):
def open(self):
from neo.client.Storage import Storage
from .Storage import Storage
config = self.config
return Storage(**dict((k, getattr(config, k))
for k in config.getSectionAttributes()))
......@@ -16,12 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import neo.lib
from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.lib.pt import MTPartitionTable as PartitionTable
from neo.lib.protocol import NodeTypes, NodeStates, ProtocolError
from neo.lib.util import dump
from neo.client.exception import NEOStorageError
from . import BaseHandler, AnswerBaseHandler
from ..exception import NEOStorageError
class PrimaryBootstrapHandler(AnswerBaseHandler):
""" Bootstrap handler used when looking for the primary master """
......
......@@ -19,12 +19,12 @@ from ZODB.TimeStamp import TimeStamp
from ZODB.POSException import ConflictError
import neo.lib
from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.lib.protocol import NodeTypes, ProtocolError, LockState, ZERO_TID
from neo.lib.util import dump
from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
from neo.lib.exception import NodeNotReady
from . import BaseHandler, AnswerBaseHandler
from ..exception import NEOStorageError, NEOStorageNotFoundError
from ..exception import NEOStorageDoesNotExistError
class StorageEventHandler(BaseHandler):
......
......@@ -19,8 +19,7 @@ from ZODB import BaseStorage
from zope.interface import implements
import ZODB.interfaces
from neo.lib.util import u64, add64
from neo.client.exception import NEOStorageCreationUndoneError
from neo.client.exception import NEOStorageNotFoundError
from .exception import NEOStorageCreationUndoneError, NEOStorageNotFoundError
CHUNK_LENGTH = 100
......
......@@ -22,9 +22,9 @@ import neo.lib
from neo.lib.locking import RLock
from neo.lib.protocol import NodeTypes, Packets
from neo.lib.connection import MTClientConnection, ConnectionClosed
from neo.client.exception import NEOStorageError
from neo.lib.profiling import profiler_decorator
from neo.lib.exception import NodeNotReady
from .exception import NEOStorageError
# How long before we might retry a connection to a node to which connection
# failed in the past.
......
......@@ -17,7 +17,7 @@
ATTRIBUTE_TRACKER_ENABLED = False
from neo.lib.locking import LockUser
from .locking import LockUser
"""
Usage example:
......
......@@ -18,10 +18,10 @@
import neo
from time import sleep
from neo.lib.handler import EventHandler
from neo.lib.protocol import Packets
from neo.lib.util import dump
from neo.lib.connection import ClientConnection
from .handler import EventHandler
from .protocol import Packets
from .util import dump
from .connection import ClientConnection
NO_SERVER = ('0.0.0.0', 0)
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from ConfigParser import SafeConfigParser
from neo.lib import util
from neo.lib.util import parseNodeAddress
from . import util
from .util import parseNodeAddress
class ConfigurationManager(object):
"""
......
......@@ -19,18 +19,15 @@ from functools import wraps
from time import time
import neo.lib
from neo.lib.locking import RLock
from neo.lib.protocol import PacketMalformedError, Packets, ParserState
from neo.lib.connector import ConnectorException, ConnectorTryAgainException, \
from . import attributeTracker
from .connector import ConnectorException, ConnectorTryAgainException, \
ConnectorInProgressException, ConnectorConnectionRefusedException, \
ConnectorConnectionClosedException
from neo.lib.util import dump
from neo.lib.logger import PACKET_LOGGER
from neo.lib import attributeTracker
from neo.lib.util import ReadBuffer
from neo.lib.profiling import profiler_decorator
from .locking import RLock
from .logger import PACKET_LOGGER
from .profiling import profiler_decorator
from .protocol import PacketMalformedError, Packets, ParserState
from .util import dump, ReadBuffer
CRITICAL_TIMEOUT = 30
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from functools import wraps
from neo.lib.locking import Lock, Empty
from neo.lib.profiling import profiler_decorator
from .locking import Lock, Empty
from .profiling import profiler_decorator
EMPTY = {}
NOBODY = []
......
......@@ -17,8 +17,8 @@
from time import time
import neo.lib
from neo.lib.epoll import Epoll
from neo.lib.profiling import profiler_decorator
from .epoll import Epoll
from .profiling import profiler_decorator
class EpollEventManager(object):
"""This class manages connections and events based on epoll(5)."""
......
......@@ -16,9 +16,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import neo.lib
from neo.lib.protocol import NodeStates, ErrorCodes, Packets, Errors
from neo.lib.protocol import PacketMalformedError, UnexpectedPacketError, \
BrokenNodeDisallowedError, NotReadyError, ProtocolError
from .protocol import (
NodeStates, Packets, ErrorCodes, Errors, BrokenNodeDisallowedError,
NotReadyError, PacketMalformedError, ProtocolError, UnexpectedPacketError)
class EventHandler(object):
......
......@@ -17,10 +17,10 @@
from base64 import b64encode
import neo
from neo.lib.protocol import PacketMalformedError
from neo.lib.util import dump
from neo.lib.handler import EventHandler
from neo.lib.profiling import profiler_decorator
from .protocol import PacketMalformedError
from .util import dump
from .handler import EventHandler
from .profiling import profiler_decorator
LOGGER_ENABLED = False
......
......@@ -18,10 +18,10 @@
from time import time
import neo.lib
from neo.lib.util import dump
from neo.lib.protocol import NodeTypes, NodeStates
from .util import dump
from .protocol import NodeTypes, NodeStates
from neo.lib import attributeTracker
from . import attributeTracker
class Node(object):
"""This class represents a node."""
......
......@@ -22,7 +22,7 @@ from socket import inet_ntoa, inet_aton
from cStringIO import StringIO
from struct import Struct
from neo.lib.util import Enum, getAddressType
from .util import Enum, getAddressType
# The protocol version (major, minor).
PROTOCOL_VERSION = (4, 1)
......
......@@ -18,10 +18,10 @@
from functools import wraps
import neo
from neo.lib import protocol
from neo.lib.protocol import CellStates
from neo.lib.util import dump, u64
from neo.lib.locking import RLock
from . import protocol
from .protocol import CellStates
from .util import dump, u64
from .locking import RLock
class PartitionTableException(Exception):
"""
......
......@@ -20,23 +20,22 @@ import os, sys
from time import time
from neo.lib import protocol
from neo.lib.connector import getConnectorHandler
from neo.lib.debug import register as registerLiveDebugger
from neo.lib.protocol import UUID_NAMESPACES, ZERO_TID
from neo.lib.protocol import ClusterStates, NodeStates, NodeTypes, Packets
from neo.lib.node import NodeManager
from neo.lib.event import EventManager
from neo.lib.connection import ListeningConnection, ClientConnection
from neo.lib.exception import ElectionFailure, PrimaryFailure, OperationFailure
from neo.master.handlers import election, identification, secondary
from neo.master.handlers import storage, client, shutdown
from neo.master.handlers import administration
from neo.master.pt import PartitionTable
from neo.master.transactions import TransactionManager
from neo.master.verification import VerificationManager
from neo.master.recovery import RecoveryManager
from neo.lib.util import dump
from neo.lib.connector import getConnectorHandler
from .handlers import election, identification, secondary
from .handlers import administration, client, storage, shutdown
from .pt import PartitionTable
from .recovery import RecoveryManager
from .transactions import TransactionManager
from .verification import VerificationManager
from neo.lib.debug import register as registerLiveDebugger
class Application(object):
"""The master node application."""
......
......@@ -17,7 +17,7 @@
import neo
from neo.master.handlers import MasterHandler
from . import MasterHandler
from neo.lib.protocol import ClusterStates, NodeStates, Packets, ProtocolError
from neo.lib.protocol import Errors
from neo.lib.util import dump
......
......@@ -16,11 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import neo.lib
from neo.lib.protocol import NodeStates, Packets, ProtocolError
from neo.master.handlers import MasterHandler
from neo.lib.util import dump
from neo.master.transactions import DelayedError
from . import MasterHandler
from ..transactions import DelayedError
class ClientServiceHandler(MasterHandler):
""" Handler dedicated to client during service state """
......
......@@ -21,9 +21,9 @@ from neo.lib.protocol import NodeTypes, NodeStates, Packets
from neo.lib.protocol import NotReadyError, ProtocolError, \
UnexpectedPacketError
from neo.lib.protocol import BrokenNodeDisallowedError
from neo.master.handlers import MasterHandler
from neo.lib.exception import ElectionFailure
from neo.lib.util import dump
from . import MasterHandler
class ClientElectionHandler(MasterHandler):
......
......@@ -19,7 +19,7 @@ import neo
from neo.lib.protocol import NodeTypes, Packets
from neo.lib.protocol import BrokenNodeDisallowedError, ProtocolError
from neo.master.handlers import MasterHandler
from . import MasterHandler
class IdentificationHandler(MasterHandler):
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.master.handlers import MasterHandler
from . import MasterHandler
from neo.lib.exception import ElectionFailure, PrimaryFailure
from neo.lib.protocol import NodeTypes, Packets
......
......@@ -17,7 +17,7 @@
import neo.lib
from neo.lib import protocol
from neo.master.handlers import BaseServiceHandler
from . import BaseServiceHandler
class ShutdownHandler(BaseServiceHandler):
"""This class deals with events for a shutting down phase."""
......
......@@ -16,14 +16,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import neo.lib
from neo.lib.protocol import ProtocolError
from neo.lib.protocol import Packets
from neo.master.handlers import BaseServiceHandler
from neo.lib.protocol import Packets, ProtocolError
from neo.lib.exception import OperationFailure
from neo.lib.util import dump
from neo.lib.connector import ConnectorConnectionClosedException
from neo.lib.pt import PartitionTableException
from . import BaseServiceHandler
class StorageServiceHandler(BaseServiceHandler):
......
......@@ -21,7 +21,7 @@ import neo
from neo.lib.util import dump
from neo.lib.protocol import Packets, ProtocolError, ClusterStates, NodeStates
from neo.lib.protocol import NotReadyError, ZERO_OID, ZERO_TID
from neo.master.handlers import MasterHandler
from .handlers import MasterHandler
class RecoveryManager(MasterHandler):
......
......@@ -18,7 +18,7 @@
import neo
from neo.lib.util import dump
from neo.lib.protocol import ClusterStates, Packets, NodeStates
from neo.master.handlers import BaseServiceHandler
from .handlers import BaseServiceHandler
class VerificationFailure(Exception):
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.neoctl.neoctl import NeoCTL, NotReadyException
from .neoctl import NeoCTL, NotReadyException
from neo.lib.util import bin, dump
from neo.lib.protocol import ClusterStates, NodeStates, NodeTypes
......
......@@ -18,9 +18,9 @@
from neo.lib.connector import getConnectorHandler
from neo.lib.connection import ClientConnection
from neo.lib.event import EventManager
from neo.neoctl.handler import CommandEventHandler
from neo.lib.protocol import ClusterStates, NodeStates, ErrorCodes, Packets
from neo.lib.util import getConnectorFromAddress
from .handler import CommandEventHandler
class NotReadyException(Exception):
pass
......
......@@ -24,16 +24,16 @@ from neo.lib.node import NodeManager
from neo.lib.event import EventManager
from neo.lib.connection import ListeningConnection
from neo.lib.exception import OperationFailure, PrimaryFailure
from neo.storage.handlers import identification, verification, initialization
from neo.storage.handlers import master, hidden
from neo.storage.replicator import Replicator
from neo.storage.database import buildDatabaseManager
from neo.storage.transactions import TransactionManager
from neo.storage.exception import AlreadyPendingError
from neo.lib.connector import getConnectorHandler
from neo.lib.pt import PartitionTable
from neo.lib.util import dump
from neo.lib.bootstrap import BootstrapManager
from .database import buildDatabaseManager
from .exception import AlreadyPendingError
from .handlers import identification, verification, initialization
from .handlers import master, hidden
from .replicator import Replicator
from .transactions import TransactionManager
from neo.lib.debug import register as registerLiveDebugger
......
......@@ -16,19 +16,19 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.lib.exception import DatabaseFailure
from neo.storage.database.manager import DatabaseManager
from .manager import DatabaseManager
DATABASE_MANAGER_DICT = {}
try:
from neo.storage.database.mysqldb import MySQLDatabaseManager
from .mysqldb import MySQLDatabaseManager
except ImportError:
pass
else:
DATABASE_MANAGER_DICT['MySQL'] = MySQLDatabaseManager
try:
from neo.storage.database.btree import BTreeDatabaseManager
from .btree import BTreeDatabaseManager
except ImportError:
pass
else:
......
......@@ -24,8 +24,8 @@ from BTrees.OOBTree import OOBTree as _OOBTree
import neo.lib
from hashlib import sha1
from neo.storage.database import DatabaseManager
from neo.storage.database.manager import CreationUndone
from . import DatabaseManager
from .manager import CreationUndone
from neo.lib.protocol import CellStates, ZERO_HASH, ZERO_OID, ZERO_TID
from neo.lib import util
......
......@@ -26,8 +26,8 @@ from hashlib import sha1
import re
import string
from neo.storage.database import DatabaseManager
from neo.storage.database.manager import CreationUndone
from . import DatabaseManager
from .manager import CreationUndone
from neo.lib.exception import DatabaseFailure
from neo.lib.protocol import CellStates, ZERO_OID, ZERO_TID, ZERO_HASH
from neo.lib import util
......
......@@ -19,9 +19,9 @@ import neo.lib
from neo.lib import protocol
from neo.lib.util import dump, makeChecksum
from neo.lib.protocol import Packets, LockState, Errors, ZERO_HASH
from neo.storage.handlers import BaseClientAndStorageOperationHandler
from neo.storage.transactions import ConflictError, DelayedError
from neo.storage.exception import AlreadyPendingError
from . import BaseClientAndStorageOperationHandler
from ..transactions import ConflictError, DelayedError
from ..exception import AlreadyPendingError
import time
# Log stores taking (incl. lock delays) more than this many seconds.
......
......@@ -17,7 +17,7 @@
import neo.lib
from neo.storage.handlers import BaseMasterHandler
from . import BaseMasterHandler
from neo.lib.protocol import CellStates
class HiddenHandler(BaseMasterHandler):
......
......@@ -41,7 +41,7 @@ class IdentificationHandler(EventHandler):
raise BrokenNodeDisallowedError
# choose the handler according to the node type
if node_type == NodeTypes.CLIENT:
from neo.storage.handlers.client import ClientOperationHandler
from .client import ClientOperationHandler
handler = ClientOperationHandler
if node is None:
node = app.nm.createClient()
......@@ -51,7 +51,7 @@ class IdentificationHandler(EventHandler):
assert not node.isConnected()
node.setRunning()
elif node_type == NodeTypes.STORAGE:
from neo.storage.handlers.storage import StorageOperationHandler
from .storage import StorageOperationHandler
handler = StorageOperationHandler
if node is None:
neo.lib.logging.error('reject an unknown storage node %s',
......
......@@ -17,7 +17,7 @@
import neo.lib
from neo.storage.handlers import BaseMasterHandler
from . import BaseMasterHandler
from neo.lib import protocol
class InitializationHandler(BaseMasterHandler):
......
......@@ -18,7 +18,7 @@
import neo.lib
from neo.lib.util import dump
from neo.lib.protocol import CellStates, Packets, ProtocolError
from neo.storage.handlers import BaseMasterHandler
from . import BaseMasterHandler
class MasterOperationHandler(BaseMasterHandler):
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.storage.handlers import BaseClientAndStorageOperationHandler
from . import BaseClientAndStorageOperationHandler
from neo.lib.protocol import Packets
class StorageOperationHandler(BaseClientAndStorageOperationHandler):
......
......@@ -17,7 +17,7 @@
import neo
from neo.storage.handlers import BaseMasterHandler
from . import BaseMasterHandler
from neo.lib.protocol import Packets, Errors, ProtocolError, INVALID_TID
from neo.lib.util import dump
from neo.lib.exception import OperationFailure
......
......@@ -18,7 +18,7 @@
import neo.lib
from random import choice
from neo.storage.handlers import replication
from .handlers import replication
from neo.lib.protocol import NodeTypes, NodeStates, Packets
from neo.lib.connection import ClientConnection
from neo.lib.util import dump
......
......@@ -19,7 +19,7 @@ import unittest
from cPickle import dumps
from mock import Mock, ReturnValues
from ZODB.POSException import StorageTransactionError, UndoError, ConflictError
from neo.tests import NeoUnitTestBase, buildUrlFromString, ADDRESS_TYPE
from .. import NeoUnitTestBase, buildUrlFromString, ADDRESS_TYPE
from neo.client.app import Application
from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
......@@ -784,7 +784,7 @@ class ClientApplicationTests(NeoUnitTestBase):
# the third will not be ready
# after the third, the partition table will be operational
# (as if it was connected to the primary master node)
from neo.tests import DoNothingConnector
from .. import DoNothingConnector
# will raise IndexError at the third iteration
app = self.getApp('127.0.0.1:10010 127.0.0.1:10011')
# TODO: test more connection failure cases
......
......@@ -18,7 +18,7 @@
import unittest
from mock import Mock, ReturnValues
from neo.tests import NeoUnitTestBase
from .. import NeoUnitTestBase
from neo.client.app import ConnectionPool
from neo.client.exception import NEOStorageError
......
......@@ -17,7 +17,7 @@
import unittest
from mock import Mock
from neo.tests import NeoUnitTestBase
from .. import NeoUnitTestBase
from neo.lib.pt import PartitionTable
from neo.lib.protocol import NodeTypes, NodeStates
from neo.client.handlers.master import PrimaryBootstrapHandler
......
......@@ -17,7 +17,7 @@
import unittest
from mock import Mock
from neo.tests import NeoUnitTestBase
from .. import NeoUnitTestBase
from neo.lib.protocol import NodeTypes, LockState
from neo.client.handlers.storage import StorageBootstrapHandler, \
StorageAnswersHandler
......
......@@ -36,9 +36,9 @@ from neo.neoctl.neoctl import NeoCTL, NotReadyException
from neo.lib import setupLog
from neo.lib.protocol import ClusterStates, NodeTypes, CellStates, NodeStates
from neo.lib.util import dump
from neo.tests import DB_USER, setupMySQLdb, NeoTestBase, buildUrlFromString, \
from .. import DB_USER, setupMySQLdb, NeoTestBase, buildUrlFromString, \
ADDRESS_TYPE, IP_VERSION_FORMAT_DICT, getTempDirectory
from neo.tests.cluster import SocketLock
from ..cluster import SocketLock
from neo.client.Storage import Storage
NEO_MASTER = 'neomaster'
......
......@@ -28,8 +28,8 @@ from ZODB.POSException import ConflictError
from ZODB.tests.StorageTestBase import zodb_pickle
from persistent import Persistent
from neo.lib.util import SOCKET_CONNECTORS_DICT
from neo.tests.functional import NEOCluster, NEOFunctionalTest
from neo.tests import IP_VERSION_FORMAT_DICT
from . import NEOCluster, NEOFunctionalTest
from .. import IP_VERSION_FORMAT_DICT
TREE_SIZE = 6
......
......@@ -19,7 +19,7 @@ import unittest
import transaction
from persistent import Persistent
from neo.tests.functional import NEOCluster, NEOFunctionalTest
from . import NEOCluster, NEOFunctionalTest
class ClusterTests(NEOFunctionalTest):
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import unittest
from neo.tests.functional import NEOCluster, NEOFunctionalTest
from . import NEOCluster, NEOFunctionalTest
from neo.lib.protocol import NodeStates
MASTER_NODE_COUNT = 3
......
......@@ -20,7 +20,7 @@ import unittest
import transaction
from persistent import Persistent
from neo.tests.functional import NEOCluster, NEOFunctionalTest
from . import NEOCluster, NEOFunctionalTest
from neo.lib.protocol import ClusterStates, NodeStates
from ZODB.tests.StorageTestBase import zodb_pickle
from MySQLdb import ProgrammingError
......
......@@ -18,7 +18,7 @@
import unittest
from mock import Mock
from struct import pack, unpack
from neo.tests import NeoUnitTestBase