示例#1
0
    def automateImageProcessing(self, eachAction):
        try:
            path = self.openPathFile()
            eachActionValue = GeneralExceptionHandling.getJsonData(GeneralExceptionHandling, 'open', eachAction)

            if eachActionValue:
                if len(eachActionValue)>1:
                    pathValue = GeneralExceptionHandling.getJsonData(GeneralExceptionHandling
                                                                 , eachActionValue[0], path)
                    if pathValue:
                        if MainRPA.imageProcessing(MainRPA, pathValue, eachActionValue[1]):
                            print('image processing complete')
                            return True
                        else:
                            print('image processing faild')
                        return False
                    else:
                        print('json error in automateImageProcessing')

                        return False
                else:
                    print('error in array size in automateImageProcessing greater than 1', eachActionValue)
            else:
                print('json error in automateImageProcessing')
                return False
        except Exception as e:
            print('error in automateImageProcessing', e)
            return False
示例#2
0
    def loadValidtionLocatorToDb(self, layer_name):
        try:
            validationFile = self.LocatorDirectory + layer_name + '_validation.json'
            generalExceptionHandling = GeneralExceptionHandling()
            validation = generalExceptionHandling.readFileAndReturnJson(
                validationFile)

            # print(validation.keys())
            df = pd.DataFrame()
            for eachKey in validation.keys():
                # print(validation[eachKey])
                locatorData = validation[eachKey]
                for locatorId, locator in locatorData.items():
                    if len(df.columns) > 0:
                        temDataFrame = pd.DataFrame({
                            'locatorData': locator,
                            'locator_id': locatorId
                        })
                        df = df.append(temDataFrame)
                    else:
                        df['locatorData'] = locator
                        df.loc[df['locatorData'] == locator,
                               'locator_id'] = locatorId
                df.loc[df['locatorData'] == locator, 'flag'] = eachKey
            # print(df)

            if self.dataFrameToDb(df, layer_name + '_validation'):
                return True
            else:
                return False
        except Exception as e:
            print('error in loadValidationLocatorToDb in LocatorFromDB', e)
            return False
示例#3
0
    def __init__(self, path):
        self.path = path
        self.dbOption = GeneralExceptionHandling.getJsonDataRecurssive(
            GeneralExceptionHandling, 'DB', self.path)
        self.LocatorDirectory = GeneralExceptionHandling.getJsonDataRecurssive(
            GeneralExceptionHandling, 'DataFetching,filesPath', self.path)
        self.getConnection()
        self.layerConnectorName = 'datafeth_locator_'
        self.layerConnect = self.getLocatorFromDb('layer_connect')

        if self.layerConnect.empty:
            print('not data in layer_connect')
            exit()
示例#4
0
    def __init__(self, path):
        CsvHandling.__init__(self)
        GeneralExceptionHandling.__init__(self)
        self.path = path
        self.locatorValidationArray = dict()

        self.dataFetchingValidationLocatorPath = self.getJsonDataRecurssive(
            'DataFetching,validationLocator', self.path)
        self.dataFetchingFilesPath = self.getJsonDataRecurssive(
            'DataFetching,filesPath', self.path)

        self.sqlConnect = SqlConnect(path)

        self.validationDebug = False
示例#5
0
    def reSelect(self, patternBuild, sourceDataProcessed, sourceData) -> str:
        """:returns regualr expression out put of :var patternBuild
        :argument patternBuild is a regular expression
        :argument sourceDataProcessed is regular expression applying data
        :argument sourceData is original data
        :returns matched string if not :returns False"""
        try:
            import re

            patternBuild = re.sub(r'\d', '\d', patternBuild)
            searhcObj = re.search(patternBuild, sourceDataProcessed)

            # print('pattern:', patternBuild)
            if searhcObj:
                patternMatch = searhcObj.group()
                patternMatch = self.regularExpressionHandling(patternMatch, 0)
                sourceData = sourceData.replace('\n', ' ')
                sourceFileMatch = re.search(patternMatch, sourceData, re.IGNORECASE)

                if sourceFileMatch:
                    sourceFileMatchString = GeneralExceptionHandling.regularExpressionHandling(GeneralExceptionHandling, patternMatch, 1)
                    return sourceFileMatchString
                else:
                    return False

            else:
                return False
        except Exception as e:
            print('error in searchDataInFuzzySearch\n', e)
            print(patternBuild)
            print('patter: ', patternMatch)
            print('patter other: ', sourceData)
