Commit ce76133b authored by Christian Fromme's avatar Christian Fromme
Browse files

Fix some issues that popped up during BridgeDB deployment

- Install translations to ~/ by default instead of /usr
- Use ~ as prefix by default
- Make sure pseudo distributors don't end up as actual ring names
parent fa77b306
......@@ -3,9 +3,9 @@ To set up:
- Install Python 2.4 or later.
- Install Twisted-Web, Twisted-Mail, PyOpenSSL, and all their dependencies.
- To run unit tests, "python test"
- python install --prefix=$HOME
- To generate translation files, run "python trans" and then run
"python install_data" to install them
- python install
- To generate translation files, run "python trans"
- Run "python install_data" to install them
- Edit bridgedb.conf; put it somewhere good.
- Make sure that the input files referred to in bridgedb.conf exist.
- You can make a self-signed certificate with
......@@ -17,6 +17,7 @@ import socket
import time
import bridgedb.Storage
import bridgedb.Bucket
ID_LEN = 20
......@@ -453,6 +454,9 @@ class BridgeSplitter(BridgeHolder):
ringname = db.insertBridgeAndGetRing(bridge, ringname, time.time())
# Resolve pseudo distributor ring names
ringname = bridgedb.Bucket.getRealDistributorName(ringname)
ring = self.ringsByName.get(ringname)
......@@ -24,6 +24,22 @@ instead of 'unallocated'. This is why they are called pseudo-distributors.
import time
import bridgedb.Storage
# What should pseudo distributors be prefixed with in the database so we can
# distinguish them from real distributors?
def getRealDistributorName(distributor):
"""Return the *real* ring name for a given one. This is needed because
with pseudo distributors, we've got strings in the database that aren't
real distributors.
# If it starts with "pseudo_", its really "unallocated"
if distributor.startswith(PSEUDO_DISTRI_PREFIX):
distributor = "unallocated"
return distributor
class BucketData:
"""A file bucket value class.
name - Name of the bucket (From config)
......@@ -95,7 +111,7 @@ class BucketManager:
self.bucketList = []
self.unallocatedList = []
self.unallocated_available = False
self.distributor_prefix = "pseudo_"
self.distributor_prefix = PSEUDO_DISTRI_PREFIX
self.db = bridgedb.Storage.Database(self.cfg.DB_FILE+".sqlite",
# BridgeDB i18n strings & helper routines. The string should go into pootle
import os
import gettext
def getLang(lang):
def getLang(lang, localedir=os.path.expanduser("~") + "/share/locale"):
"""Return the Translation instance for a given language. If no Translation
instance is found, return the one for 'en'
return gettext.translation("bridgedb", languages=[lang], fallback="en")
return gettext.translation("bridgedb", localedir=localedir,
languages=[lang], fallback="en")
def _(text):
"""This is necessary because strings are translated when they're imported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment