Skip to content

Commit

Permalink
Merge pull request #64 from yahoo/wheel_fix
Browse files Browse the repository at this point in the history
Wheel fix
  • Loading branch information
dwighthubbard committed Apr 17, 2015
2 parents cd4471f + 068cb71 commit 406350d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
5 changes: 5 additions & 0 deletions deploy_package
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
export MACOSX_DEPLOYMENT_TARGET="10.6"
export PYTHON_CONFIGURE_OPTS="--enable-universalsdk=/ --with-universal-archs=intel"

python setup.py sdist bdist_wheel upload
5 changes: 2 additions & 3 deletions redislite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
__redis_executable__ = str(_package_metadata['redis_bin'])
__redis_server_info__ = _package_metadata['redis_server']


if os.path.exists(os.path.join(os.path.basename(__file__), "bin/redis-server")):
if os.path.exists(os.path.join(os.path.dirname(__file__), "bin/redis-server")):
__redis_executable__ = os.path.join(
os.path.basename(__file__),
os.path.dirname(__file__),
'bin/redis-server'
) # pragma: no cover

Expand Down
25 changes: 14 additions & 11 deletions redislite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ class RedisMixin(object):
dbdir = None
settingregistryfile = None
cleanupregistry = False
redis_configuration = None
redis_configuration_filename = None

def _cleanup(self):
"""
Stop the redis-server for this instance if it's running
:return:
"""

if not self.redis_dir:
if not self.redis_dir: # pragma: no cover
return

if self.running:
Expand Down Expand Up @@ -114,7 +116,10 @@ def _start_redis(self):
Start the redis server
:return:
"""
config_file = os.path.join(self.redis_dir, 'redis.config')

self.redis_configuration_filename = os.path.join(
self.redis_dir, 'redis.config'
)

kwargs = dict(self.server_config)
kwargs.update(
Expand All @@ -126,16 +131,14 @@ def _start_redis(self):
}
)
# Write a redis.config to our temp directory
fh = open(config_file, 'w')
fh.write(
configuration.config(**kwargs)
)
fh.close()
self.redis_configuration = configuration.config(**kwargs)
with open(self.redis_configuration_filename, 'w') as file_handle:
file_handle.write(self.redis_configuration)

redis_executable = __redis_executable__
if not redis_executable: # pragma: no cover
redis_executable = 'redis-server'
command = [redis_executable, config_file]
command = [redis_executable, self.redis_configuration_filename]
logger.debug('Running: %s', ' '.join(command))
rc = subprocess.call(command)
if rc: # pragma: no cover
Expand Down Expand Up @@ -299,7 +302,7 @@ def __init__(self, *args, **kwargs):
super(RedisMixin, self).__init__(*args, **kwargs) # pragma: no cover

def __del__(self):
self._cleanup()
self._cleanup() # pragma: no cover

@property
def db(self):
Expand All @@ -321,11 +324,11 @@ def pid(self):
redislite instance or None. If the redis-server is not
running.
"""
if self.pidfile:
if self.pidfile and os.path.exists(self.pidfile):
with open(self.pidfile) as fh:
pid = fh.read().strip()
return int(pid)
return None # pragma: no cover
return 0 # pragma: no cover


class Redis(RedisMixin, redis.Redis):
Expand Down
6 changes: 3 additions & 3 deletions redislite/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,10 @@ def settings(*args, **kwargs):
"""
global default_settings

settings = default_settings
settings.update(kwargs)
new_settings = default_settings
new_settings.update(kwargs)

return settings
return new_settings


def config(*args, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ def test_metadata(self):
self.assertIsInstance(redislite.__redis_server_info__, dict)
self.assertIsInstance(redislite.__redis_executable__, str)

def test_is_redis_running_no_pidfile(self):
r = redislite.Redis()
r.shutdown()
result = r._is_redis_running()
self.assertFalse(result)


if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[tox]
skip_missing_interpreters=True
envlist = py27,py33,py34,pypy,pypy3

# Removed pypy3 due to issues with the psutil dependency on that python
# version.
#envlist = py27,py33,py34,pypy,pypy3
envlist = py27,py33,py34,pypy

[testenv]
deps=
Expand Down

0 comments on commit 406350d

Please sign in to comment.