mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
utils/relay: add and use getDatabaseName to fetch an instance-specific DB name
This commit is contained in:
parent
f16edf6efc
commit
561af2e037
@ -12,14 +12,9 @@ from expiringdict import ExpiringDict
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from conf import confname
|
||||
import world
|
||||
|
||||
dbname = "pylinkrelay"
|
||||
if confname != 'pylink':
|
||||
dbname += '-%s' % confname
|
||||
dbname += '.db'
|
||||
|
||||
### GLOBAL (statekeeping) VARIABLES
|
||||
relayusers = defaultdict(dict)
|
||||
relayservers = defaultdict(dict)
|
||||
spawnlocks = defaultdict(threading.RLock)
|
||||
@ -28,6 +23,8 @@ savecache = ExpiringDict(max_len=5, max_age_seconds=10)
|
||||
killcache = ExpiringDict(max_len=5, max_age_seconds=10)
|
||||
relay_started = True
|
||||
|
||||
dbname = utils.getDatabaseName('pylinkrelay')
|
||||
|
||||
### INTERNAL FUNCTIONS
|
||||
|
||||
def initializeAll(irc):
|
||||
|
15
utils.py
15
utils.py
@ -6,6 +6,7 @@ import os
|
||||
|
||||
from log import log
|
||||
import world
|
||||
import conf
|
||||
|
||||
class NotAuthenticatedError(Exception):
|
||||
pass
|
||||
@ -514,3 +515,17 @@ def loadModuleFromFolder(name, folder):
|
||||
def getProtoModule(protoname):
|
||||
"""Imports and returns the protocol module requested."""
|
||||
return loadModuleFromFolder(protoname, world.protocols_folder)
|
||||
|
||||
def getDatabaseName(dbname):
|
||||
"""
|
||||
Returns a database filename with the given base DB name appropriate for the
|
||||
current PyLink instance.
|
||||
|
||||
This returns '<dbname>.db' if the running config name is PyLink's default
|
||||
(config.yml), and '<dbname>-<config name>.db' for anything else. For example,
|
||||
if this is called from an instance running as './pylink testing.yml', it
|
||||
would return '<dbname>-testing.db'."""
|
||||
if conf.confname != 'pylink':
|
||||
dbname += '-%s' % conf.confname
|
||||
dbname += '.db'
|
||||
return dbname
|
||||
|
Loading…
Reference in New Issue
Block a user