1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-11-04 09:22: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):
if filename is None:
filename = DEFAULTSESSIONFILE
with open(filename, 'rb') as sessionfile:
session = requests.Session()
session.cookies = requests.utils.cookiejar_from_dict(pickle.load(sessionfile))
session.headers.update(default_http_header())
log("Loaded session from %s." % filename, quiet=quiet)
return session
try:
with open(filename, 'rb') as sessionfile:
session = requests.Session()
session.cookies = requests.utils.cookiejar_from_dict(pickle.load(sessionfile))
session.headers.update(default_http_header())
log("Loaded session from %s." % filename, quiet=quiet)
return session
except FileNotFoundError:
pass
def test_login(user, session):
if user is None or session is None: