mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Apply black formatting.
Apply isort.
This commit is contained in:
@@ -5,14 +5,13 @@ from time import time
|
||||
|
||||
import uwsgi
|
||||
|
||||
|
||||
realtime_db_file = uwsgi.opt["interactivetools_map"].decode('utf-8')
|
||||
realtime_db_file = uwsgi.opt["interactivetools_map"].decode("utf-8")
|
||||
db_conn = sqlite3.connect(realtime_db_file)
|
||||
|
||||
DATABASE_TABLE_NAME = 'gxitproxy'
|
||||
DATABASE_TABLE_NAME = "gxitproxy"
|
||||
|
||||
|
||||
class CacheEntry():
|
||||
class CacheEntry:
|
||||
def __init__(self, key, value, ttl=20):
|
||||
self.key = key
|
||||
self.value = value
|
||||
@@ -21,12 +20,12 @@ class CacheEntry():
|
||||
|
||||
def expired(self):
|
||||
if self._expired is False:
|
||||
return (self.expires_at < time())
|
||||
return self.expires_at < time()
|
||||
else:
|
||||
return self._expired
|
||||
|
||||
|
||||
class CacheList():
|
||||
class CacheList:
|
||||
def __init__(self):
|
||||
self.entries = []
|
||||
self.lock = RLock()
|
||||
@@ -53,8 +52,9 @@ key_type_token_mapped_cache = CacheList()
|
||||
|
||||
def args_as_unicode(func):
|
||||
def wrap_args(*args):
|
||||
args = (arg.decode('utf-8') if isinstance(arg, bytes) else arg for arg in args)
|
||||
args = (arg.decode("utf-8") if isinstance(arg, bytes) else arg for arg in args)
|
||||
return func(*args)
|
||||
|
||||
return wrap_args
|
||||
|
||||
|
||||
@@ -81,9 +81,13 @@ def key_type_token_mapper(key, key_type, token, route_extra, url):
|
||||
for _ in range(2):
|
||||
# Order by rowid gives us the last row added
|
||||
try:
|
||||
row = db_conn.execute("SELECT host, port FROM %s WHERE key=? AND key_type=? AND token=? ORDER BY rowid DESC LIMIT 1" % (DATABASE_TABLE_NAME), (key, key_type, token)).fetchone()
|
||||
row = db_conn.execute(
|
||||
"SELECT host, port FROM %s WHERE key=? AND key_type=? AND token=? ORDER BY rowid DESC LIMIT 1"
|
||||
% (DATABASE_TABLE_NAME),
|
||||
(key, key_type, token),
|
||||
).fetchone()
|
||||
if row:
|
||||
rval = '%s:%s' % (tuple(row))
|
||||
rval = "%s:%s" % (tuple(row))
|
||||
return rval.encode()
|
||||
break
|
||||
except sqlite3.ProgrammingError:
|
||||
@@ -93,5 +97,5 @@ def key_type_token_mapper(key, key_type, token, route_extra, url):
|
||||
return None
|
||||
|
||||
|
||||
uwsgi.register_rpc('rtt_key_type_token_mapper', key_type_token_mapper)
|
||||
uwsgi.register_rpc('rtt_key_type_token_mapper_cached', key_type_token_mapper_cached)
|
||||
uwsgi.register_rpc("rtt_key_type_token_mapper", key_type_token_mapper)
|
||||
uwsgi.register_rpc("rtt_key_type_token_mapper_cached", key_type_token_mapper_cached)
|
||||
|
||||
Reference in New Issue
Block a user