1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-11-05 01:42:29 +01:00

catch case of nonexisting session file

This commit is contained in:
Alexander Graf 2016-07-26 17:03:20 +02:00
parent 04821f5f76
commit 087a69ef7e

View File

@ -145,12 +145,15 @@ def save_session(session, filename, quiet=False):
def load_session(filename, quiet=False): def load_session(filename, quiet=False):
if filename is None: if filename is None:
filename = DEFAULTSESSIONFILE filename = DEFAULTSESSIONFILE
with open(filename, 'rb') as sessionfile: try:
session = requests.Session() with open(filename, 'rb') as sessionfile:
session.cookies = requests.utils.cookiejar_from_dict(pickle.load(sessionfile)) session = requests.Session()
session.headers.update(default_http_header()) session.cookies = requests.utils.cookiejar_from_dict(pickle.load(sessionfile))
log("Loaded session from %s." % filename, quiet=quiet) session.headers.update(default_http_header())
return session log("Loaded session from %s." % filename, quiet=quiet)
return session
except FileNotFoundError:
pass
def test_login(user, session): def test_login(user, session):
if user is None or session is None: if user is None or session is None: