summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-12-12 20:00:10 -0500
committerDrew DeVault <sir@cmpwn.com>2018-12-12 20:00:10 -0500
commitc61c00ffd2e6a5dd12b9585b491964237a625bcc (patch)
tree2c6683a5ee700a1e2d4fc5fdc762cd99c16ca6cb
parent5f60b49c89e42709180be5f29d2a7c61bb5e36d8 (diff)
Add support for py-redis 3.x
-rw-r--r--gitsrht/blueprints/repo.py4
-rw-r--r--gitsrht/git.py2
-rw-r--r--gitsrht/redis.py5
3 files changed, 7 insertions, 4 deletions
diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py
index 685eaab..0133b19 100644
--- a/gitsrht/blueprints/repo.py
+++ b/gitsrht/blueprints/repo.py
@@ -51,7 +51,7 @@ def get_readme(repo, tip):
except:
md = "Error decoding readme - is it valid UTF-8?"
html = markdown(md, ["h1", "h2", "h3", "h4", "h5"])
- redis.setex(key, html, timedelta(days=7))
+ redis.setex(key, timedelta(days=7), html)
return Markup(html)
def _get_shebang(data):
@@ -88,7 +88,7 @@ def _highlight_file(name, data, blob_id):
formatter = HtmlFormatter()
style = formatter.get_style_defs('.highlight')
html = f"<style>{style}</style>" + highlight(data, lexer, formatter)
- redis.setex(key, html, timedelta(days=7))
+ redis.setex(key, timedelta(days=7), html)
return Markup(html)
def get_last_3_commits(commit):
diff --git a/gitsrht/git.py b/gitsrht/git.py
index 549e351..7c1eb15 100644
--- a/gitsrht/git.py
+++ b/gitsrht/git.py
@@ -135,7 +135,7 @@ def annotate_tree(repo, tree, commit):
cache = {entry.name: entry.serialize() for entry in tree.values()}
cache = json.dumps(cache)
- redis.setex(key, cache, timedelta(days=30))
+ redis.setex(key, timedelta(days=30), cache)
return [entry.fetch_blob() for entry in tree.values()]
diff --git a/gitsrht/redis.py b/gitsrht/redis.py
index c64d07c..a815f90 100644
--- a/gitsrht/redis.py
+++ b/gitsrht/redis.py
@@ -1,3 +1,6 @@
-from redis import Redis
+try:
+ from redis import StrictRedis as Redis
+except ImportError:
+ from redis import Redis
redis = Redis()