Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

Remove pyhdb imports #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions pyhdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import os

from pyhdb.exceptions import *
from pyhdb.connection import Connection
from pyhdb.protocol.lobs import Blob, Clob, NClob
from pyhdb.compat import configparser
from .exceptions import *
from .connection import Connection
from .protocol.lobs import Blob, Clob, NClob
from .compat import configparser

apilevel = "2.0"
threadsafety = 2
Expand Down
10 changes: 5 additions & 5 deletions pyhdb/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import hmac
from io import BytesIO
###
from pyhdb.protocol.segments import RequestSegment
from pyhdb.protocol.constants import message_types
from pyhdb.protocol.parts import Authentication, Fields
from pyhdb.protocol.message import RequestMessage
from pyhdb.compat import iter_range
from .protocol.segments import RequestSegment
from .protocol.constants import message_types
from .protocol.parts import Authentication, Fields
from .protocol.message import RequestMessage
from .compat import iter_range

CLIENT_PROOF_SIZE = 32
CLIENT_KEY_SIZE = 64
Expand Down
2 changes: 1 addition & 1 deletion pyhdb/cesu8.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import codecs
from pyhdb.compat import PY2, unichr
from .compat import PY2, unichr


class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
Expand Down
16 changes: 8 additions & 8 deletions pyhdb/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import threading
import logging
###
from pyhdb.auth import AuthManager
from pyhdb.cursor import Cursor
from pyhdb.exceptions import Error, OperationalError, ConnectionTimedOutError
from pyhdb.protocol.segments import RequestSegment
from pyhdb.protocol.message import RequestMessage, ReplyMessage
from pyhdb.protocol.parts import ClientId, ConnectOptions
from pyhdb.protocol.constants import message_types, function_codes, DEFAULT_CONNECTION_OPTIONS
from .auth import AuthManager
from .cursor import Cursor
from .exceptions import Error, OperationalError, ConnectionTimedOutError
from .protocol.segments import RequestSegment
from .protocol.message import RequestMessage, ReplyMessage
from .protocol.parts import ClientId, ConnectOptions
from .protocol.constants import message_types, function_codes, DEFAULT_CONNECTION_OPTIONS

