Ejemplo n.º 1
0
    def __init__(self, arg_connection):
        self.__connection = arg_connection

        self.initialed = False
        # check pin status
        self.__pin_verified = False
        self.__adm_verified = False
        self.__pin_enabled = False

        uicc_resp = self.select(UICC_FILE.MF,
                                arg_type=UICC_SELECT_TYPE.FILE_ID)
        self.__pin_enabled = uicc_resp.pin

        self.__iccid = None
        uicc_resp: uicc_sel_resp = self.select(UICC_FILE.ICCID)
        read_resp = self.read_binary(uicc_resp)
        if read_resp != None:
            self.__iccid = convert_bcd_to_string(read_resp)
            log.info(self.__class__.__name__, "ICCID: " + self.__iccid)

        # select AID for '7FFF'
        self.__aid = None
        self.__aid = self.__init_aid()

        if self.__aid != None and self.__iccid != None:
            self.initialed = True
Ejemplo n.º 2
0
    def execute(self, arg_components: components, arg_arguments):
        ret_state = STATE.DISPATCH_ERROR
        ret_arguments = None

        log.debug(self.__class__.__name__, "ENTER")
        log.info(self.__class__.__name__, arg_arguments)

        lower_arguments = arg_arguments.lower()
        if (lower_arguments == 'plugin'):
            ret_state = STATE.PLUGIN_LIST
        elif (lower_arguments == 'help'):
            ret_state = STATE.HELP
        elif (lower_arguments == 'exit'):
            ret_state = STATE.EXIT
        elif (arg_arguments != ''):
            cmd_list = arg_arguments.split(' ')
            for plugin in arg_components.plugin:
                if (plugin[0] == cmd_list[0].lower()):
                    if (len(cmd_list) > 1 and 'help' == cmd_list[1].lower()):
                        ret_state = STATE.PLUGIN_HELP
                        ret_arguments = cmd_list[0]
                    else:
                        ret_state = STATE.EXECUTE
                        ret_arguments = cmd_list[0].lower() + " " + " ".join(cmd_list[1:])
                    break

        log.debug(self.__class__.__name__, "EXIT")
        return (ret_state, ret_arguments)
Ejemplo n.º 3
0
    def query_pin_code(self, arg_iccid):
        ret_pin = None
        try:
            root = self.__xml.getroot()
            pin_node = root.xpath('//uicc[@iccid="' + arg_iccid + '"]/pin')
            if len(pin_node) > 0:
                return pin_node[0].text
        except Exception as e:
            log.info(self.__class__.__name__,
                     "Can't found the PIN of ICCID: " + arg_iccid)

        return ret_pin
Ejemplo n.º 4
0
    def query_adm_code(self, arg_iccid):
        ret_adm = None
        try:
            root = self.__xml.getroot()
            adm_node = root.xpath('//uicc[@iccid="' + arg_iccid + '"]/adm')
            if len(adm_node) > 0:
                return adm_node[0].text
        except Exception as e:
            log.info(self.__class__.__name__,
                     "Can't found the ADM of ICCID: " + arg_iccid)

        return ret_adm
Ejemplo n.º 5
0
    def execute(self, arg_components: components, arg_arguments):
        ret_state = STATE.CLI
        ret_arguments = None

        log.debug(self.__class__.__name__, "ENTER")
        log.info(self.__class__.__name__, arg_arguments)

        cmd_list = arg_arguments.split(" ")
        for plugin in arg_components.plugin:
            if (plugin[0] == cmd_list[0]):
                plugin_class = __import__("model.plugins.%s.%s" %
                                          (plugin[0], plugin[0]),
                                          fromlist=[plugin[0]])
                instance_class = getattr(plugin_class, plugin[0])()
                instance_class.execute(arg_components, " ".join(cmd_list[1:]))
                break

        log.debug(self.__class__.__name__, "EXIT")
        return (ret_state, ret_arguments)