diff --git a/README.md b/README.md index caea6453c..30b13311e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Development Installation ------------------------ 1. Make sure you have the development dependencies installed -2. Place `septa_bus.zip`, `septa_rail.zip`, and `patco.zip` in the gtfs folder +2. Place `septa_bus.zip`, `septa_rail.zip`, and `patco.zip` in the otp_data folder 3. Run `vagrant up` 4. See the app at http://localhost:8024! See OpenTripPlanner at http://localhost:9090. 5. Running `gulp watch` from `/opt/app/src` will automatically collect static files together when changes are detected for Django template consumption. diff --git a/deployment/ansible/roles/cac-tripplanner.otp-data/defaults/main.yml b/deployment/ansible/roles/cac-tripplanner.otp-data/defaults/main.yml index 42f3a32f2..74fe272fc 100644 --- a/deployment/ansible/roles/cac-tripplanner.otp-data/defaults/main.yml +++ b/deployment/ansible/roles/cac-tripplanner.otp-data/defaults/main.yml @@ -4,3 +4,5 @@ #otp_data_dir: /var/otp otp_osm_source: https://s3.amazonaws.com/metro-extracts.mapzen.com/philadelphia_pennsylvania.osm.pbf otp_osm_filename: /var/otp/philadelphia.osm.pbf +otp_repo: "https://github.com/azavea/OpenTripPlanner.git" +otp_version: "develop" diff --git a/deployment/ansible/roles/cac-tripplanner.otp-data/files/gtfs/.gitignore b/deployment/ansible/roles/cac-tripplanner.otp-data/files/otp_data/.gitignore similarity index 82% rename from deployment/ansible/roles/cac-tripplanner.otp-data/files/gtfs/.gitignore rename to deployment/ansible/roles/cac-tripplanner.otp-data/files/otp_data/.gitignore index b2f5b9ad7..186451983 100644 --- a/deployment/ansible/roles/cac-tripplanner.otp-data/files/gtfs/.gitignore +++ b/deployment/ansible/roles/cac-tripplanner.otp-data/files/otp_data/.gitignore @@ -1,4 +1,4 @@ # Ignore files in this directory * # Except .gitignore -!.gitignore +!.gitignore \ No newline at end of file diff --git a/deployment/ansible/roles/cac-tripplanner.otp-data/files/validate_feed.py b/deployment/ansible/roles/cac-tripplanner.otp-data/files/validate_feed.py new file mode 100755 index 000000000..01e042abb --- /dev/null +++ b/deployment/ansible/roles/cac-tripplanner.otp-data/files/validate_feed.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +# Check GTFS feeds have no errors and are current, using feedvalidator.py + +import os +import subprocess +import sys + +def validate_feed(feed_file): + print("Validating GTFS %s..." % feed_file) + p = subprocess.Popen(['feedvalidator.py', '--output=CONSOLE', + '-m', '-n', feed_file], stdout=subprocess.PIPE) + out = p.communicate() + res = out[0].split('\n') + for ln in res: + print(ln) + # find output line with count of errors/warnings + errct = res[-2:-1][0] + if errct.find('error') > -1: + print("Feed validator found errors in " + feed_file + ": " + errct + ".") + sys.exit(1) + elif out[0].find('this feed is in the future,') > -1: + print("Feed validator found GTFS not in service until future.") + sys.exit(2) + elif out[0].find('feed expired on') > -1: + print("Feed validator found GTFS has expired.") + sys.exit(3) + else: + if errct.find('successfully') > -1: + print("Feed looks great: " + errct + ".") + else: + # have warnings + print("Feed " + feed_file + " looks ok: " + errct[7:] + ".") + +# validate all zip files in current directory as GTFS +for p, ds, fs in os.walk('.'): + for f in fs: + if f.endswith('.zip'): + validate_feed(os.path.join(p, f)) diff --git a/deployment/ansible/roles/cac-tripplanner.otp-data/handlers/main.yml b/deployment/ansible/roles/cac-tripplanner.otp-data/handlers/main.yml index d3626fe61..9ae16e935 100644 --- a/deployment/ansible/roles/cac-tripplanner.otp-data/handlers/main.yml +++ b/deployment/ansible/roles/cac-tripplanner.otp-data/handlers/main.yml @@ -1,12 +1,11 @@ +--- - name: Validate GTFS - command: feedvalidator.py -m -o CONSOLE {{ otp_data_dir }}/{{ item }}.zip - with_items: otp_gtfs_sources - register: command_result - failed_when: "'This feed expired on' in command_result.stdout or - 'this feed is in the future,' in command_result.stdout" - notify: Build OTP Graph + command: python validate_feed.py + args: + chdir: "{{ otp_data_dir }}" - name: Build OTP Graph - command: "{{ otp_bin_dir }}/build-old {{ otp_data_dir }}/graph-config.xml - chdir={{ otp_bin_dir }}" + command: /usr/bin/java -Xmx{{ otp_process_mem }} -jar {{ otp_jarfile }} --build {{ otp_data_dir }} + args: + chdir: "{{ otp_bin_dir }}" notify: Restart OpenTripPlanner diff --git a/deployment/ansible/roles/cac-tripplanner.otp-data/tasks/main.yml b/deployment/ansible/roles/cac-tripplanner.otp-data/tasks/main.yml index 2f10b6ce7..575ed843b 100644 --- a/deployment/ansible/roles/cac-tripplanner.otp-data/tasks/main.yml +++ b/deployment/ansible/roles/cac-tripplanner.otp-data/tasks/main.yml @@ -2,15 +2,14 @@ - name: Create Directory for OSM and GTFS file: path={{ otp_data_dir }} state=directory -- name: Download Philadelphia OSM Data - get_url: url={{ otp_osm_source }} - dest={{ otp_osm_filename }} - notify: Build OTP Graph +- name: Copy Feed Validator + copy: src=validate_feed.py dest="{{ otp_data_dir }}" - name: Copy OTP Data - copy: src=./ dest="{{ otp_data_dir }}/" owner={{ansible_ssh_user}} group={{ansible_ssh_user}} mode=0664 + copy: src=./otp_data/ dest="{{ otp_data_dir }}/" owner={{ansible_ssh_user}} group={{ansible_ssh_user}} mode=0664 notify: Validate GTFS -- name: Save graph-config.xml - template: src=graph-config.xml.j2 dest={{ otp_data_dir }}/graph-config.xml +- name: Download Philadelphia OSM Data + get_url: url={{ otp_osm_source }} + dest={{ otp_osm_filename }} notify: Build OTP Graph diff --git a/gtfs b/gtfs deleted file mode 120000 index 00f69721e..000000000 --- a/gtfs +++ /dev/null @@ -1 +0,0 @@ -deployment/ansible/roles/cac-tripplanner.otp-data/files/gtfs/ \ No newline at end of file diff --git a/otp_data b/otp_data new file mode 120000 index 000000000..cd4bc73e6 --- /dev/null +++ b/otp_data @@ -0,0 +1 @@ +deployment/ansible/roles/cac-tripplanner.otp-data/files/otp_data/ \ No newline at end of file