-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21667ea
commit 2b01eff
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-FileCopyrightText: 2024 Jonah Brüchert <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import sys | ||
from pathlib import Path | ||
import subprocess | ||
|
||
if len(sys.argv) < 2: | ||
print("Argument run-reason is missing.") | ||
print("Must be one of timer, merge-request") | ||
sys.exit(1) | ||
|
||
run_reason = sys.argv[1] | ||
feed_dir = Path("feeds/") | ||
|
||
match run_reason: | ||
case "timer": | ||
for feed in feed_dir.glob("*.json"): | ||
subprocess.check_call(["./src/fetch.py", str(feed.absolute())]) | ||
case "merge-request": | ||
changed_files = subprocess.check_output( | ||
["git", "diff", "--name-only", "-r", "HEAD^1", "HEAD"]) \ | ||
.decode().splitlines() | ||
|
||
changed_feeds = [f for f in changed_files if | ||
f.startswith("feeds/") and f.endswith(".json")] | ||
|
||
for feed in changed_feeds: | ||
subprocess.check_call(["./src/fetch.py", feed]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-FileCopyrightText: 2024 Jonah Brüchert <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import subprocess | ||
import time | ||
import sys | ||
|
||
|
||
def run_motis_import() -> bool: | ||
p = subprocess.Popen(["motis", "--import.require_successful", "1"], | ||
stderr=subprocess.PIPE) | ||
|
||
for line in iter(p.stderr.readline, ""): | ||
if p.poll(): | ||
return False | ||
|
||
sys.stdout.buffer.write(line) | ||
if b"system boot finished" in line: | ||
p.terminate() | ||
return True | ||
else: | ||
time.sleep(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
if run_motis_import(): | ||
sys.exit(0) | ||
else: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-FileCopyrightText: 2023 Jonah Brüchert <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|