コード例 #1
0
                cl("Already registered")
                return threadHandle
            else:
                cl("New listener")
                existingProcessor.addListener(newProcessor)
                self.thread2ClientId[threadHandle].append(clientId)
                return clientId
        else:
            cl("New Processor")
            self.thread2ClientId[threadHandle] = [clientId]
            self.thread2Processor[threadHandle] = newProcessor
            newProcessor.start()
            #newProcessor.msg("subClassRun", {})
            ncl('returnning:', threadHandle)
            return threadHandle
    def getThreadInst(self, threadHandle):
        return self.thread2Processor[threadHandle]
        
    def stop(self):
        cl('-----------------------exist server called')
        for threadHandle in self.thread2Processor:
            self.thread2Processor[threadHandle].msg("exitThread", {})
    stop.exposed = True
    


    
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(xmlRpcServerWithThread(gXmlRpcServerPort))
コード例 #2
0

class folderInfoStorageServer(threadSvrBase.xmlRpcServerWithThread):
    '''
    classdocs
    '''
    def __init__(self, port):
        '''
        Constructor
        '''
        super(folderInfoStorageServer, self).__init__(port)
        
    def create(self, outputFolder, rootPath):
        threadInst = workThread(outputFolder, rootPath)
        clientId = self.createProcessor(threadInst)
        ncl(clientId)
        threadInst.msg("gen", {})
        return "OK"
    create.exposed = True
    
    def notify(self, param):
        cl(param)
        threadInst = self.getThreadInst(param.replace("folder://", "recursive://"))
        threadInst.msg("scanComplete", {})
        
    notify.exposed = True
    
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(folderInfoStorageServer(gXmlRpcServerPort))
コード例 #3
0
            if newObjUuid is None:
                cl("item deleted, do not add it")
                continue
            ncl('before update obj uuid')
            '''
            collection.updateObjUuidIfNeeded(itemUrl, newObjUuid)
            '''
            if collection.isSame(objInCol, newObjUuid):
                ncl("no updates needed", objInCol, newObjUuid)
                continue
            collection.updateObjUuidRaw(objInCol, newObjUuid)
            ncl('new item added', objInCol)
                
        cl("notifying listener")
        self.notifyAll()


class collectionManagementServer(xmlRpcServerWithWorkerThreadBase.xmlRpcServerWithWorkerThreadBase):
    def register(self, monitorUrl, xmlRpcServerUrl, dbPrefix = ""):
        #paramDict = {"rootFolder": monitorUrl, "serverUrl": xmlRpcServerUrl}
        newProcessor = dirScanner(monitorUrl, xmlRpcServerUrl, dbPrefix)
        targetCallbackServerUrl = self.createProcessor(newProcessor)
        if targetCallbackServerUrl == newProcessor.getFirstCallbackServerUrl():
            newProcessor.msg("subClassRun", {})
        return newProcessor.getThreadHndl()
    register.exposed = True

if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(collectionManagementServer(8808))
コード例 #4
0
    def sampleMethodInternal(self, clientId):
        #Server will send message to this class and the
        #parent class will generate call to member in
        #a message loop
        print "Sample method called:", clientId

