Skip to content

Commit

Permalink
Merge 6c29b45 into 95b3a1c
Browse files Browse the repository at this point in the history
  • Loading branch information
aosingh committed Jun 6, 2020
2 parents 95b3a1c + 6c29b45 commit 17c87f7
Show file tree
Hide file tree
Showing 33 changed files with 573 additions and 639 deletions.
10 changes: 4 additions & 6 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[run]
branch = False
parallel = True

source =
sqlite_rx

branch = False
source = sqlite_rx
concurrency = multiprocessing
omit =
/*/tests/*
.env/*
/sqlite_rx/cli
./sqlite_rx/cli/__init__.py
/home/travis/virtualenv/*

[report]
Expand Down
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ dist
sqlite_rx.egg-info
.coveragerc
docker_examples
.coverage
.pytest_cache
.coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ sqlite_rx.egg-info/
cover/
build/
dist/
.coverage
.pytest_cache
.coverage
28 changes: 16 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
language: python
os:
- linux
python:
- "3.6"
- "3.7"
- "3.8"
- "pypy3"
matrix:
include:
- os: linux
python: 3.6
- os: linux
python: 3.7
- os: linux
python: 3.8
- os: linux
python: pypy3
install:
- pip install --upgrade pip
- pip install pytest pytest-cov coverage coveralls
- pip install -e .
script:
- pip install nose
- pip install coverage
- pip install coveralls
- python setup.py nosetests --with-coverage
- coverage run --concurrency=multiprocessing -m unittest discover -s sqlite_rx/tests
- coverage run -m pytest --verbose sqlite_rx/tests
- coverage combine
- coverage report -i -m
- coveralls
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ def main():
logging.config.dictConfig(get_default_logger_settings(logging.DEBUG))
server = SQLiteServer(database=":memory:",
bind_address="tcp://127.0.0.1:5000")
try:
server.start()
except KeyboardInterrupt:
server.stop()

server.start()

if __name__ == '__main__':
main()
Expand Down
11 changes: 11 additions & 0 deletions dockerfiles/Dockerfile_pypy3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM pypy:3-slim

RUN apt-get update
RUN apt-get -y install g++
RUN apt-get -y install libzmq3-dev

COPY . /sqlite_rx
WORKDIR /sqlite_rx

RUN pypy3 -m pip install -r requirements.txt
RUN pypy3 setup.py install
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
click
msgpack-python
msgpack
pyzmq
tornado
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ cover-package = sqlite_rx
cover-html = 1
tests = sqlite_rx/tests

[coverage:run]
branch = True
concurrency = multiprocessing
parallel = True
source = sqlite_rx
[easy_install]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

PACKAGES = ['sqlite_rx']

DEPENDENCIES = ['msgpack-python', 'pyzmq', 'tornado', 'click']
DEPENDENCIES = ['msgpack', 'pyzmq', 'tornado', 'click']

classifiers = [
'Development Status :: 4 - Beta',
Expand Down
8 changes: 6 additions & 2 deletions sqlite_rx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.9.98"
__version__ = "0.9.99"
__author__ = "Abhishek Singh"
__authoremail__ = "aosingh@asu.edu"

Expand Down Expand Up @@ -39,4 +39,8 @@ def get_default_logger_settings(level: str = "DEBUG"):
'propagate': False
},
}
}
}


def get_version():
return __version__
34 changes: 12 additions & 22 deletions sqlite_rx/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import zmq
import zmq.auth
from sqlite_rx.exception import InvalidAuthConfig
from sqlite_rx.exception import SQLiteRxAuthConfigError


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -67,7 +67,7 @@ class during server startup. This class represents a callable passed to the sqli
permissions are ``sqlite3.SQLITE_OK``, ``sqlite3.SQLITE_DENY`` and ``sqlite3.SQLITE_IGNORE``
Raises:
sqlite_rx.exception.InvalidAuthConfig: if ``config`` contains invalid permissions other than
sqlite_rx.exception.SQLiteRxAuthConfigError: if ``config`` contains invalid permissions other than
``sqlite3.SQLITE_OK``, ``sqlite3.SQLITE_DENY`` and ``sqlite3.SQLITE_IGNORE``
Example:
Expand All @@ -84,7 +84,7 @@ class during server startup. This class represents a callable passed to the sqli
sqlite3.SQLITE_OK,
sqlite3.SQLITE_DENY}
if any(k not in self.valid_return_values for k in self.config.keys()):
raise InvalidAuthConfig(
raise SQLiteRxAuthConfigError(
"Allowed return values are: "
"sqlite3.SQLITE_OK(0), sqlite3.SQLITE_DENY(1), sqlite3.SQLITE_IGNORE(2)")

Expand Down Expand Up @@ -150,7 +150,7 @@ def generate(self):
bogus = False
for key in [self.public_key, self.private_key]:
if os.path.exists(key):
print("%s already exists. Aborting." % key)
LOG.info("%s already exists. Aborting.", key)
bogus = True
break
if bogus:
Expand All @@ -171,8 +171,8 @@ def generate(self):
LOG.info(server_secret_file)
os.chmod(self.public_key, 0o600)
os.chmod(self.private_key, 0o600)
LOG.info("Created %s." % self.public_key)
LOG.info("Created %s." % self.private_key)
LOG.info("Created Public key %s", self.public_key)
LOG.info("Created Private key %s", self.private_key)


class KeyMonkey:
Expand Down Expand Up @@ -229,14 +229,10 @@ def setup_secure_server(self,
server.curve_publickey = foo
server.curve_secretkey = bar
server.curve_server = True
LOG.info(
"Secure setup completed using on %s using curve key %s." %
(bind_address, self.my_id))
LOG.info("Secure setup completed using on %s using curve key %s", bind_address, self.my_id)
return server
except IOError:
LOG.exception(
"Couldn't load the private key: %s" %
self.private_key)
LOG.exception("Couldn't load the private key: %s", self.private_key)
raise
except Exception:
LOG.exception("Exception while setting up CURVECP")
Expand Down Expand Up @@ -267,9 +263,7 @@ def setup_secure_client(self,
client.curve_publickey = foo
client.curve_secretkey = bar
except IOError:
LOG.exception(
"Couldn't load the client private key: %s" %
self.private_key)
LOG.exception("Couldn't load the client private key: %s", self.private_key)
raise
else:
# Clients need server's public key for encryption
Expand All @@ -279,13 +273,9 @@ def setup_secure_client(self,
client.curve_serverkey = foo
except IOError:
LOG.exception(
"Couldn't load the server public key %s " %
os.path.join(
self.curvedir,
f"{servername}.key"))
"Couldn't load the server public key %s ", os.path.join(self.curvedir, f"{servername}.key"))
raise
else:
LOG.info(
"Client connecting to %s (key %s) using curve key '%s'." %
(connect_address, servername, self.my_id))
LOG.info("Client connecting to %s (key %s) using curve key '%s'.",
connect_address, servername, self.my_id)
return client
15 changes: 3 additions & 12 deletions sqlite_rx/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main(log_level,
curve_dir,
key_id):
logging.config.dictConfig(get_default_logger_settings(level=log_level))
LOG.info("Python Platform %s" % platform.python_implementation())
LOG.info("Python Platform %s", platform.python_implementation())
kwargs = {
'bind_address': f'tcp://{advertise_host}:{port}',
'database': database,
Expand All @@ -38,18 +38,9 @@ def main(log_level,
'use_encryption': curvezmq,
'server_curve_id': key_id
}
LOG.info('Args %s' % pformat(kwargs))
LOG.info('Args %s', pformat(kwargs))
server = SQLiteServer(**kwargs)
try:
server.start()
except KeyboardInterrupt:
LOG.warning("Keyboard Interrupt")
server.stop()
except Exception:
LOG.exception("Exception in Server Thread")
server.stop()
raise

server.start()



Expand Down
Loading

0 comments on commit 17c87f7

Please sign in to comment.