ingress.utils

Miscellaneous utility functions used in other modules.

bigbang.ingress.utils.ask_for_input(request: str) → Optional[str]
bigbang.ingress.utils.get_auth_session(url_login: str, username: str, password: str) → requests.sessions.Session

Create AuthSession.

There are three ways to create an AuthSession:
  • parse username & password directly into method

  • create a /bigbang/config/authentication.yaml file that contains keys

  • type then into terminal when the method ‘get_login_from_terminal’

    is raised

bigbang.ingress.utils.get_login_from_terminal(username: Optional[str], password: Optional[str], file_auth: str = '/home/docs/checkouts/readthedocs.org/user_builds/bigbang-py/checkouts/latest/bigbang/config/authentication.yaml') → Tuple[Optional[str]]

Get login key from user during run time if ‘username’ and/or ‘password’ is ‘None’. Return ‘None’ if no reply within 15 sec.

bigbang.ingress.utils.get_website_content(url: str, session: Optional[requests.sessions.Session] = None) → Union[str, bs4.BeautifulSoup]

Get HTML code from website

Note

Servers don’t like it when one is sending too many requests from same ip address in short period of time. Therefore we need to:

  1. catch ‘requests.exceptions.RequestException’ errors

    (includes all possible errors to be on the safe side),

  2. safe intermediate results,

  3. continue where we left off at a later stage.

bigbang.ingress.utils.loginkey_to_file(username: str, password: str, file_auth: str) → None

Safe login key to yaml

bigbang.ingress.utils.set_website_preference_for_header(url_pref: str, session: requests.sessions.Session) → requests.sessions.Session

Set the ‘Email Headers’ of the ‘Archive Preferences’ for the auth session to ‘Show All Headers’. Otherwise only a restricted list of header fields is shown.