def injectTestFile(self, srcFiles, dstDir, timeout): """ Copy test file and wait for import to complete. """ try: destFiles = [] for src in srcFiles: ext = pathModule.path(src).ext dstFile = os.path.join(dstDir, str(uuid.uuid1())+ext) destFiles.append((src, dstFile)) except: log.exception("Error source files:") return -1 try: for filePair in destFiles: shutil.copy(filePair[0],filePair[1]) except: log.exception("Error copying file:") return -1 self.importCount = len(srcFiles) self.event.wait(timeout) if not self.event.isSet(): log.error("notifyTestFile not called enough times (%s/%s)", len(srcFiles)-self.importCount, len(srcFiles)) else: log.info("All imports completed.") try: sf = omero.util.internal_service_factory( self.communicator(), "root", "system", retries=self.maxRetries, interval=self.retryInterval) except: log.exception("Failed to get Session: \n") return -1 p = omero.sys.Parameters() retVal = 0 for i in self.imageIds: query = "select i from Image i where i.id = " + "'" + i + "'" out = sf.getQueryService().findAllByQuery(query, p) if len(out) > 0: for item in out: fname = item._name._val log.info("Query on id=%s returned file %s", i, fname) else: log.error("No items found.") retVal = -1 try: sf.destroy() except: log.exception("Failed to get close session: \n") return retVal
def testListOrphans(self, gatewaywrapper): gatewaywrapper.loginAsUser() eid = gatewaywrapper.gateway.getUserId() imageList = list() for i in range(0, 5): imageList.append( gatewaywrapper.createTestImage( imageName=(str(uuid.uuid1()))).getName()) findImages = list(gatewaywrapper.gateway.listOrphans("Image")) assert len(findImages) == 5, "Did not find orphaned images" for p in findImages: assert p.getName( ) in imageList, "All images should have queried name" params = omero.sys.ParametersI() params.page(1, 3) findImagesInPage = list( gatewaywrapper.gateway.listOrphans("Image", eid=eid, params=params)) assert len( findImagesInPage) == 3, "Did not find orphaned images in page" for p in findImages: client = p._conn handle = client.deleteObjects('Image', [p.getId()], deleteAnns=True) try: client._waitOnCmd(handle) finally: handle.close()
def testListOrphans(self, gatewaywrapper): gatewaywrapper.loginAsUser() eid = gatewaywrapper.gateway.getUserId() imageList = list() for i in range(0,5): imageList.append(gatewaywrapper.createTestImage(imageName=(str(uuid.uuid1()))).getName()) findImages = list(gatewaywrapper.gateway.listOrphans("Image")) assert len(findImages) == 5, "Did not find orphaned images" for p in findImages: assert p.getName() in imageList, "All images should have queried name" params = omero.sys.ParametersI() params.page(1, 3) findImagesInPage = list(gatewaywrapper.gateway.listOrphans("Image", eid=eid, params=params)) assert len(findImagesInPage) == 3, "Did not find orphaned images in page" for p in findImages: client = p._conn handle = client.deleteObjects('Image', [p.getId()], deleteAnns=True) try: client._waitOnCmd(handle) finally: handle.close()
def _getNextMonitorId(self): """ Return next monitor ID and increment. The monitorID is a unique key to identify a monitor on the file system. In the present implementation this is a string generated by uuid.uuid1() :return: Next monitor Id :rtype: string """ return str(uuid.uuid1())
def __init__(self, eventTypes, pathMode, pathString, whitelist, blacklist, ignoreSysFiles, ignoreDirEvents, proxy): """ Set-up Monitor thread. After initialising the superclass and some instance variables try to create an FSEventStream. Throw an exeption if this fails. :Parameters: eventTypes : A list of the event types to be monitored. pathMode : The mode of directory monitoring: flat, recursive or following. pathString : string A string representing a path to be monitored. whitelist : list<string> A list of files and extensions of interest. blacklist : list<string> A list of subdirectories to be excluded. ignoreSysFiles : If true platform dependent sys files should be ignored. monitorId : Unique id for the monitor included in callbacks. proxy : A proxy to be informed of events """ AbstractPlatformMonitor.__init__(self, eventTypes, pathMode, pathString, whitelist, blacklist, ignoreSysFiles, ignoreDirEvents, proxy) self.log = logging.getLogger("fsserver."+__name__) #: an FSEvents.FSEventStream StreamRef object reference. self.streamRef = None #: FSEvents.CFRunLoop object reference. self.runLoopRef = None self.clientInfo = str(uuid.uuid1()) # # Without using the mutable array, ie using the Python list directly, # the code works but throws up a couple of horrible warnings: # "Oject of class OC_PythonArray autoreleased with no pool in place # - just leaking" # With the array there are still warnings about the strings whether # Python native strings are used or NSStrings. # # All of these warnings are eliminated by using a pool for the lifetime # of the NSMutableArray. # pool = NSAutoreleasePool.alloc().init() pathsToMonitor = NSMutableArray.alloc().init() ms = NSString.stringWithString_(self.pathsToMonitor) pathsToMonitor.insertObject_atIndex_(ms, 0) self.directory = fsDirectory.Directory(pathString=self.pathsToMonitor, whitelist=self.whitelist, pathMode=self.pathMode) self.streamRef = FSEvents.FSEventStreamCreate(FSEvents.kCFAllocatorDefault, self.callback, self.clientInfo, pathsToMonitor, FSEvents.kFSEventStreamEventIdSinceNow, 1, FSEvents.kFSEventStreamCreateFlagWatchRoot) # # Release the pool now that the NSMutableArray has been used. # del pool if self.streamRef == None: raise Exception('Failed to create FSEvent Stream') self.log.info('Monitor set-up on %s', str(self.pathsToMonitor)) self.log.info('Monitoring %s events', str(self.eTypes))
# set up mpi world recover number of nodes and rank of each process # Process of rank=0 acts as co-ordinating process and does the latex generation comm = mpi.COMM_WORLD size = comm.Get_size() rank = comm.Get_rank() name = mpi.Get_processor_name() # get the command line arguments try: opts, args = gop.getopt(argv, "h:u:p:c:e:r:o", [ "host", "user", "password", "control", "experiment", "rfid", "outputfilename" ]) except gop.error, msg: print >> sys.stderr, msg return 2 s_dir = str(uuid.uuid1()) + '/' d_args = {} d_args['d'] = s_dir for opt, arg in opts: if opt in ("-h", "--host"): host = arg.strip() d_args['host'] = host if opt in ("-u", "--user"): user = arg.strip() d_args['user'] = user if opt in ("-p", "--password"): password = arg.strip() d_args['password'] = password if opt in ("-c", "--control"): control = arg.strip() d_args['control'] = control
def mpi_run(argv): texfilename = 'test_n.tex'; # set up mpi world recover number of nodes and rank of each process # Process of rank=0 acts as co-ordinating process and does the latex generation comm = mpi.COMM_WORLD size = comm.Get_size() rank = comm.Get_rank() name= mpi.Get_processor_name() # get the command line arguments try: opts, args = gop.getopt(argv, "h:u:p:c:e:r:o", ["host","user","password","control","experiment", "rfid", "outputfilename"]) except gop.error, msg: print >>sys.stderr, msg return 2 s_dir = str(uuid.uuid1())+'/'; d_args={} d_args['d'] = s_dir; for opt, arg in opts: if opt in ("-h", "--host"): host=arg.strip() d_args['host']=host if opt in ("-u", "--user"): user=arg.strip() d_args['user']=user if opt in ("-p", "--password"): password=arg.strip() d_args['password']=password if opt in ("-c", "--control"): control=arg.strip() d_args['control']=control
def injectTestFile(self, srcFiles, dstDir, timeout): """ Copy test file and wait for import to complete. """ try: destFiles = [] for src in srcFiles: ext = pathModule.path(src).ext dstFile = os.path.join(dstDir, str(uuid.uuid1()) + ext) destFiles.append((src, dstFile)) except: log.exception("Error source files:") return -1 try: for filePair in destFiles: shutil.copy(filePair[0], filePair[1]) except: log.exception("Error copying file:") return -1 self.importCount = len(srcFiles) self.event.wait(timeout) if not self.event.isSet(): log.error("notifyTestFile not called enough times (%s/%s)", len(srcFiles) - self.importCount, len(srcFiles)) else: log.info("All imports completed.") try: sf = omero.util.internal_service_factory( self.communicator(), "root", "system", retries=self.maxRetries, interval=self.retryInterval) except: log.exception("Failed to get Session: \n") return -1 p = omero.sys.Parameters() retVal = 0 for i in self.imageIds: query = "select i from Image i where i.id = " + "'" + i + "'" out = sf.getQueryService().findAllByQuery(query, p) if len(out) > 0: for item in out: fname = item._name._val log.info("Query on id=%s returned file %s", i, fname) else: log.error("No items found.") retVal = -1 try: sf.destroy() except: log.exception("Failed to get close session: \n") return retVal
texfilename = "test_n.tex" # set up mpi world recover number of nodes and rank of each process # Process of rank=0 acts as co-ordinating process and does the latex generation comm = mpi.COMM_WORLD size = comm.Get_size() rank = comm.Get_rank() name = mpi.Get_processor_name() # get the command line arguments try: opts, args = gop.getopt( argv, "h:u:p:c:e:r:o", ["host", "user", "password", "control", "experiment", "rfid", "outputfilename"] ) except gop.error, msg: print >>sys.stderr, msg return 2 s_dir = str(uuid.uuid1()) + "/" d_args = {} d_args["d"] = s_dir for opt, arg in opts: if opt in ("-h", "--host"): host = arg.strip() d_args["host"] = host if opt in ("-u", "--user"): user = arg.strip() d_args["user"] = user if opt in ("-p", "--password"): password = arg.strip() d_args["password"] = password if opt in ("-c", "--control"): control = arg.strip() d_args["control"] = control