MCPcopy
hub / github.com/InstaPy/InstaPy / smart_run

Function smart_run

instapy/util.py:1981–2002  ·  view source on GitHub ↗
(session, threaded=False)

Source from the content-addressed store, hash-verified

1979
1980@contextmanager
1981def 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
2005def reload_webpage(browser):

Callers 1

quickstart.pyFile · 0.90

Calls 2

loginMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected