def __get_data(self, port): r = { 'mode_modem': False, 'mode_brew': False, 'manufacturer': None, 'model': None, 'firmware_version': None, 'esn': None, 'firmwareresponse': None } try: c = commport.CommConnection(self, port, timeout=self.__default_timeout) except: self.log('Failed to open port: ' + port) return r r['mode_modem'] = self.__get_mode_modem(c) if r['mode_modem']: # in modem mode, ok to try other info r['manufacturer'] = self.__get_manufacturer(c) r['model'] = self.__get_model(c) r['firmware_version'] = self.__get_firmware_version(c) r['esn'] = self.__get_esn(c) c.close() return r
def detectphone(_, coms, likely_ports, res, _module, _log): if not likely_ports: # cannot detect any likely ports return None for port in likely_ports: if not res.has_key(port): res[port] = { 'mode_modem': None, 'mode_brew': None, 'manufacturer': None, 'model': None, 'firmware_version': None, 'esn': None, 'firmwareresponse': None } try: if res[port]['mode_brew']==False or \ res[port]['model']: # either phone is not in BREW, or a model has already # been found, not much we can do now continue p = _module.Phone( _log, commport.CommConnection(_log, port, timeout=1)) if res[port]['mode_brew'] is None: res[port]['mode_brew'] = p.is_mode_brew() if res[port]['mode_brew']: p.check_my_phone(res[port]) p.comm.close() except com_brew.BrewBadBrewCommandException: pass except: if __debug__: raise
def detectphone(_, coms, likely_ports, res, _module, _log): if not likely_ports: # cannot detect any likely ports return None for port in likely_ports: if not res.has_key(port): res[port] = { 'mode_modem': None, 'mode_brew': None, 'manufacturer': None, 'model': None, 'firmware_version': None, 'esn': None, 'firmwareresponse': None } try: if res[port]['model']: # been found, not much we can do now continue p = _module.Phone( _log, commport.CommConnection(_log, port, timeout=1)) # Force to check for BREW if not res[port]['mode_brew']: res[port]['mode_brew'] = p.is_mode_brew() if res[port]['mode_brew']: p.check_my_phone(res[port]) p.comm.close() except: if __debug__: raise
def detectphone(_, coms, likely_ports, res, _module, _log): if not len(likely_ports): return None for port in likely_ports: if not res.has_key(port): res[port] = { 'mode_modem': None, 'mode_brew': None, 'manufacturer': None, 'model': None, 'firmware_version': None, 'esn': None, 'firmwareresponse': None } try: if res[port]['mode_modem']==False or \ res[port]['model']: continue p = Phone(_log, commport.CommConnection(_log, port, timeout=1)) if p.is_mode_modem(): res[port]['mode_modem'] = True p.get_detect_data(res[port]) else: res[port]['mode_modem'] = False except: # this port is not available if __debug__: raise
def exp_deviceopen(self, port, baud, timeout, hardwareflow, softwareflow, context): # ::TODO:: None is pointer to log object return self.stashhandle( context, commport.CommConnection(None, port, baud, timeout, hardwareflow, softwareflow))
def detectphone(_, coms, likely_ports, res, _module, _log): if not likely_ports: # cannot detect any likely ports return None for port in likely_ports: if not res.has_key(port): res[port] = { 'mode_modem': None, 'mode_brew': None, 'manufacturer': None, 'model': None, 'firmware_version': None, 'esn': None, 'firmwareresponse': None } try: if res[port]['model']: # is a model has already # been found, not much we can do now continue p = _module.Phone( _log, commport.CommConnection(_log, port, timeout=1)) # because this is a modem port we ignore any existing results for likely ports res[port]['mode_brew'] = p._setmodebrew() if res[port]['mode_brew']: p.get_detect_data(res[port]) p.comm.close() except: if __debug__: raise
def detectphone(_, coms, likely_ports, res, _module, _log): for port in likely_ports: _model = res.get(port, {}).get('model', None) if _model == _module.Profile.phone_model: return port elif _model == _module.Profile.generic_phone_model: # this is a V710, try to get the actual model try: _comm = commport.CommConnection(_log, port) _comm.sendatcommand('+MODE=2') _comm.sendatcommand('') _s = _comm.sendatcommand('+GMM')[0] _comm.sendatcommand('+MODE=0') _comm.close() _model = _s.split(': ')[1].split(',')[-1].replace( '"', '').split('=')[1] if _model == _module.Profile.common_model_name: _model = _module.Profile.phone_model res[port]['model'] = _model if _model == _module.Profile.phone_model: return port except: _comm.close() if __debug__: raise
def __init__(self, arg, file_in, file_out, file_err, config_filename=None, comm_port=None, phone_model=None): """Constructor @param arg: command string including the command and its argument @param file_in: input stream file object @param file_out: output stream file object @param file_err: error strean file object @param config_filename: use this config file instead of the default @param comm_port: string name of the comm port to use (default to config file) @param phone_model: string phone model to use (default to config file) """ self.OK = False self._inCLI = False try: _cmd_line = arg.split(None) self.cmd = _cmd_line[0] self.args = _cmd_line[1:] self.config = bp_config.Config(config_filename) _commport = comm_port if comm_port else self.config.Read( "lgvx4400port", None) _phonemodel = phone_model if phone_model else self.config.Read( "phonetype", None) if os.environ.get('PHONE_FS', None): # running in BREW FS debug/sim mode self.commport = None else: self.commport = commport.CommConnection(self, _commport) try: self.phonemodule = common.importas(phones.module(_phonemodel)) except KeyError: raise PhoneModelError self.phone = self.phonemodule.Phone(self, self.commport) self._rootdir = '' self._pwd = self._rootdir self._in = file_in self._out = file_out self._err = file_err # initialize the Brew file cache com_brew.file_cache = com_brew.FileCache( self.config.Read('path', '')) except common.CommsOpenFailure: file_err.write('Error: Failed to open comm port %s\n' % _commport) except PhoneModelError: file_err.write('Error: Phone Model %s not available\n' % _phonemodel) else: self.OK = True