示例#1
0
def main(argv):

    options = Options()
    options.workingDir = pathlib.Path("./.download")
    options.parseCommandLine(argv)

    eutl_schema_path = options.xsdDir / "ts_119612v020201_201601xsd.xsd"

    if options.printVersionAndExit:
        printVersion()
        sys.exit()

    if not check_preconditions(options):
        Logger.LogError("Preconditions not satisfied, exiting")
        return False

    try:
        EuTL = TrustList(options.urlLotl, MimeType.Xml, "EU",
                         str(eutl_schema_path))
        EuTL.Update(options.localTListPath(), options.force)
        EuTL.DownloadChildren()
        EuTL.PostProcess(options.localCachePath())
        EuTL.SaveCetificatesOnDisk(options.localTrustCertPath())
        # EuTL.Print()

        Logger.LogInfo(
            "Found {0} trust service providers and {1} services.".format(
                sum(len(x.TrustServiceProviders) for x in EuTL.ListsOfTrust),
                len(EuTL.AllServices)))

        return True
    except Exception as ex:
        Logger.LogExceptionTrace("main: Got an error", ex)
示例#2
0
def check_preconditions(options):
    if not options.workingDir.is_dir():
        os.makedirs(options.workingDir)
    if not options.localTListPath().is_dir():
        os.makedirs(options.localTListPath())
    if not options.localTrustCertPath().is_dir():
        os.makedirs(options.localTrustCertPath())
    if not (options.xsdDir / "ts_119612v020201_201601xsd.xsd").exists():
        Logger.LogError("Could not find schema definition files")
        return False
    return True
示例#3
0
def delete_all_files(folder_path, pattern):

    if (folder_path is None or not folder_path.exists()):
        Logger.LogError("Folder does not exist: {0}".folder_path)
        return

    Logger.LogInfo(
        "Deleting existing certificate files in directory {0}".format(
            folder_path))

    cert_files = list(folder_path.glob(pattern))

    for cert_file in cert_files:
        os.remove(cert_file)

    Logger.LogInfo("Deleted {0} {1} files".format(len(cert_files), pattern))