Skip to content
Snippets Groups Projects
Commit c8cdb6b1 authored by Nils Breyer's avatar Nils Breyer
Browse files

support TrainAnnouncement schema 1.8

parent e6414854
No related branches found
No related tags found
No related merge requests found
# Changelog
## 1.1.2 (2022-01-26)
## 1.2.0 (2023-02-16)
* NEW: Collect new column DepartureDateOTN for announcements (schema 1.8)
* CHANGED: TechnicalDateTime renamed to LocationDateTimeOTN (schema 1.8)
* CHANGED: TechnicalTrainIdent renamed to OperationalTrainNumber (schema 1.8)
* REMOVED: --compress flag (was not implemented anyway)
## 1.1.2 (2023-01-26)
* FIX: Simultaneous writes to csv can cause invalid format in output file
## 1.1.1 (2022-01-13)
## 1.1.1 (2023-01-13)
* FIX: Connection not initialized if status file unreadable
## 1.1.0 (2022-01-13)
## 1.1.0 (2023-01-13)
* NEW: Warn on low disk space
## 1.0.0 (2022-01-13)
## 1.0.0 (2023-01-13)
* NEW: Create output directory if not existing
......
......@@ -3,17 +3,16 @@
Crawler for Trafikverkets API
```
usage: crawl.py [-h] [-s] [-c] [-f] -l locationSignature [-o path] [-w webhookurl] [-a authkey] [-v] objecttype
usage: crawl.py [-h] [-s] [-f] -l locationSignature [-o path] [-w webhookurl] [-a authkey] [-v] [-q] objecttype
Crawler for Trafikverket's Trafikinfo API
Crawler for Trafikverket's Trafikinfo API - version 1.2.0
positional arguments:
objecttype the API objecttype to crawl
optional arguments:
options:
-h, --help show this help message and exit
-s, --stream use streaming in real-time instead of daily crawling
-c, --compress write zip compressed csv files
-f, --force force new connection instead of reconnecting
-l locationSignature, --locationSignature locationSignature
the location signature of the station to crawl data for
......@@ -24,6 +23,7 @@ optional arguments:
-a authkey, --authkey authkey
The API authkey to use as obtained from https://api.trafikinfo.trafikverket.se/Account/Register
-v, --verbose Prints extra debug information
-q, --query Print query only instead of starting a crawler
```
*Example:*
......
......@@ -12,7 +12,7 @@ from crawler import StreamCrawler
import crawler.trafikverket
VERSION = "1.1.2"
VERSION = "1.2.0"
parser = argparse.ArgumentParser(description="Crawler for Trafikverket's Trafikinfo API - version " + VERSION)
......@@ -28,10 +28,10 @@ parser.add_argument('-s', '--stream',
help='use streaming in real-time instead of daily crawling'
)
parser.add_argument('-c', '--compress',
action='store_true',
help='write zip compressed csv files'
)
# parser.add_argument('-c', '--compress',
# action='store_true',
# help='write zip compressed csv files'
# )
parser.add_argument('-f', '--force',
action='store_true',
......@@ -86,8 +86,6 @@ if args.output is None:
else:
#specified, check if exists
if not os.path.isdir(args.output):
print("The output path {output} does not exist and will be created.".format(output=args.output))
try:
os.makedirs(args.output)
print("The output path {output} has been created.".format(output=args.output))
......@@ -132,11 +130,6 @@ elif args.objecttype == "TrainMessage" and not args.stream:
if not args.webhook is None:
c.message_webhook_url = args.webhook
c.compress = args.compress
if c.compress:
print("Compression not supported yet.")
if args.verbose:
c.DEBUG = True
print("Verbose output enabled.")
......
......@@ -38,8 +38,8 @@ COLUMNS_TRAINANNOUNCEMENT = [
"ProductInformation",
"ScheduledDepartureDateTime",
"Service",
"TechnicalDateTime",
"TechnicalTrainIdent",
"LocationDateTimeOTN",
"OperationalTrainNumber",
"TimeAtLocation",
"TimeAtLocationWithSeconds",
"ToLocation",
......@@ -50,7 +50,8 @@ COLUMNS_TRAINANNOUNCEMENT = [
"WebLink",
"WebLinkName",
"ViaFromLocation",
"ViaToLocation"
"ViaToLocation",
"DepartureDateOTN"
]
COLUMNS_TRAINMESSAGE = [
......@@ -110,7 +111,7 @@ def build_query(authkey, attributes = {}, filter = "", columns = []):
def get_train_announcement_query(authkey, startTime = None, endTime=None, locationSignature= "", sseurl=False, limit=None):
attributes = {
"objecttype": "TrainAnnouncement",
"schemaversion": "1.6",
"schemaversion": "1.8",
"orderby": "TimeAtLocation",
"includedeletedobjects": "true",
"sseurl": sseurl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment