def __init__(self,
                 url: str,
                 username: Optional[str] = None,
                 password: Optional[str] = None,
                 login_on_demand: bool = False,
                 timeout: Union[float, Tuple[float, float], None] = None):
        # Auth info embedded in the URL may reportedly cause problems, strip it
        parsed_url = urlparse(url)
        clear_url = urlunparse(
            (parsed_url.scheme, parsed_url.netloc.rpartition("@")[-1],
             *parsed_url[2:]))
        super().__init__(clear_url, timeout=timeout)
        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import,import-outside-toplevel
        self.user = User(self, username, password)

        if login_on_demand:
            warnings.warn(
                "login_on_demand is deprecated, and has no effect, please remove this parameter from your code! if  will get removed in next minor release.",
                DeprecationWarning)

        if self.user.login(True):
            self.login_time = datetime.datetime.utcnow()
            self.logged_in = True
class AuthorizedConnection(Connection):
    LOGOUT_TIMEOUT = 300  # seconds
    login_time = None
    logged_in = False

    def __init__(self,
                 url: str,
                 username: Optional[str] = None,
                 password: Optional[str] = None,
                 login_on_demand: bool = False,
                 timeout: Union[float, Tuple[float, float], None] = None):
        # Auth info embedded in the URL may reportedly cause problems, strip it
        parsed_url = urlparse(url)
        clear_url = urlunparse(
            (parsed_url.scheme, parsed_url.netloc.rpartition("@")[-1],
             *parsed_url[2:]))
        super().__init__(clear_url, timeout=timeout)
        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import,import-outside-toplevel
        self.user = User(self, username, password)

        if login_on_demand:
            warnings.warn(
                "login_on_demand is deprecated, and has no effect, please remove this parameter from your code! if  will get removed in next minor release.",
                DeprecationWarning)

        if self.user.login(True):
            self.login_time = datetime.datetime.utcnow()
            self.logged_in = True

    def _is_login_timeout(self) -> bool:
        if self.login_time is None:
            return True
        logout_time = self.login_time + datetime.timedelta(
            seconds=self.LOGOUT_TIMEOUT)
        return logout_time < datetime.datetime.utcnow()

    def enforce_authorized_connection(self) -> bool:
        # Check if connection timeouted or not
        if not self.logged_in or self._is_login_timeout():
            # Connection timeouted, relogin
            if self.user.login():
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True
            else:
                self.login_time = None
                self.logged_in = False

        return self.logged_in
    def __init__(self, url: str, username: Optional[str]=None, password: Optional[str]=None,
                 login_on_demand: bool=False, timeout: Union[float, Tuple[float, float], None] = None):
        super(AuthorizedConnection, self).__init__(url, timeout=timeout)
        parsed_url = urlparse(url)

        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import
        self.user = User(self, username, password)

        if not login_on_demand:
            if self.user.login(True):
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True
Beispiel #4
0
class AuthorizedConnection(Connection):
    LOGOUT_TIMEOUT = 300  # seconds
    login_time = None
    logged_in = False

    def __init__(self,
                 url: str,
                 username: Optional[str] = None,
                 password: Optional[str] = None,
                 login_on_demand: bool = False,
                 timeout: Union[float, Tuple[float, float], None] = None):
        parsed_url = urlparse(url)
        clear_url = '{scheme}://{hostname}{path}'.format(
            scheme=parsed_url.scheme,
            hostname=parsed_url.hostname,
            path=parsed_url.path)
        super(AuthorizedConnection, self).__init__(clear_url, timeout=timeout)
        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import,import-outside-toplevel
        self.user = User(self, username, password)

        if not login_on_demand:
            if self.user.login(True):
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True

    def _is_login_timeout(self) -> bool:
        if self.login_time is None:
            return True
        logout_time = self.login_time + datetime.timedelta(
            seconds=self.LOGOUT_TIMEOUT)
        return logout_time < datetime.datetime.utcnow()

    def enforce_authorized_connection(self) -> bool:
        # Check if connection timeouted or not
        if not self.logged_in or self._is_login_timeout():
            # Connection timeouted, relogin
            if self.user.login():
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True
            else:
                self.login_time = None
                self.logged_in = False

        return self.logged_in
Beispiel #5
0
class AuthorizedConnection(Connection):
    LOGOUT_TIMEOUT = 300  # seconds
    login_time = None
    logged_in = False

    def __init__(self,
                 url: str,
                 username: str = None,
                 password: str = None,
                 login_on_demand: bool = False):
        super(AuthorizedConnection, self).__init__(url)
        parsed_url = urlparse(url)

        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import
        self.user = User(self, username, password)

        if not login_on_demand:
            if self.user.login(True):
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True

    def _is_login_timeout(self) -> bool:
        if self.login_time is None:
            return True
        logout_time = self.login_time + datetime.timedelta(
            seconds=self.LOGOUT_TIMEOUT)
        return logout_time < datetime.datetime.utcnow()

    def enforce_authorized_connection(self):
        # Check if connection timeouted or not
        if not self.logged_in or self._is_login_timeout():
            # Connection timeouted, relogin
            if self.user.login():
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True
            else:
                self.login_time = None
                self.logged_in = False

        return self.logged_in
