def run(self, args):
        retries = 5
        interval = 3
        dropBoxDir = "DropBox"
        dirImportWait = 60
        pathMode = "Follow"

        sf = omero.util.internal_service_factory(self.communicator(),
                                                 "root",
                                                 "system",
                                                 retries=retries,
                                                 interval=interval)
        try:
            configService = sf.getConfigService()
            dropBoxBase = configService.getConfigValue("omero.data.dir")
            dropBoxBase = os.path.join(dropBoxBase, dropBoxDir)
        finally:
            sf.destroy()

        config = None  # Satisfies flake8 but needs fixing

        fsServer = self.communicator().stringToProxy(config.serverIdString)
        fsServer = monitors.MonitorServerPrx.checkedCast(fsServer.ice_twoway())

        identity = self.communicator().stringToIdentity(config.clientIdString)

        mClient = MockMonitor(dropBoxBase)
        adapter = self.communicator().createObjectAdapter(
            config.clientAdapterName)
        adapter.add(mClient, identity)
        adapter.activate()

        mClientProxy = monitors.MonitorClientPrx.checkedCast(
            adapter.createProxy(identity))
        monitorType = monitors.MonitorType.__dict__["Persistent"]
        eventTypes = [
            monitors.EventType.__dict__["Create"],
            monitors.EventType.__dict__["Modify"]
        ]
        pathMode = monitors.PathMode.__dict__[pathMode]
        serverId = fsServer.createMonitor(monitorType, eventTypes,
                                          pathMode, dropBoxBase,
                                          list(config.fileTypes), [],
                                          mClientProxy, 0.0, True)

        mClient.setId(serverId)
        mClient.setServerProxy(fsServer)
        mClient.setSelfProxy(mClientProxy)
        mClient.setDirImportWait(dirImportWait)
        mClient.setMaster(self)
        fsServer.startMonitor(serverId)

        self.communicator().waitForShutdown()

        if mClient is not None:
            mClient.stop()
        fsServer.stopMonitor(id)
        fsServer.destroyMonitor(id)
示例#2
0
 def testEmptyAdd(self):
     MockMonitor().fsEventHappened('', [])  # Does nothing.
示例#3
0
 def testBadId(self):
     with pytest.raises(omero.ApiUsageException):
         MockMonitor().fsEventHappened('foo', [])
示例#4
0
 def testBadFileId(self):
     # Could cause infinite loop
     with pytest.raises(omero.ApiUsageException):
         MockMonitor().fsEventHappened('', [monitors.EventInfo()])
示例#5
0
 def setup_method(self, method):
     self.client = MockMonitor()
     self.driver = Driver(self.client)