Coder Social home page Coder Social logo

fahrgastrechte-autofill's Introduction

Fahrgastrechte Autofill [WIP]

Ein kleines Programm um das Fahrgastrechte-Formular der DB einfacher auszufüllen.

Features

Stammdaten speichern

Nach dem Ausfüllen werden die Daten auch in der Datei fields.json gespeichert. Wenn diese in defaults.json umbenannt wird, werden die Daten beim Start des Programms eingelesen und als Stanard-Werte für die Felder genommen (zB nützlich für Kontodaten und Adresse)

Daten aus Buchung importieren

Daten aus Buchung können importiert werden. Dafür muss die Buchungsnummer und der Nachname mit den Kommandozeilenparametern --auftragsnummer und --nachname angegeben werden.

python3 fahrgastrechte.py --auftragsnummer ABC123 --nachname Mustermensch

Daten aus ICE Portal importieren

Die Daten zum aktuellen Zug können automatisch aus dem ICE Portal importiert werden. Dabei ist es sowohl möglich, die planmäßige Abfahrt als auch die tatsächliche und planmäßige Ankunft einzutragen. Um die Abfahrtsdaten einzutragen, muss ggf der Startbahnhof mit dem Kommandozeilenparameter --from-stop oder -f und ggf der Zielbahnhof mit --to-stop oder -t angegeben werden. Statt des vollen Namens des Bahnhofs kann auch die evaNr angegeben werden.

python3 fahrgastrechte.py --from-stop "Berlin Hbf" --to-stop "Leipzig Hbf"

Nutzung: CLI

Benötigt werden pdftk sowie die Python-Module npyscreen, requests, fdfgen und beautifulsoup4, diese können zB via

pip3 install -r requirements.txt

installiert werden. pdftk sollte am besten aus den Paketquellen der jewieligen Distro installiert werden.

Danach einfach

python3 fahrgastrechte.py

Nutzung: tkinter

Alternativ steht auch ein graphischeres Interface zur Verfügung.

Benötigt werden pdftk sowie die Python-Module requests, fdfgen und beautifulsoup4, diese können zB via

pip3 install -r requirements-tkinter.txt

installiert werden. pdftk sollte am besten aus den Paketquellen der jewieligen Distro installiert werden.

Danach einfach

python3 fahrgastrechte-tkinter.py

Nutzung

Dort das Formular ausfüllen (nicht benötigte Felder leer lassen) und dann auf der letzten Seite "Generate Form" betätigen.

Danach wird eine Datei fahrgastrechte_[AKTUELLER TIMESTAMP].pdf erstellt.

Nutzung: CLI mit Docker

Um die Anwendung in einem eigenen Container laufen zu lassen, in dem alle Abhängigkeiten automatisch installiert sind, folgende Kommandos verwenden:

docker build -t fahrgastrechte-app .
docker run -it --rm -v $(pwd):/usr/src/app -w /usr/src/app fahrgastrechte-app

Copyright

Die Scrollable-Klasse in fahrgastrechte_tkinter.py basiert auf https://stackoverflow.com/a/47985165.

fahrgastrechte-autofill's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fahrgastrechte-autofill's Issues

Example defaults.json // docu missing

How can I fill in the fileds json, if i do not know which filed belongs to which field on the pdf.
Either add a example defaults.json or a docu, which is explanin the field numbers.

addwstr() error

If I want to test your program using this commands:

pip3 install -r requirements.txt
python3 fahrgastrechte.py

I got the following error:

Traceback (most recent call last):
  File "fahrgastrechte.py", line 177, in <module>
    print(main())
  File "fahrgastrechte.py", line 50, in main
    return npyscreen.wrapper_basic(functools.partial(run_menu, defaults, args))
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/npyssafewrapper.py", line 19, in wrapper_basic
    return curses.wrapper(call_function)
  File "/usr/lib/python3.6/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "fahrgastrechte.py", line 73, in run_menu
    npyscreen.TitleMultiLine, values=fields[n]['FieldStateOption'], name=title, value=i)))
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/fmFormMultiPage.py", line 74, in add_widget_intelligent
    return self.add_widget(*args, **keywords)
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/fmForm.py", line 384, in add_widget
    *args, **keywords)
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/wgtitlefield.py", line 69, in __init__
    self.make_contained_widgets()
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/wgtitlefield.py", line 86, in make_contained_widgets
    self.label_widget = textbox.Textfield(self.parent, relx=self.relx, rely=self.rely, width=len(self.name)+1, value=self.name, color=self.labelColor)
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/wgtextbox.py", line 44, in __init__
    self.update()
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/wgtextbox.py", line 132, in update
    self._print()
  File "/home/user/.local/lib/python3.6/site-packages/npyscreen/wgtextbox.py", line 299, in _print
    color
_curses.error: addwstr() returned ERR

Commands like python3 fahrgastrechte.py -h work as intended. The pip3 command worked like I expected.

Is the project is still alive?

Hi folks 👋

I just wanted to ask if the project is still alive. ;)

Traceback (most recent call last):
  File "fahrgastrechte.py", line 75, in <module>
    print(main())
  File "fahrgastrechte.py", line 20, in main
    args, defaults = functions.get_args()
  File "/Users/steinbrueckri/Projects/steinbrueckri/fahrgastrechte-autofill/functions.py", line 59, in get_args
    livedata = get_livedata(**vars(args))
  File "/Users/steinbrueckri/Projects/steinbrueckri/fahrgastrechte-autofill/functions.py", line 203, in get_livedata
    return trip_info.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

It doesn't work for me at the moment because of the following error message. The only question is, is it possible to fix this or is the "API" no longer available?

cheers 🍻 Richard

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.