(session, threaded=False)
| 1979 | |
| 1980 | @contextmanager |
| 1981 | def smart_run(session, threaded=False): |
| 1982 | try: |
| 1983 | session.login() |
| 1984 | yield |
| 1985 | except NoSuchElementException: |
| 1986 | # The problem is with a change in IG page layout |
| 1987 | log_file = "{}.html".format(time.strftime("%Y%m%d-%H%M%S")) |
| 1988 | file_path = os.path.join(gettempdir(), log_file) |
| 1989 | |
| 1990 | with open(file_path, "wb") as fp: |
| 1991 | fp.write(session.browser.page_source.encode("utf-8")) |
| 1992 | |
| 1993 | print( |
| 1994 | "{0}\nIf raising an issue, " |
| 1995 | "please also upload the file located at:\n{1}\n{0}".format( |
| 1996 | "*" * 70, file_path |
| 1997 | ) |
| 1998 | ) |
| 1999 | except KeyboardInterrupt: |
| 2000 | clean_exit("You have exited successfully.") |
| 2001 | finally: |
| 2002 | session.end(threaded_session=threaded) |
| 2003 | |
| 2004 | |
| 2005 | def reload_webpage(browser): |
no test coverage detected