コード例 #1
0
def write_output(outfilename, data):
    # Write the data out so that we can track it
    try:
        with open(outfilename, "w") as outfile:
            outfile.write("[\n")
            for idx, (key, value) in utils.indexed_items(data.iteritems()):
                output = '    ["%s", "%s", "%s", "%s", %d, %d, %f]' % (
                    key[0],
                    key[1],
                    key[2],
                    key[3],
                    value[KEY_COUNT],
                    value[KEY_RUN_COUNT],
                    value[KEY_DURATION],
                )
                outfile.write(output)
                if idx >= 0:
                    outfile.write(",\n")
                else:
                    outfile.write("\n")
            outfile.write("]\n")
            return True
    except IOError as e:
        print("%s: %s" % (e.filename, e.strerror))
        return False
コード例 #2
0
ファイル: whitelist.py プロジェクト: weinrank/gecko-dev
    def checkDuration(self, test, file_name_index, file_duration_index):
        errors = {}
        for idx, (row_key, row_value) in utils.indexed_items(test.iteritems()):
            if row_value[file_duration_index] > DEFAULT_DURATION:
                filename = self.sanitize_filename(row_key[file_name_index])
                if filename in self.listmap and "ignoreduration" in self.listmap[filename]:
                    # we have defined in the json manifest max values
                    # (max found value * 2) and will ignore it
                    if row_value[file_duration_index] <= self.listmap[filename]["ignoreduration"]:
                        continue

                if filename not in errors:
                    errors[filename] = []
                errors[filename].append("Duration %s > %S" % (row_value[file_duration_index]), DEFAULT_DURATION)
        return errors
コード例 #3
0
def write_output(outfilename, data):
    # Write the data out so that we can track it
    try:
        with open(outfilename, 'w') as outfile:
            outfile.write("[\n")
            for idx, (key, value) in utils.indexed_items(data.iteritems()):
                output = "    [\"%s\", \"%s\", \"%s\", \"%s\", %d, %d, %f]" % (
                    key[0], key[1], key[2], key[3], value[KEY_COUNT],
                    value[KEY_RUN_COUNT], value[KEY_DURATION])
                outfile.write(output)
                if idx >= 0:
                    outfile.write(",\n")
                else:
                    outfile.write("\n")
            outfile.write("]\n")
            return True
    except IOError as e:
        print("%s: %s" % (e.filename, e.strerror))
        return False
コード例 #4
0
ファイル: whitelist.py プロジェクト: moipcr/Mypal
    def checkDuration(self, test, file_name_index, file_duration_index):
        errors = {}
        for idx, (row_key, row_value) in utils.indexed_items(test.iteritems()):
            if row_value[file_duration_index] > DEFAULT_DURATION:
                filename = self.sanitize_filename(row_key[file_name_index])
                if filename in self.listmap and \
                   'ignoreduration' in self.listmap[filename]:
                    # we have defined in the json manifest max values
                    # (max found value * 2) and will ignore it
                    if row_value[file_duration_index] <= \
                            self.listmap[filename]['ignoreduration']:
                        continue

                if filename not in errors:
                    errors[filename] = []
                errors[filename].append(
                    "Duration %s > %S" % (row_value[file_duration_index]),
                    DEFAULT_DURATION)
        return errors