BlinkTagInc / gtfs-to-html

Build human readable transit timetables as HTML or PDF from GTFS.
https://gtfstohtml.com
MIT License
181 stars 57 forks source link

Unable to create pdf timetables #77

Closed turbobenny closed 4 years ago

turbobenny commented 4 years ago

After a few weeks of trying to get gtfs-to-html work on a windows machine,I nearly succeeded. It works now until the point, where it should generate pdf timetables. There it stops not knowing which directory or file it should the timetables generate to. It refers to "views\timetable\timetablepage_full.pug", but I don't know what to do now. Do I have to create a directory or file now myself? And where? To what directory? Or do I need to make amendmends to an existing file? I don't understand what do do now. Ithink this is the last step, and I would so like gtfs-to-html to work for me. Thank you for your help. This is what it says:

VBB: Generating HTML timetables [-----------------------------------] 0/3273512 Error: Error: ENOENT: no such file or directory, open 'views\timetable\timetable page_full.pug' (node:864) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or dire ctory, open 'views\timetable\timetablepage_full.pug' at Object.openSync (fs.js:458:3) at Object.readFileSync (fs.js:360:35) at handleTemplateCache (C:\Users\Heinz-Jürgen Schücke\AppData\Roaming\npm\no de_modules\gtfs-to-html\node_modules\pug\lib\index.js:239:37) at Object.exports.renderFile (C:\Users\Heinz-Jürgen Schücke\AppData\Roaming\ npm\node_modules\gtfs-to-html\node_modules\pug\lib\index.js:452:10) at Object.exports.renderFile (C:\Users\Heinz-Jürgen Schücke\AppData\Roaming\ npm\node_modules\gtfs-to-html\lib\file-utils.js:99:24) at Object.exports.generateHTML (C:\Users\Heinz-Jürgen Schücke\AppData\Roamin g\npm\node_modules\gtfs-to-html\lib\utils.js:1153:32) at C:\Users\Heinz-Jürgen Schücke\AppData\Roaming\npm\node_modules\gtfs-to-ht ml\lib\gtfs-to-html.js:74:35 at async Promise.all (index 0) at async C:\Users\Heinz-Jürgen Schücke\AppData\Roaming\npm\node_modules\gtfs -to-html\bin\gtfs-to-html.js:68:5 (node:864) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This e rror originated either by throwing inside of an async function without a catch b lock, or by rejecting a promise which was not handled with .catch(). To terminat e the node process on unhandled promise rejection, use the CLI flag --unhandled -rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejection s_mode). (rejection id: 2) (node:864) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprec ated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

brendannee commented 4 years ago

Can you share with me your config.json file? or your codebase?

This could be a Windows-specific issue - the code that tries to find find the tempate directory is here: https://github.com/BlinkTagInc/gtfs-to-html/blob/master/lib/file-utils.js#L17

turbobenny commented 4 years ago

Hallo, thanks for your answer. I must add, that I am a total amateur. At the beginning I was unable to set a path for the config.json file. No path I set was accepted. It always said "can't find configuration file". In the end I solved it by looking into the package.json file where the program might look for it, The directory was System 32. I copied my config.json file into it and it worked. Finally I want to add, that I installed globally, so it is in &Appdata%. I set no custom template.

My config.json file { "mongoUrl": "mongodb://localhost:27017/gtfs", "agencies": [{ "agency_key": "VBB", "url": "https://transitfeeds.com/p/verkehrsverbund-berlin-brandenburg/213/latest/download" }], "beautify": false, "coordinatePrecision": 5, "dateFormat": "DD.MM.YYYY", "daysShortStrings": ["Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"], "daysStrings": ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Sonnabend", "Sonntag"], "defaultOrientation": "vertical", "effectiveDate": "02.06.2020", "interpolatedStopSymbol": "•", "interpolatedStopText": "Estimated time of arrival", "linkStopUrls": true, "mapboxAccessToken": "pk.eyXaX5F8oCJSYedim3yCnTGsVBfnRjsoXdy4Ej7ZZZydrCn2WMDXha5bPj5.bPj5xsBo8u8N8GJqJh", "menuType": "jump", "noDropoffSymbol": "null", "noDropoffText": "No drop off available", "noHead": false, "noPickupSymbol": "null", "noPickupText": "No pickup available", "noServiceSymbol": "null", "noServiceText": "No service at this stop", "outputFormat": "pdf", "requestDropoffSymbol": "null", "requestDropoffText": "Must request drop off", "requestPickupSymbol": "null", "requestPickupText": "Request stop - call for pickup", "serviceNotProvidedOnText": "Service not provided on", "serviceProvidedOnText": "Service provided on", "showArrivalOnDifference": null, "showMap": false, "showOnlyTimepoint": true, "showRouteTitle": true, "showStopCity": false, "showStopDescription": false, "skipImport": false, "sortingAlgorithm": "common", "templatePath": "views/timetable", "timeFormat": "hh:mma", "useParentStation": true, "verbose": true, "zipOutput": false }

The code: const path = require('path');

const archiver = require('archiver'); const beautify = require('js-beautify').html_beautify; const fs = require('fs-extra'); const pug = require('pug'); const puppeteer = require('puppeteer'); const sanitize = require('sanitize-filename'); const untildify = require('untildify');

const formatters = require('./formatters');

/*

/*

/*

/*

/*

/*

/*

Thank you. Regards

brendannee commented 4 years ago

It's having trouble finding the path to the template directory.

Can you try removing the templatePath config option entirely from your config.json file (to s

Or try putting the full path to the template directory in your config.json for templatePath? Something like

C:\Users\Heinz-Jürgen Schücke\AppData\Roaming\npm\node_modules\gtfs-to-html\views\timetable

turbobenny commented 4 years ago

Hallo, sorry for the delay, but yesterday I didn't have the time to test what you proposed. Today I tested with "HTML". Removing the templatePath config option entirely from my config.json file worked. The program went through. The second, putting the full path to the template directory in my config.json did not work, but I'll try again. Tomorrow I'll try the same with "PDF" and I'll tell you the resullts. THank you very much again. The file I am working on is very big, and in fact I only need one agency. Do I have to delete the other agencies manually or is there a shorter way to get rid of thhem? Regards turbobenny