Beispiel #6
0
    def __init__(self,
                 url: str,
                 username: Optional[str] = None,
                 password: Optional[str] = None,
                 login_on_demand: bool = False,
                 timeout: Union[float, Tuple[float, float], None] = None):
        parsed_url = urlparse(url)
        clear_url = '{scheme}://{hostname}{path}'.format(
            scheme=parsed_url.scheme,
            hostname=parsed_url.hostname,
            path=parsed_url.path)
        super(AuthorizedConnection, self).__init__(clear_url, timeout=timeout)
        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import,import-outside-toplevel
        self.user = User(self, username, password)

        if not login_on_demand:
            if self.user.login(True):
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True
    def __init__(self,
                 url: str,
                 username: Optional[str] = None,
                 password: Optional[str] = None,
                 login_on_demand: bool = False,
                 timeout: Union[float, Tuple[float, float], None] = None):
        # Auth info embedded in the URL may reportedly cause problems, strip it
        parsed_url = urlparse(url)
        clear_url = urlunparse(
            (parsed_url.scheme, parsed_url.netloc.rpartition("@")[-1],
             *parsed_url[2:]))
        super(AuthorizedConnection, self).__init__(clear_url, timeout=timeout)
        username = username if username else parsed_url.username
        password = password if password else parsed_url.password

        from huawei_lte_api.api.User import User  # pylint: disable=cyclic-import,import-outside-toplevel
        self.user = User(self, username, password)

        if not login_on_demand:
            if self.user.login(True):
                self.login_time = datetime.datetime.utcnow()
                self.logged_in = True
Beispiel #8
0
 def __init__(self, connection: Connection):  # pylint: disable=too-many-statements
     self.monitoring = Monitoring(connection)
     self.security = Security(connection)
     self.webserver = WebServer(connection)
     self.global_ = Global_(connection)
     self.wlan = WLan(connection)
     self.cradle = Cradle(connection)
     self.pin = Pin(connection)
     self.config_dialup = DialUpConfig(connection)
     self.config_global = Global(connection)
     self.config_lan = LanConfig(connection)
     self.config_network = NetworkConfig(connection)
     self.config_pincode = PincodeConfig(connection)
     self.config_sms = SmsConfig(connection)
     self.config_voice = Voice(connection)
     self.config_wifi = WifiConfig(connection)
     self.config_pc_assistant = PcAssistant(connection)
     self.config_device_information = DeviceInformation(connection)
     self.config_web_ui_cfg = WebUICfg(connection)
     self.config_device = DeviceConfig(connection)
     self.config_fast_boot = FastBoot(connection)
     self.config_firewall = Firewall(connection)
     self.config_ipv6 = IPv6(connection)
     self.config_ota = OtaConfig(connection)
     self.config_pb = PbConfig(connection)
     self.config_sntp = Sntp(connection)
     self.config_statistic = ConfigStatistic(connection)
     self.config_stk = Stk(connection)
     self.config_update = Update(connection)
     self.config_u_pnp = UPnp(connection)
     self.config_ussd = Ussd(connection)
     self.config_web_sd = WebSd(connection)
     self.usermanual_public_sys_resources = PublicSysResources(connection)
     self.ota = Ota(connection)
     self.net = Net(connection)
     self.dial_up = DialUp(connection)
     self.sms = Sms(connection)
     self.redirection = Redirection(connection)
     self.v_sim = VSim(connection)
     self.file_manager = FileManager(connection)
     self.dhcp = Dhcp(connection)
     self.d_dns = DDns(connection)
     self.diagnosis = Diagnosis(connection)
     self.s_ntp = SNtp(connection)
     self.user = User(connection)
     self.device = Device(connection)
     self.online_update = OnlineUpdate(connection)
     self.log = Log(connection)
     self.time = Time(connection)
     self.sd_card = SdCard(connection)
     self.usb_storage = UsbStorage(connection)
     self.usb_printer = UsbPrinter(connection)
     self.vpn = Vpn(connection)
     self.ntwk = Ntwk(connection)
     self.pb = Pb(connection)
     self.host = Host(connection)
     self.language = Language(connection)
     self.syslog = Syslog(connection)
     self.voice = Voice_(connection)
     self.cwmp = Cwmp(connection)
     self.lan = Lan(connection)
     self.led = Led(connection)
     self.statistic = Statistic(connection)
     self.timerule = TimeRule(connection)
     self.bluetooth = Bluetooth(connection)
     self.mlog = MLog(connection)