예제 #1
0
 def load_module(self, module_name):
     if _debug(): print "SikuliLoader.load_module", module_name, self.path
     module_name = _stripPackagePrefix(module_name)
     p = ImageLocator.addImagePath(self.path)
     if not p: return None
     Sikuli.addModPath(p)
     return self._load_module(module_name)
예제 #2
0
 def load_module(self, module_name):
     if _debug():
         print "SikuliLoader.load_module", module_name, self.path
     module_name = _stripPackagePrefix(module_name)
     p = ImageLocator.addImagePath(self.path)
     if not p: return None
     Sikuli.addModPath(p)
     return self._load_module(module_name)
예제 #3
0
 def assertThat(self, text):        
     self.validate()
     self.logger.info("Asserting [%s]" % text)
     
     baselinePath = self.config.imageBaseline + "/assert/" +  str(Env.getOS()).lower() + "/" + text + ".png"
     baseline = Pattern(baselinePath)
     
     # TODO: Refactor to allow for using RegionFinder class so PNG attributes can be used
     try:
         ImageLocator().locate( baselinePath )            
         result = self.region.find(baseline)                    
         self.logger.info('%%s matched %%s', self.logger.getFormatter()(result), self.logger.getFormatter()(baseline))
     except FindFailed, e:            
         self.logger.error('%%s does not match %%s', self.logger.getFormatter()(self.region), self.logger.getFormatter()(baseline))
         raise Exception("Assertion failure")        
예제 #4
0
def getBundlePath():
    return ImageLocator.getBundlePath()
예제 #5
0
def setBundlePath(path):
    ImageLocator.setBundlePath(path)
예제 #6
0
def resetImagePath(path):
    ImageLocator.resetImagePath(path)
예제 #7
0
def removeImagePath(path):
    ImageLocator.removeImagePath(path)
예제 #8
0
def getImagePath():
    return [e for e in ImageLocator.getImagePath() if e]
예제 #9
0
def addImagePath(path):
    ImageLocator.addImagePath(path)
예제 #10
0
    def findBaselines(self):

        # If this is set we've already found stuff
        if self.collectionType: return

        for filename, nameType in ( \
                (self.entity.getCanonicalName(ancestorEntities=False, topLevel=False) + '/' + self.entity.getCanonicalName(),self.NAME_TYPE_FULL), \
                (self.entity.getCanonicalName(ancestorEntities=False, topLevel=False) + '/' + self.entity.getCanonicalName(ancestorEntities=1), self.NAME_TYPE_GENERIC), \
                (self.entity.getCanonicalName(ancestorEntities=False, topLevel=False) + '/' + self.entity.getClassName() + self.entity.getCanonicalName(rootEntity=False, ancestorEntities=False), self.NAME_TYPE_CLASS_ENTITY), \
                (self.entity.getCanonicalName(ancestorEntities=False, topLevel=False) + '/' + self.entity.getClassName(), self.NAME_TYPE_CLASS), \
                (self.entity.getClassName() + self.entity.getCanonicalName(rootEntity=False, ancestorEntities=False), self.NAME_TYPE_CLASS_ENTITY), \
                (self.entity.getClassName(), self.NAME_TYPE_CLASS)
            ):

            # single
            try:
                self.path = ImageLocator().locate(
                    filename + self.state + self.config.imageSuffix
                )[:-4] + ".png"  # get full path, minus .png extension
            except:
                pass  # file doesn't exist
            else:
                self.filename = filename
                self.nameType = nameType
                self.collectionType = self.COL_TYPE_SINGLE
                self.seriesRange = [
                    0,
                ]
                self.__logFound()
                return

            # sequence
            try:
                self.path = ImageLocator().locate(
                    filename + '-0' + self.state + self.config.imageSuffix
                )[:-4] + ".png"  # get full path, minus .png extension
            except:
                pass  # file doesn't exist
            else:
                self.filename = filename
                self.nameType = nameType
                self.collectionType = self.COL_TYPE_SEQUENCE
                self.seriesRange = [
                    0,
                ]
                self.__logFound()
                return

            # series
            seq = 0
            while True:
                try:
                    self.path = ImageLocator().locate(
                        filename + '[' + str(seq) + ']' + self.state +
                        self.config.imageSuffix
                    )[:-4] + ".png"  # get full path, minus .png extension
                except:
                    break  # end of series
                else:
                    seq += 1

            if seq > 0:
                self.filename = filename
                self.nameType = nameType
                self.collectionType = self.COL_TYPE_SERIES
                self.seriesRange = range(0, seq)
                self.__logFound()
                return

            # sequence + series
            seq = 0
            while True:
                try:
                    self.path = ImageLocator().locate(
                        filename + '[' + str(seq) + ']-0' + self.state +
                        self.config.imageSuffix
                    )[:-4] + ".png"  # get full path, minus .png extension
                except:
                    break  # end of sequence
                else:
                    seq += 1

            if seq > 0:
                self.filename = filename
                self.nameType = nameType
                self.collectionType = self.COL_TYPE_SERIES_SEQUENCE
                self.seriesRange = range(0, seq)
                self.__logFound()
                return

            self.logger.trace(
                "failed to find image on disk [\"%s%s\"] nameType=%s" %
                (filename, self.state, nameType))

        raise ImageMissingException(
            "cannot find image on disk [\"%s%s\"]" % (filename, self.state)
        )  # if we don't have single image or sequence, file cannot be found