示例#1
0
            log.info("'{_ShortName}' data retrieved. Generating CSV.".format(
                **locals()))
            strHeadings = ",".join(
                [repr(i).replace("'", '"') for i in headings])
            fh.write(strHeadings + "\n")
            for row in RS:
                row = ",".join(
                    tuple([
                        '"' + str(val).replace('"', "") +
                        '"' if val is not None else '""' for val in row
                    ]))
                fh.write(row + "\n")

            if _WRITE_CSV_TO_DISK:
                log.info("Writing {name} to disk.".format(**locals()))
                fh.seek(0)
                with open(name, 'w') as csvFile:
                    csvFile.write(fh.read())
            _FilesAndData.append([name, fh.getvalue()])
        else:
            errors += 1
            log.critical(
                "No data retrieved for '{_ShortName}'".format(**locals()))
except Exception as e:
    errors += 1
    log.critical("Exception on getting data: " + str(e))

# ~
# GENERATE ZIP
# ~