2018-02-03 20:40:17 +00:00
|
|
|
#!/usr/bin/env python3
|
2017-09-01 12:43:10 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-02-03 20:40:17 +00:00
|
|
|
# pylint: disable=C0111,C0326,C0103
|
2017-09-01 12:43:10 +01:00
|
|
|
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Library for TCL API work and related functions."""
|
|
|
|
|
2017-09-01 12:43:10 +01:00
|
|
|
import requests
|
2018-02-03 20:24:36 +00:00
|
|
|
|
2018-02-06 00:03:25 +00:00
|
|
|
from . import (dumpmgr, servervote, tclcheck, tclchecksum, tclencheader,
|
|
|
|
tclrequest)
|
2018-02-03 20:24:36 +00:00
|
|
|
|
|
|
|
|
2018-02-03 00:36:08 +00:00
|
|
|
class FotaCheck(
|
2018-02-03 21:25:26 +00:00
|
|
|
tclcheck.TclCheckMixin,
|
|
|
|
tclrequest.TclRequestMixin,
|
|
|
|
tclchecksum.TclChecksumMixin,
|
|
|
|
tclencheader.TclEncHeaderMixin,
|
|
|
|
servervote.ServerVoteMixin,
|
2018-02-05 12:20:15 +00:00
|
|
|
dumpmgr.DumpMgrMixin
|
2018-02-03 20:24:36 +00:00
|
|
|
):
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Main API handler class."""
|
2018-02-05 15:52:06 +00:00
|
|
|
|
2017-09-01 12:43:10 +01:00
|
|
|
def __init__(self):
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Handle mixins and populate variables."""
|
2018-02-03 01:37:55 +00:00
|
|
|
super().__init__()
|
2017-09-01 16:58:00 +01:00
|
|
|
self.reset_session()
|
|
|
|
|
2018-02-07 00:49:44 +00:00
|
|
|
def reset_session(self, device=None):
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Reset everything to default."""
|
2017-09-01 12:43:10 +01:00
|
|
|
self.g2master = self.get_master_server()
|
2017-09-01 16:58:00 +01:00
|
|
|
self.sess = requests.Session()
|
2018-02-07 00:49:44 +00:00
|
|
|
if device:
|
|
|
|
self.sess.headers.update({"User-Agent": device.ua})
|
2017-09-01 16:58:00 +01:00
|
|
|
return self.sess
|