示例#6
0
    def imageProcessing(self, options, imageName):
        try:
            from imageProcessing.imageProcessing import ImageProcessing

            imageProcessingObj = ImageProcessing()

            imageLocation = GeneralExceptionHandling.getJsonData(
                GeneralExceptionHandling, 'imageLocation', options)

            if imageLocation:
                openCvImage = imageProcessingObj.openCVReadImage(
                    imageLocation, imageName)
                contors = imageProcessingObj.getContours(
                    imageProcessingObj.openCVReadImage(imageLocation,
                                                       imageName))
                if imageProcessingObj.drawContours(openCvImage, contors):
                    return True
                else:
                    return False
            else:
                print('json error image location')
                return False
        except Exception as e:
            print('error from imageProcessing', e)
            return False
示例#7
0
    def setUp(self) -> None:
        # initial run
        pathFile = open('path.json', 'r')
        path = json.loads(pathFile.read())
        pathFile.close()

        path = GeneralExceptionHandling.getJsonData(GeneralExceptionHandling, 'linux', path)
        print('begin')
        self.locatorValidation = LocatorValidation(path)
    def ocrImage(self, imageName, imageExtension, ocrDocumentName,
                 imageFilePath, ocrFilePath):
        try:
            print('saving ocr: ', ocrFilePath + ocrDocumentName + '.txt')
            DrectoryHandling.createDirectory(DrectoryHandling, ocrFilePath)
            fp = open(ocrFilePath + ocrDocumentName + '.txt', 'w')

            tesseract = GeneralExceptionHandling.getJsonData(
                GeneralExceptionHandling, 'imagProcessing', self.path)
            tesseract = GeneralExceptionHandling.getJsonData(
                GeneralExceptionHandling, 'tesseract', tesseract)
            if tesseract:
                if tesseract == 'None':
                    ocrData = self.getOcr(imageFilePath + imageName + '.' +
                                          imageExtension)
                    if ocrData:
                        fp.write(ocrData)
                        fp.write(
                            pytesseract.image_to_string(imageFilePath +
                                                        imageName + '.' +
                                                        imageExtension))

                        fp.close()
                        return True
                else:
                    ocrData = self.getOcr(
                        imageFilePath + imageName + '.' + imageExtension,
                        tesseract)
                    if ocrData:
                        fp.write(ocrData)
                        fp.close()
                    else:
                        print('ocr handling failed')
                        fp.close()
                        return False
            else:
                return False

            return True
        except Exception as e:
            print('Error in ocrImage', e)
            return False
示例#9
0
    def automate(self, option):
        try:
            processFile = open('process.json', 'r')
            # process = json.loads(processFile.read())[option]
            process = GeneralExceptionHandling.getJsonData(GeneralExceptionHandling, option, json.loads(processFile.read()))
            processFile.close()

            if process:
                for eachProcessLine in process:
                    if not self.processLine(eachProcessLine):
                        return False
                return True
            else:
                print('json error in automate in automation')
                return False
        except Exception as e:
            print('error in automate', e)
            return False
示例#10
0
    def automateFirefox(self, values):
        try:
            path = self.openPathFile()

            openValue = GeneralExceptionHandling.getJsonData(GeneralExceptionHandling, 'open', values)
            if openValue:
                if len(openValue) >3:
                    if MainRPA.run(MainRPA, openValue[0], openValue[1], path, openValue[2], openValue[3]):
                        print('image processing complete')
                        return True
                    else:
                        print('image processing faild')
                        return False
                else:
                    print('open  array size should be 4', values)
                    return False
            else:
                print('json error in automateFirefox in automation')
                return False
        except Exception as e:
            print('error in auromatefirefox')
示例#11
0
 def __init__(self, path):
     GeneralExceptionHandling.__init__(self)
     self.path = path
     self.stringMatchConfidence = 90
     self.fuzzySearchOptimumLength = 6
     """ threshold will set to 90 and l_dist will be 0 for precision while less than fuzzySearchOptimumLength """
示例#12
0
    try:
        pathFile = open('path.json', 'r')
        path = json.loads(pathFile.read())
        pathFile.close()

        if len(sys.argv) == 4:
            if sys.argv[3] == 'rpa':
                if MainRPA.run(MainRPA, sys.argv[1], sys.argv[2], path):
                    print('Process complete')
            else:
                print('Process exit with error')
        elif len(sys.argv) == 3:
            if sys.argv[2] == 'imageProcessing':
                print('imageProcessing', sys.argv)
                # path = path[sys.argv[1]]
                path = GeneralExceptionHandling.getJsonData(
                    GeneralExceptionHandling, sys.argv[1], path)

                if path:
                    if MainRPA.imageProcessing(MainRPA, path, 'geek'):
                        print('image processing complete')
                    else:
                        print('image processing faild')
                else:
                    exit()
            elif sys.argv[2] == 'dataFetching':
                try:
                    from DataFetching.DataFetching import DataFetchingMain

                    pathValues = GeneralExceptionHandling.getJsonData(
                        GeneralExceptionHandling, sys.argv[1], path)
                    if pathValues: