Search in sources :

Example 1 with FileUtilsException

use of org.wikivoyage.listings.utils.FileUtilsException in project wikivoyage-listings by baturin.

the class Main method dailyUpdate.

private static void dailyUpdate(CommandLine cl, HashMap<String, OutputFormat> formats) throws IOException, FileUtilsException {
    createWorkingDir();
    createListingsDir();
    createDumpsCacheDir();
    DumpDownloader downloader = new DumpDownloader();
    for (String language : Languages.getLanguageCodes()) {
        log.info("Processing language " + language);
        List<String> dumpDates = downloader.listDumps(language);
        if (dumpDates.size() == 0) {
            continue;
        }
        String latestDumpDate = dumpDates.get(0);
        if (cl.latestCount != null) {
            log.info("Processing the latest " + cl.latestCount + " dumps");
            dumpDates = dumpDates.subList(0, cl.latestCount);
        }
        for (String dumpDate : dumpDates) {
            log.info("Processing dump " + dumpDate);
            try {
                processDump(downloader, language, latestDumpDate, dumpDate, formats, !cl.doNotUseIntermediateFile);
            } catch (Exception e) {
                log.info("Failed to create dump " + dumpDate);
                log.debug("Exception: ", e);
                StringWriter sw = new StringWriter();
                e.printStackTrace(new PrintWriter(sw));
                log.debug("Stack trace: " + sw.toString());
            }
        }
    }
    System.exit(0);
}
Also used : DumpDownloader(org.wikivoyage.listings.input.DumpDownloader) StringWriter(java.io.StringWriter) FileUtilsException(org.wikivoyage.listings.utils.FileUtilsException) DumpReadException(org.wikivoyage.listings.input.DumpReadException) IOException(java.io.IOException) WriteOutputException(org.wikivoyage.listings.output.WriteOutputException) PrintWriter(java.io.PrintWriter)

Aggregations

IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 DumpDownloader (org.wikivoyage.listings.input.DumpDownloader)1 DumpReadException (org.wikivoyage.listings.input.DumpReadException)1 WriteOutputException (org.wikivoyage.listings.output.WriteOutputException)1 FileUtilsException (org.wikivoyage.listings.utils.FileUtilsException)1