1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-09 22:06:47 +00:00
tcl_ota_check/tcllib/__init__.py

36 lines
939 B
Python
Raw Normal View History

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
class FotaCheck(
2018-02-03 21:25:26 +00:00
tclcheck.TclCheckMixin,
tclrequest.TclRequestMixin,
tclchecksum.TclChecksumMixin,
tclencheader.TclEncHeaderMixin,
servervote.ServerVoteMixin,
dumpmgr.DumpMgrMixin
2018-02-03 20:24:36 +00:00
):
2018-02-03 21:25:26 +00:00
"""Main API handler class."""
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__()
self.reset_session()
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()
self.sess = requests.Session()
if device:
self.sess.headers.update({"User-Agent": device.ua})
return self.sess