def main(configFile):
    ''' Holds it all together '''
    
    # Get the config information into a single object. p also gets passed into the listener
    p = getConfigParameters(configFile)

    # Handle the mongo connection and authentication
    c, dbh, collection, emoCollection = getMongoHandles(p)

    # Open the english dictionary file and loop it
    try:
        f = open(os.path.join(p.sourcePath, p.enPlainFile), 'r')
    except Exception, e:
        handleErrors(p, e)
Example #2
0
    def setUp(self):
        ''' sets up parameters before each test'''
        
        # The base url to hit
        self.url = 'http://localhost:8044'

        # Config information from a relative path
        configPath = os.path.join(wsDir, 'config')
        configFile = 'testsWordslang.cfg'
        self.p = getConfigParameters(os.path.join(configPath, configFile))
        
        self.c, dbh, collection, emoCollection = getMongoHandles(self.p)

        # Build a document and insert it 
        doc1 = {"pho" : "sml",
                 "slang" : ["smlie", "smiiile", "2smile", "smiiileee", "smilee",
                            "usmile", "smilie", "simle", "smillleee", "smillle",
                            "smille", "smileee", "*s*", "smle", "smilert", "smiile",
                            "smil", "smie", ": )", "(-:"],
                 "word" : "smile"}
        
        doc2 = {"pho" : "st",
                 "slang" : [ "sosad", "ssad", "saaad", "saaddd",
                        "saaadd", "sadd", "saadd", "saddd",
                        "saddy", "saad", "saaaddd", ": (", ": ["],
                "word" : "sad"}
        
        doc3 = {"pho" : "unh",
                 "slang" : [ "sad"],
                "word" : "unhappy"}

                
        # Insert a couple of documents
        id1 = collection.insert(doc1) 
        id2 = collection.insert(doc2)
        id3 = collection.insert(doc3)
        self.document1 = doc1
        self.document2 = doc2
        self.document3 = doc3
        
        # Documents to go into the emoticons collection
        doc4 = {"word" : "smile",
                "emo"  : [":-)"]}
        id4 = emoCollection.insert(doc4)
        self.document4 = doc4
Example #3
0
def main(configFile, file="norm"):
    """ Holds it all together """

    # Get the config information into a single object. p also gets passed into the listener
    p = getConfigParameters(configFile)

    # Handle the mongo connection and authentication
    c, dbh, collection, emoCollection = getMongoHandles(p)

    if file == "norm":
        fileToProcess = p.enNormalisedFile
    elif file == "slang":
        fileToProcess = p.slangFile

    # Open the english dictionary file and loop it
    try:
        f = open(os.path.join(p.sourcePath, fileToProcess), "r")
    except Exception, e:
        print e
        handleErrors(p, e)
Example #4
0
    import mdb
except:
    on_error(message='failed import of baseUtils and mdb.\n')
    
# Config information from a relative path
configFile = '/home/dotcloud/code/config/wordslang.cfg'

try:
    # Get the config information into a single object. p also gets passed into the listener
    p = getConfigParameters(configFile)
except Exception, e:
    on_error(message='%s \n failed on getConfigParameters.\n' %e)
    
# Handle the mongo connection and authentication
try:
    c, dbh, collection = getMongoHandles(p)
except Exception, e:
    #on_error(message='db: %s host: %s port: %s user: %s pssd: %s \n' %(p.db, p.dbHost, p.dbPort, p.dbUser, p.dbPassword))
    on_error(message='Failed to get mongo handles.\n')
    #on_error(message='%s\n' %e)
    
@route('/check1')
def check1():
    '''    '''
    
    global c
    global dbh
    global collection
    #global p
    # It appears you don't need to make these global scope