class sampleServer(threadSvrBase.xmlRpcServerWithThread):
    '''
    classdocs
    '''
    def __init__(self, port):
        '''
        Constructor
        '''
        super(sampleServer, self).__init__(port)
        
    def sampleCreateOnServer(self):
        threadInst = sampleThread(clientId = "helloworld")
        return self.createProcessor(threadInst)
    sampleCreateOnServer.exposed = True
    
    def sampleMethod(self, threadHandle, clientId = "helloworld"):
        cl(threadHandle, clientId)
        t = self.thread2Processor[(threadHandle)]
        t.msg("sampleMethod", {"clientId":clientId})
    sampleMethod.exposed = True
    
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(sampleServer(gXmlRpcServerPort))
コード例 #5
0
    classdocs
    
    '''
    def __init__(self, port):
        super(XmlRpcServer2BeanstalkdServiceBridge, self).__init__(port)
        self.beanstalkd_service_command_tube_names = []
        self.beanstalk = None
        
    def get_beanstalkd_instance(self):
        if self.beanstalk is None:
            self.beanstalk = beanstalkc.Connection(host=gBeanstalkdServerHost, port=gBeanstalkdServerPort)
        return self.beanstalk

        self.beanstalk.ignore('default')
    def subscribe(self, beanstalkd_tube_name):
        self.beanstalkd_service_command_tube_names.append(beanstalkd_tube_name)
        return "added: "+beanstalkd_tube_name
        
    subscribe.exposed = True
    def stop(self):
        #Send messages to all beanstalkd service
        for i in self.beanstalkd_service_command_tube_names:
            print "add item to tube:", i
            stop_beanstalkd_service(i, self.get_beanstalkd_instance())
    stop.exposed = True

        
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(XmlRpcServer2BeanstalkdServiceBridge(gXmlRpcServerPort))
コード例 #6
0
    def __init__(self, port):
        '''
        Constructor
        '''
        xmlRpcServerWithWorkerThreadBase.xmlRpcServerWithWorkerThreadBase.__init__(self, port)
        self.threadList = list()

    
    #Create a sync service
    def addSync(self, taskUuid, folderPath, encZipPath, passwd, workingPath):
        threadInst = syncThread(taskUuid, folderPath, encZipPath, passwd, workingPath)
        self.createProcessor(threadInst)
        
        #Add additional notify info so the notification from dir scanner 
        #will be dispatched to specific thread
        encZipPathMonitorUrl, folderPathMonitorUrl = threadInst.getNotificationHandler()
        self.threadList.append((encZipPathMonitorUrl, folderPathMonitorUrl, threadInst))

    addSync.exposed = True
    
    def notify(self, notifyParam):
        cl("notify called", notifyParam)
        for i in self.threadList:
            if (i[0] == notifyParam) or (i[1] == notifyParam):
                i[2].msg("subClassRun", {"notificationSource": notifyParam})
    notify.exposed = True
    
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(syncXmlRpcServer(8807))
コード例 #7
0
            yield objInCol
        folderObj = self.objDb.getFsObjFromFullPath(self.rootFolder)
        self.objDb.updateObjByUuid(folderObj["uuid"], 
                                           {"folderCollectionId": self.targetCollectionId})
        cl(folderObj, {"folderCollectionId": self.targetCollectionId})

class folderCollectionServer(threadSvrBase.notifierServer):
    '''
    classdocs
    '''
    def __init__(self, port):
        '''
        Constructor
        '''
        super(folderCollectionServer, self).__init__(port)
        
    def create(self, rootPath, retNum, username, passwd, notifyServer = None):
        threadInst = workThread(rootPath, username, passwd, notifyServer = notifyServer)
        res = threadInst.getPartialResult(retNum)
        clientId = self.createProcessor(threadInst)
        ncl(clientId)
        threadInst.msg("gen", {})
        return threadInst.partialRes
    create.exposed = True
    

    
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(folderCollectionServer(gXmlRpcServerPort))
コード例 #8
0
            self.threadHndl2ProcessorListDict[threadHandle] = [callbackServerUrl]
            self.threadHndlAndProcessorHndl2ThreadDict[(threadHandle, callbackServerUrl)] = newProcessor
            newProcessor.start()
            #newProcessor.msg("subClassRun", {})
            cl('returnning:', callbackServerUrl)
            return callbackServerUrl
    def stop(self):
        cl('-----------------------exist server called')
        for callbackHndl in self.threadHndl2ProcessorListDict:
            self.threadHndlAndProcessorHndl2ThreadDict[(callbackHndl, self.threadHndl2ProcessorListDict[callbackHndl][0])].msg("exitThread", {})
    stop.exposed = True
    
    def register(self, serverUrl):
        paramDict = {"serverUrl": serverUrl}
        newProcessor = serverThread(paramDict)
        return self.createProcessor(newProcessor)
    register.exposed = True
        
    def complete(self, threadHandle, processorHndl):
        cl(threadHandle, processorHndl)
        t = self.threadHndlAndProcessorHndl2ThreadDict[(threadHandle, processorHndl)]
        t.complete(processorHndl)
    complete.exposed = True



    
if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    xmlRpcServerBase.startMainServer(xmlRpcServerWithWorkerThreadBase(gXmlRpcServerPort))