예제 #1
0
 def test_getServiceIdByName_func(self):
     collection = getDbObject(TEST_DB)["services"]
     obj = collection.find_one({"_id": TEST_ID})
     print('Test object: ' + unicode(obj))
     try:
         getServiceIdByName('testservice')
     except ServiceNotExistException:
         self.assertTrue(False)
     with self.assertRaises(ServiceNotExistException):
         getServiceIdByName('OlchikovTestService')
예제 #2
0
 def test_getServiceIdByName_func(self):
     collection = getDbObject(TEST_DB)["services"]
     obj = collection.find_one({"_id": TEST_ID})
     print('Test object: ' + unicode(obj))
     try:
         getServiceIdByName('testservice')
     except ServiceNotExistException:
         self.assertTrue(False)
     with self.assertRaises(ServiceNotExistException):
         getServiceIdByName('OlchikovTestService')
        def post(self, serviceName):
            importDataDict = parserClass.parsePostParameters()
            channelName = importDataDict.get('channelName')
            getServiceIdByName(serviceName)
            getChannelByName(serviceName, channelName)
            job = jobClass(importFunction, importDataDict.get('channelName'),
                           importDataDict.get('openDataUrl'), importDataDict,
                           serviceName)

            return JobManager.startJob(job)
예제 #4
0
def geocoderImport(self, channelName, serviceName):
    # Checking for service existence
    getServiceIdByName(serviceName)
    # Getting channel id
    channel = getChannelByName(serviceName, channelName)
    channel_id = channel[ID]
    # Initialising requester and parser
    greqv = GeonamesRequestSender()
    gpars = GeocoderResponseParser()
    # Getting points collection
    points_coll = getDbObject(serviceName)[POINTS_COLL]
    # Getting first slice of <= 5000 points
    proc_step = 0
    point_block = list(points_coll.find({
        CHANNEL_ID: channel_id,
        JSON + '.' + ADDRESS: {"$exists": True}
    }).skip(proc_step).limit(PROC_BLOCK))
    login = PluginConfigReader(PLUGIN_NAME).getConfigContent()[
        SECTION_GEOCODING][GEONAMES_LOGIN]
    while point_block:
        current_size = len(point_block)
        addresses = [point[JSON][ADDRESS] for point in point_block]
        ids = [point[ID] for point in point_block]
        string_addresses = greqv.requestCoordinates(
            addresses,
            login,
            json_list_to_list_of_strings)
        json_coords = gpars.parseList(string_addresses)
        for i in range(0, current_size):
            # If no coords was found - we change nothing
            if json_coords[i] is None:
                continue
            points_coll.update(
                {ID: ids[i]},
                {'$set': {'location.coordinates': json_coords[i]}}
            )
        # Getting next slice of <= 5000 points
        proc_step += PROC_BLOCK
        point_block = list(
            points_coll.find().skip(proc_step).limit(PROC_BLOCK))
    # Task is done
    self.done = True
    # And thread is done too after return
    return []
예제 #5
0
 def get(self, serviceName, jobId):
     getServiceIdByName(serviceName)
     return JobManager.getJob(jobId)
예제 #6
0
 def delete(self, serviceName, jobId):
     getServiceIdByName(serviceName)
     return JobManager.stopJob(jobId)
예제 #7
0
 def get(self, serviceName):
     getServiceResult = getServiceIdByName(serviceName)
     return getServiceResult
예제 #8
0
 def testRemoveService(self):
     db[COLLECTION].save({NAME: TEST_OBJECT})
     removeService(TEST_OBJECT)
     with self.assertRaises(ServiceNotExistException):
         getServiceIdByName(TEST_OBJECT)
 def testRemoveService(self):
     db[COLLECTION].save({NAME: TEST_OBJECT})
     removeService(TEST_OBJECT)
     with self.assertRaises(ServiceNotExistException):
         getServiceIdByName(TEST_OBJECT)
예제 #10
0
 def get(self, serviceName):
     getServiceResult = getServiceIdByName(serviceName)
     return getServiceResult
예제 #11
0
 def get(self, serviceName):
     getServiceIdByName(serviceName)
     return JobManager.getJobs()