Skip to content

Commit

Permalink
Merge pull request #2 from acelyc111/master
Browse files Browse the repository at this point in the history
change code structure for pypi
  • Loading branch information
acelyc111 authored Mar 2, 2018
2 parents d76d485 + 1ef3777 commit 45e485c
Show file tree
Hide file tree
Showing 29 changed files with 122 additions and 98 deletions.
4 changes: 4 additions & 0 deletions pypegasus/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python
# coding: utf-8

__version__ = '0.1.14'
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion base/ttypes.py → pypegasus/base/ttypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions operate/packet.py → pypegasus/operate/packet.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import struct
import ctypes
import base.ttypes
import utils

from thrift.Thrift import TMessageType

from utils import tools
from rrdb import (
from pypegasus import utils
from pypegasus.rrdb import (
meta,
rrdb)
from base.ttypes import (
error_code,
gpid)
from pypegasus.base.ttypes import (
rocksdb_error_types,
error_code,
gpid)
from pypegasus.utils import tools


class ThriftHeader(object):
Expand Down Expand Up @@ -127,8 +127,8 @@ def send_data(self, oprot, seqid):
@staticmethod
def parse_result(resp):
data = {}
if resp.error == base.ttypes.rocksdb_error_types.kOk.value\
or resp.error == base.ttypes.rocksdb_error_types.kIncomplete.value:
if resp.error == rocksdb_error_types.kOk.value\
or resp.error == rocksdb_error_types.kIncomplete.value:
for kv in resp.kvs:
data[kv.key.data] = kv.value.data

Expand Down
27 changes: 16 additions & 11 deletions pgclient.py → pypegasus/pgclient.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
from __future__ import print_function
from __future__ import with_statement

import os
import logging.config

from thrift.Thrift import TMessageType, TApplicationException
from twisted.internet import defer
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, succeed, fail
from twisted.internet.protocol import ClientCreator

from base.ttypes import *
from operate.packet import *
from replication.ttypes import *
from rrdb.ttypes import *
from utils.tools import *
from transport.protocol import TPegasusThriftClientProtocol
from pypegasus import rrdb, replication
from pypegasus.base.ttypes import *
from pypegasus.operate.packet import *
from pypegasus.replication.ttypes import query_cfg_request
from pypegasus.rrdb import *
from pypegasus.rrdb.ttypes import scan_request, get_scanner_request, update_request, key_value, multi_put_request, \
multi_get_request, multi_remove_request
from pypegasus.transport.protocol import *
from pypegasus.utils.tools import restore_key, get_ttl, bytes_cmp, ScanOptions

try:
from thrift.protocol import fastbinary
except:
fastbinary = None


logging.config.fileConfig("logger.conf")
logger = logging.getLogger("root")
logging.config.fileConfig(os.path.dirname(__file__)+"/logger.conf")
logger = logging.getLogger("pgclient")

DEFAULT_TIMEOUT = 2000 # ms
META_CHECK_INTERVAL = 2 # s
Expand Down Expand Up @@ -246,8 +251,8 @@ def query_one(self, session):

def got_results(self, res):
for (suc, result) in res:
if suc \
and isinstance(result, replication.ttypes.query_cfg_response) \
if suc \
and result.__class__.__name__ == "query_cfg_response" \
and result.is_stateful:
logger.info('table: %s, partition result: %s',
self.name, result)
Expand Down Expand Up @@ -295,7 +300,7 @@ def got_results(self, res):
return True

def update_cfg(self, resp):
if not isinstance(resp, replication.ttypes.query_cfg_response):
if resp.__class__.__name__ != "query_cfg_response":
logger.error('table: %s, query_cfg_response is error',
self.name)
return None
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions pypegasus/replication/replication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from ttypes import (
partition_configuration,
query_cfg_request,
query_cfg_response)


22 changes: 11 additions & 11 deletions replication/ttypes.py → pypegasus/replication/ttypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions rrdb/meta.py → pypegasus/rrdb/meta.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions rrdb/rrdb.py → pypegasus/rrdb/rrdb.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 45e485c

Please sign in to comment.