INITIALIZATION_BYTES = bytearray([
255, 255, 255, 255, 4, 20, 0, 4, 1, 0, 0, 1, 1, 1
Expand Down Expand Up @@ -97,7 +97,7 @@ def __send_message_recv_reply(self, packed_message):
raw_header = self._socket.recv(32)
header = ReplyMessage.header_from_raw_header_data(raw_header)

# from pyhdb.lib.stringlib import allhexlify
# from lib.stringlib import allhexlify
# print 'Raw msg header:', allhexlify(raw_header)
msg = 'Message header (32 bytes): sessionid: %d, packetcount: %d, length: %d, size: %d, noofsegm: %d'
debug(msg, *(header[:5]))
Expand Down
14 changes: 7 additions & 7 deletions pyhdb/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

import collections
###
from pyhdb.protocol.message import RequestMessage
from pyhdb.protocol.segments import RequestSegment
from pyhdb.protocol.types import escape_values, by_type_code
from pyhdb.protocol.parts import Command, FetchSize, ResultSetId, StatementId, Parameters, WriteLobRequest
from pyhdb.protocol.constants import message_types, function_codes, part_kinds
from pyhdb.exceptions import ProgrammingError, InterfaceError, DatabaseError
from pyhdb.compat import izip
from .protocol.message import RequestMessage
from .protocol.segments import RequestSegment
from .protocol.types import escape_values, by_type_code
from .protocol.parts import Command, FetchSize, ResultSetId, StatementId, Parameters, WriteLobRequest
from .protocol.constants import message_types, function_codes, part_kinds
from .exceptions import ProgrammingError, InterfaceError, DatabaseError
from .compat import izip

FORMAT_OPERATION_ERRORS = [
'not enough arguments for format string',
Expand Down
2 changes: 1 addition & 1 deletion pyhdb/lib/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from __future__ import print_function
import io
import pyhdb
from pyhdb.compat import StringIO
from ..compat import StringIO


def trace(trace_obj):
Expand Down
2 changes: 1 addition & 1 deletion pyhdb/protocol/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"data_format_version2": 1
}

from pyhdb.protocol.constants.general import MAX_MESSAGE_SIZE, MAX_SEGMENT_SIZE
from .general import MAX_MESSAGE_SIZE, MAX_SEGMENT_SIZE
2 changes: 1 addition & 1 deletion pyhdb/protocol/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import collections
import struct
###
from pyhdb.protocol.constants import type_codes
from .constants import type_codes


MessageHeader = collections.namedtuple(
Expand Down
12 changes: 6 additions & 6 deletions pyhdb/protocol/lobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import logging
from os import SEEK_SET, SEEK_CUR, SEEK_END

from pyhdb.protocol.headers import ReadLobHeader
from pyhdb.protocol.message import RequestMessage
from pyhdb.protocol.segments import RequestSegment
from pyhdb.protocol.constants import message_types, type_codes
from pyhdb.protocol.parts import ReadLobRequest
from pyhdb.compat import PY2, PY26, PY3, byte_type, StringIO
from .headers import ReadLobHeader
from .message import RequestMessage
from .segments import RequestSegment
from .constants import message_types, type_codes
from .parts import ReadLobRequest
from ..compat import PY2, PY26, PY3, byte_type, StringIO

if PY2:
# Depending on the Python version we use different underlying containers for CLOB strings
Expand Down
13 changes: 7 additions & 6 deletions pyhdb/protocol/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import struct
from os import SEEK_SET, SEEK_CUR, SEEK_END
###
from pyhdb.protocol import constants
from pyhdb.protocol.headers import MessageHeader
from pyhdb.protocol.segments import ReplySegment
from pyhdb.lib.tracing import trace
from .constants.general import MESSAGE_HEADER_SIZE
from .constants import MAX_SEGMENT_SIZE
from .headers import MessageHeader
from .segments import ReplySegment
from ..lib.tracing import trace


class BaseMessage(object):
Expand All @@ -28,7 +29,7 @@ class BaseMessage(object):
"""
header_struct = struct.Struct('qiIIhb9x') # I8 I4 UI4 UI4 I2 I1 x[9]
header_size = header_struct.size
assert header_size == constants.general.MESSAGE_HEADER_SIZE # Ensures that the constant defined there is correct!
assert header_size == MESSAGE_HEADER_SIZE # Ensures that the constant defined there is correct!
__tracing_attrs__ = ['header', 'segments']

def __init__(self, session_id, packet_count, segments=(), autocommit=False, header=None):
Expand Down Expand Up @@ -56,7 +57,7 @@ def pack(self):
self.build_payload(payload)

packet_length = len(payload.getvalue()) - self.header_size
self.header = MessageHeader(self.session_id, self.packet_count, packet_length, constants.MAX_SEGMENT_SIZE,
self.header = MessageHeader(self.session_id, self.packet_count, packet_length, MAX_SEGMENT_SIZE,
num_segments=len(self.segments), packet_options=0)
packed_header = self.header_struct.pack(*self.header)

Expand Down
16 changes: 8 additions & 8 deletions pyhdb/protocol/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
from os import SEEK_SET, SEEK_CUR, SEEK_END
###
import pyhdb
from pyhdb.lib.stringlib import humanhexlify
from pyhdb.protocol import types
from pyhdb.protocol import constants
from pyhdb.protocol.types import by_type_code
from pyhdb.exceptions import InterfaceError, DatabaseError, DataError, IntegrityError
from pyhdb.compat import is_text, iter_range, with_metaclass, string_types, byte_type
from pyhdb.protocol.headers import ReadLobHeader, PartHeader, WriteLobHeader
from pyhdb.protocol.constants import parameter_direction
from ..lib.stringlib import humanhexlify
from ..protocol import types
from ..protocol import constants
from ..protocol.types import by_type_code
from ..exceptions import InterfaceError, DatabaseError, DataError, IntegrityError
from ..compat import is_text, iter_range, with_metaclass, string_types, byte_type
from ..protocol.headers import ReadLobHeader, PartHeader, WriteLobHeader
from ..protocol.constants import parameter_direction

logger = logging.getLogger('pyhdb')
debug = logger.debug
Expand Down
12 changes: 5 additions & 7 deletions pyhdb/protocol/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
from io import BytesIO
from os import SEEK_SET, SEEK_CUR, SEEK_END
###
from pyhdb.protocol.constants import part_kinds
from pyhdb.compat import iter_range
from pyhdb.protocol import constants
from pyhdb.protocol.parts import Part
from pyhdb.protocol.headers import RequestSegmentHeader, ReplySegmentHeader
from pyhdb.protocol.constants import segment_kinds
from .constants import part_kinds, segment_kinds, MAX_SEGMENT_SIZE
from ..compat import iter_range
from .parts import Part
from .headers import RequestSegmentHeader, ReplySegmentHeader


logger = logging.getLogger('pyhdb')
Expand Down Expand Up @@ -55,7 +53,7 @@ class RequestSegment(BaseSegment):
segment_kind = segment_kinds.REQUEST
header_struct = struct.Struct(BaseSegment.base_header_struct_fmt + 'bbbb8x') # + I1 I1 I1 I1 x[8]
header_size = header_struct.size
MAX_SEGMENT_PAYLOAD_SIZE = constants.MAX_SEGMENT_SIZE - header_size
MAX_SEGMENT_PAYLOAD_SIZE = MAX_SEGMENT_SIZE - header_size

def __init__(self, message_type, parts=None, header=None):
super(RequestSegment, self).__init__(parts, header)
Expand Down
8 changes: 4 additions & 4 deletions pyhdb/protocol/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import datetime
from weakref import WeakValueDictionary

from pyhdb.protocol.constants import type_codes
from pyhdb.exceptions import InterfaceError
from pyhdb.compat import PY26, PY2, PY3, with_metaclass, iter_range, int_types, \
from .constants import type_codes
from ..exceptions import InterfaceError
from ..compat import PY26, PY2, PY3, with_metaclass, iter_range, int_types, \
string_types, byte_type, text_type
from pyhdb.protocol.headers import WriteLobHeader
from .headers import WriteLobHeader


logger = logging.getLogger('pyhdb')
Expand Down