@@ -25,6 +25,7 @@ def save_cookie(session: requests.Session, cookie_path: Optional[str] = None):
25
25
cookie_path = cookie_path or default_cookie_path
26
26
os .makedirs (os .path .dirname (cookie_path ), exist_ok = True )
27
27
session .cookies .save ()
28
+ logging .info ("Saved session into {}" .format (os .path .abspath (cookie_path )))
28
29
os .chmod (cookie_path , 0o600 )
29
30
30
31
@@ -33,6 +34,8 @@ def load_cookie_to(session: requests.Session, cookie_path: Optional[str] = None)
33
34
session .cookies = LWPCookieJar (cookie_path )
34
35
if os .path .exists (cookie_path ):
35
36
session .cookies .load ()
37
+ logging .info (
38
+ "Loaded session from {}" .format (os .path .abspath (cookie_path )))
36
39
return True
37
40
return False
38
41
@@ -57,7 +60,7 @@ def check_logging_in(self):
57
60
resp = self ._request (private_url )
58
61
return resp .url == private_url
59
62
60
- def login (self , username = None , password = None , use_local_session_cache = True ):
63
+ def login (self , username = None , password = None , use_local_session_cache = True , save_session_cache = True ):
61
64
if use_local_session_cache :
62
65
load_cookie_to (self ._session )
63
66
if self .check_logging_in ():
@@ -82,7 +85,7 @@ def login(self, username=None, password=None, use_local_session_cache=True):
82
85
if resp .text .find ("パスワードを忘れた方はこちら" ) != - 1 :
83
86
raise LoginError
84
87
85
- if use_local_session_cache :
88
+ if use_local_session_cache and save_session_cache :
86
89
save_cookie (self ._session )
87
90
88
91
def download_problem_list (self , contest : Contest ) -> List [Problem ]:
0 commit comments