From 1d3a943e74fd86cec99380fd8ddd92863b3794f8 Mon Sep 17 00:00:00 2001 From: Blallo Date: Mon, 21 Jan 2019 09:32:52 +0100 Subject: [PATCH] README updated --- README.md | 25 +++++++++++++++++++++---- bot_z/bot_z.py | 21 ++++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4bfd2d7..ab506e6 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,28 @@ Features -------- * Login/Logout +* Check in/Check out + + +Install +------- + +Either clone this repo and `pip install .` or use one of the provided packages. +Pay attention: this package needs a working binary of [geckodriver](https://github.com/mozilla/geckodriver). +You can either proceed in one of the following ways: + +* Install the source distribution and put in your `$PATH` the `geckodriver` binary + (that can be downloaded [here](https://github.com/mozilla/geckodriver/releases/)) +* Install the wheel for your architecture +* `pip install .` or `pip install -e .` will download the latest `geckodriver` and + put it in a path where the code will be able to find it. + +*BEWARE*: the code gives precedence to the `geckodriver` in `$PATH` over that donwloaded. TODO ---- - * Check in/out - * systemd {unit, timer} - * APIs - * ... + [x] Check in/out + [ ] systemd {unit, timer} + [ ] APIs + [ ] Mailer diff --git a/bot_z/bot_z.py b/bot_z/bot_z.py index 5f333f3..67bbbc1 100644 --- a/bot_z/bot_z.py +++ b/bot_z/bot_z.py @@ -9,16 +9,27 @@ from datetime import datetime, timedelta import logging import os import pkg_resources +import shutil +import sys import time import typing as T from urllib.parse import urlparse -os.environ["PATH"] = ( - os.environ["PATH"] + ":" + pkg_resources.resource_filename(__name__, "bin") -) +geckoexe = shutil.which("geckodriver") +if geckoexe is None: + local_path = pkg_resources.resource_filename(__name__, "bin") + try: + os.stat(os.path.join(local_path, "geckodriver")) + os.environ["PATH"] = os.environ["PATH"] + ":" + local_path + except FileNotFoundError: + print("Missing geckodriver executable in path", file=sys.stderr) + raise -from selenium import webdriver as wd -from selenium.common.exceptions import WebDriverException, NoSuchElementException +from selenium import webdriver as wd # noqa +from selenium.common.exceptions import ( + WebDriverException, + NoSuchElementException, +) # noqa logging.basicConfig(