mirror of
https://github.com/instaloader/instaloader.git
synced 2024-09-11 16:22:24 +02:00
catch case of nonexisting session file
This commit is contained in:
parent
04821f5f76
commit
087a69ef7e
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user