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: ...@@ -3,9 +3,9 @@ To set up:
- Install Python 2.4 or later. - Install Python 2.4 or later.
- Install Twisted-Web, Twisted-Mail, PyOpenSSL, and all their dependencies. - Install Twisted-Web, Twisted-Mail, PyOpenSSL, and all their dependencies.
- To run unit tests, "python setup.py test" - To run unit tests, "python setup.py test"
- python setup.py install --prefix=$HOME - python setup.py install
- To generate translation files, run "python setup.py trans" and then run - To generate translation files, run "python setup.py trans"
"python setup.py install_data" to install them - Run "python setup.py install_data" to install them
- Edit bridgedb.conf; put it somewhere good. - Edit bridgedb.conf; put it somewhere good.
- Make sure that the input files referred to in bridgedb.conf exist. - Make sure that the input files referred to in bridgedb.conf exist.
- You can make a self-signed certificate with - You can make a self-signed certificate with
......
...@@ -140,4 +140,4 @@ EMAIL_INCLUDE_FINGERPRINTS=False ...@@ -140,4 +140,4 @@ EMAIL_INCLUDE_FINGERPRINTS=False
# HTTPS_SHARE : EMAIL_SHARE : RESERVED_SHARE # HTTPS_SHARE : EMAIL_SHARE : RESERVED_SHARE
RESERVED_SHARE=2 RESERVED_SHARE=2
FILE_BUCKETS = {} FILE_BUCKETS = {}
\ No newline at end of file
...@@ -17,6 +17,7 @@ import socket ...@@ -17,6 +17,7 @@ import socket
import time import time
import bridgedb.Storage import bridgedb.Storage
import bridgedb.Bucket
HEX_FP_LEN = 40 HEX_FP_LEN = 40
ID_LEN = 20 ID_LEN = 20
...@@ -453,6 +454,9 @@ class BridgeSplitter(BridgeHolder): ...@@ -453,6 +454,9 @@ class BridgeSplitter(BridgeHolder):
ringname = db.insertBridgeAndGetRing(bridge, ringname, time.time()) ringname = db.insertBridgeAndGetRing(bridge, ringname, time.time())
db.commit() db.commit()
# Resolve pseudo distributor ring names
ringname = bridgedb.Bucket.getRealDistributorName(ringname)
ring = self.ringsByName.get(ringname) ring = self.ringsByName.get(ringname)
ring.insert(bridge) ring.insert(bridge)
...@@ -24,6 +24,22 @@ instead of 'unallocated'. This is why they are called pseudo-distributors. ...@@ -24,6 +24,22 @@ instead of 'unallocated'. This is why they are called pseudo-distributors.
import time import time
import bridgedb.Storage import bridgedb.Storage
# What should pseudo distributors be prefixed with in the database so we can
# distinguish them from real distributors?
PSEUDO_DISTRI_PREFIX = "pseudo_"
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: class BucketData:
"""A file bucket value class. """A file bucket value class.
name - Name of the bucket (From config) name - Name of the bucket (From config)
...@@ -95,7 +111,7 @@ class BucketManager: ...@@ -95,7 +111,7 @@ class BucketManager:
self.bucketList = [] self.bucketList = []
self.unallocatedList = [] self.unallocatedList = []
self.unallocated_available = False self.unallocated_available = False
self.distributor_prefix = "pseudo_" self.distributor_prefix = PSEUDO_DISTRI_PREFIX
self.db = bridgedb.Storage.Database(self.cfg.DB_FILE+".sqlite", self.db = bridgedb.Storage.Database(self.cfg.DB_FILE+".sqlite",
self.cfg.DB_FILE) self.cfg.DB_FILE)
......
# BridgeDB i18n strings & helper routines. The string should go into pootle # BridgeDB i18n strings & helper routines. The string should go into pootle
import os
import gettext 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 """Return the Translation instance for a given language. If no Translation
instance is found, return the one for 'en' 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): def _(text):
"""This is necessary because strings are translated when they're imported. """This is necessary because strings are translated when they're imported.
......
[install] [install]
install-data=/usr prefix=$HOME
install-data=$HOME
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