(cookie_file_name, params)
| 305 | return schema, secret |
| 306 | |
| 307 | def on_login(cookie_file_name, params): |
| 308 | global botUID |
| 309 | client_post(subscribe('me')) |
| 310 | |
| 311 | """Save authentication token to file""" |
| 312 | if params == None or cookie_file_name == None: |
| 313 | return |
| 314 | |
| 315 | if 'user' in params: |
| 316 | botUID = params['user'].decode("ascii")[1:-1] |
| 317 | |
| 318 | # Protobuf map 'params' is not a python object or dictionary. Convert it. |
| 319 | nice = {'schema': 'token'} |
| 320 | for key_in in params: |
| 321 | if key_in == 'token': |
| 322 | key_out = 'secret' |
| 323 | else: |
| 324 | key_out = key_in |
| 325 | nice[key_out] = json.loads(params[key_in].decode('utf-8')) |
| 326 | |
| 327 | try: |
| 328 | cookie = open(cookie_file_name, 'w') |
| 329 | json.dump(nice, cookie) |
| 330 | cookie.close() |
| 331 | except Exception as err: |
| 332 | log("Failed to save authentication cookie", err) |
| 333 | |
| 334 | def load_quotes(file_name): |
| 335 | with open(file_name) as f: |
no test coverage detected
searching dependent graphs…