コード例 #1
0
def generate_phone_features():
    r={}
    for model in phones.phonemodels:
        module=common.importas(phones.module(model))
        # check for Profile._supportedsyncs
        support_sync=[(x[0], x[1]) for x in module.Profile._supportedsyncs]
        d={}
        for f in features:
            d[f]={ 'r': False, 'w': False }
            if (f, 'read') in support_sync:
                if hasattr(module.Phone, req_attrs[f]['r']) and\
                   getattr(module.Phone, req_attrs[f]['r']) is not NotImplemented\
                   and getattr(module.Phone, req_attrs[f]['r']) is not None:
                    d[f]['r']=True
            if (f, 'write') in support_sync:
                if hasattr(module.Phone, req_attrs[f]['w']) and\
                   getattr(module.Phone, req_attrs[f]['w']) is not NotImplemented\
                   and getattr(module.Phone, req_attrs[f]['w']) is not None:
                    d[f]['w']=True
        for f in misc_features:
            d[f]={ 'x': req_attrs[f](module) }
        if hasattr(module.Phone, 'helpid') and module.Phone.helpid:
            _model_name='<a href="%s">%s</a>'%( module.Phone.helpid, model)
        else:
            _model_name=model
        r[_model_name]=d
    return r
コード例 #2
0
 def set(self, data):
     self._model_name=data.get('phone', '')
     self._model.SetLabel(self._model_name)
     self._com_port=data.get('com', '')
     self._port.SetLabel(self._com_port)
     _module=common.importas(phones.module(self._model_name))
     self._det_btn.Enable(bool(self._model_name and \
                               hasattr(_module.Phone,
                                      'detectphone'))) 
コード例 #3
0
 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
コード例 #4
0
 def set(self, data):
     self._status.SetLabel('')
     self._model_name = data.get('phone', '')
     self._model.SetLabel(self._model_name)
     self._com_port = data.get('com', '')
     self._port.SetLabel(self._com_port)
     _module = common.importas(phones.module(self._model_name))
     self._det_btn.Enable(bool(self._model_name and \
                               (hasattr(_module.Phone,
                                        'detectphone') or \
                                hasattr(_module.Profile,
                                        'phone_model'))))
コード例 #5
0
ファイル: bp_cli.py プロジェクト: SJLC/portage-overlay
 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
コード例 #6
0
ファイル: phone_detect.py プロジェクト: deosai/bitpim
    def detect(self, using_port=None, using_model=None):
        # start the detection process
        # 1st, get the list of available ports
        coms = comscan.comscan() + usbscan.usbscan()
        self.log('coms:' + str(coms))
        available_modem_coms=[x['name'] for x in coms if x['available'] \
                              and x.get('class', None)=='modem']
        if not using_port:
            available_coms = [x['name'] for x in coms if x['available']]
        else:
            available_coms = [using_port]
            available_modem_coms = [
                x for x in available_coms if x in available_modem_coms
            ]
        # loop through each port and gather data
        self.log('Available ports: ' + str(available_coms))
        self.log('Available modem ports: ' + str(available_modem_coms))
        # only try those AT commands on modem ports
        # using threads
        self.__q_on = True
        threads=[threading.Thread(target=self.do_get_data, args=(e,)) \
                 for e in available_modem_coms]
        for t in threads:
            t.start()
        for t in threads:
            t.join()
        self.__q_on = False
        while not self.__q_log.empty():
            q = self.__q_log.get_nowait()
            if isinstance(q, (list, tuple)):
                self.logdata(*q)
            else:
                self.log(q)
        # non-thread version
##        for e in available_modem_coms:
##            self.do_get_data(e)
# go through each phone and ask it
##        pm=phones.phonemodels
        if using_model:
            models = [using_model]
        else:
            models = phones.phonemodels
        found_port = found_model = None
        for model in models:
            self.log('Checking for model: ' + model)
            module = common.importas(phones.module(model))
            # check for detectphone in module.Phone or
            # phone_model and phone_manufacturer in module.Profile
            if hasattr(module.Phone, 'detectphone'):
                if using_port is None:
                    likely_ports=[x['name'] for x in coms if \
                                  x['available'] and \
                                  comdiagnose.islikelyport(x, module)]
                else:
                    likely_ports = [using_port]
                self.log('Likely ports:' + str(likely_ports))
                found_port = getattr(module.Phone,
                                     'detectphone')(coms, likely_ports,
                                                    self.__data, module, self)
                self.log('Detect Phone result: ' + ` self.__data `)
                if found_port is not None:
                    self.log('Phone ' + model + ' returned port:' +
                             ` found_port `)
                    # found it
                    found_model = model
                    break
            found_port = self.__check_profile(module.Profile)
            if found_port is not None:
                found_model = model
                break
        if found_port is None and using_port is None and using_model is None:
            # if we're not looking for a specific model on a specific port,
            # scan for other CDMA phone
            found_port, found_model = self.__check_for_other_cdma()
        if found_port is not None and found_model is not None:
            self.log('Found phone:' + found_model + ' port:' + ` found_port `)
            return {
                'port': found_port,
                'phone_name': found_model,
                'phone_module': phones.module(found_model),
                'phone_esn': self.__data[found_port]['esn']
            }
コード例 #7
0
	def set(self, data):

        self._model_name=data.get('phone', '')

        self._model.SetLabel(self._model_name)

        self._com_port=data.get('com', '')

        self._port.SetLabel(self._com_port)

        _module=common.importas(phones.module(self._model_name))

        self._det_btn.Enable(bool(self._model_name and \
                                  hasattr(_module.Phone,
                                         'detectphone'))) 

    
	def OnDetect(self, _):

        if self._com_port=='auto':

            _port_name=None

        else:

            _port_name=str(self._com_port)

        _res=phone_detect.DetectPhone().detect(using_port=_port_name,
                                               using_model=self._model_name)

        _status='FAILED'

        if _res and _res.get('phone_name', '')==self._model_name:

            _status='PASSED'

        self._status.SetLabel(_status)



class  SetPhoneWizard (wiz.Wizard) :
	def __init__(self, parent):

        super(SetPhoneWizard, self).__init__(parent, -1,
                                             'Phone Setting Wizard')

        self._data={}

        commport_page=CommPortPage(self)

        phonemodel_page=PhoneModelPage(self)

        summary_page=SummaryPage(self)

        wiz.WizardPageSimple_Chain(commport_page, phonemodel_page)

        wiz.WizardPageSimple_Chain(phonemodel_page, summary_page)

        self.first_page=commport_page

        self.GetPageAreaSizer().Add(commport_page, 1, wx.EXPAND|wx.ALL, 5)

        wiz.EVT_WIZARD_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)

        wiz.EVT_WIZARD_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)

    
	def RunWizard(self, firstPage=None):

        return super(SetPhoneWizard, self).RunWizard(firstPage or self.first_page)

    
	def OnPageChanging(self, evt):

        pg=evt.GetPage()

        if not evt.GetDirection() or pg.ok():

            pg.get(self._data)

        else:

            evt.Veto()

    
	def OnPageChanged(self, evt):

        evt.GetPage().set(self._data)

    
	def get(self):

        return self._data



if __name__=="__main__":

    app=wx.PySimpleApp()

    f=wx.Frame(None, title='setphone_wizard')

    w=SetPhoneWizard(f)

    print w.RunWizard()

    print w._data

    w.Destroy()
コード例 #8
0
	def detect(self, using_port=None, using_model=None):

        coms=comscan.comscan()

        self.log('coms:'+str(coms))

        available_modem_coms=[x['name'] for x in coms if x['available'] \
                              and x['class']=='modem']

        if using_port is None:

            available_coms=[x['name'] for x in coms if x['available']]

        else:

            available_coms=[using_port]

            available_modem_coms=[x for x in available_coms if x in available_modem_coms]

        self.log('Available ports: '+str(available_coms))

        self.log('Available modem ports: '+str(available_modem_coms))

        self.__q_on=True

        threads=[threading.Thread(target=self.do_get_data, args=(e,)) \
                 for e in available_modem_coms]

        for t in threads:

            t.start()

        for t in threads:

            t.join()

        self.__q_on=False

        while not self.__q_log.empty():

            q=self.__q_log.get_nowait()

            if isinstance(q, (list, tuple)):

                self.logdata(*q)

            else:

                self.log(q)

        if using_model:

            models=[using_model]

        else:

            models=phones.phonemodels

        found_port=found_model=None

        for model in models:

            self.log('Checking for model: '+model)

            module=common.importas(phones.module(model))

            if hasattr(module.Phone, 'detectphone'):

                if using_port is None:

                    likely_ports=[x['name'] for x in coms if \
                                  x['available'] and \
                                  comdiagnose.islikelyport(x, module)]

                else:

                    likely_ports=[using_port]

                self.log('Likely ports:'+str(likely_ports))

                found_port=getattr(module.Phone, 'detectphone')(coms,
                                                                likely_ports,
                                                                self.__data,
                                                                module,
                                                                self)

                self.log('Detect Phone result: '+`self.__data`)

                if found_port is not None:

                    self.log('Phone '+model+' returned port:'+`found_port`)

                    found_model=model

                    break

            found_port=self.__check_profile(module.Profile)

            if found_port is not None:

                found_model=model

                break

        if found_port is None:

            found_port, found_model=self.__check_for_other_cdma()

        if found_port is not None and found_model is not None:

            self.log('Found phone:'+found_model+' port:'+`found_port`)

            return { 'port': found_port, 'phone_name': found_model,
                     'phone_module': phones.module(found_model),
                     'phone_esn': self.__data[found_port]['esn'] }
コード例 #9
0
ファイル: phone_detect.py プロジェクト: SJLC/portage-overlay
    def detect(self, using_port=None, using_model=None):
        # start the detection process
        # 1st, get the list of available ports
        coms=comscan.comscan()+usbscan.usbscan()
        self.log('coms:'+str(coms))
        available_modem_coms=[x['name'] for x in coms if x['available'] \
                              and x.get('class', None)=='modem']
        if not using_port:
            available_coms=[x['name'] for x in coms if x['available']]
        else:
            available_coms=[using_port]
            available_modem_coms=[x for x in available_coms if x in available_modem_coms]
        # loop through each port and gather data
        self.log('Available ports: '+str(available_coms))
        self.log('Available modem ports: '+str(available_modem_coms))
        # only try those AT commands on modem ports
        # using threads
        self.__q_on=True
        threads=[threading.Thread(target=self.do_get_data, args=(e,)) \
                 for e in available_modem_coms]
        for t in threads:
            t.start()
        for t in threads:
            t.join()
        self.__q_on=False
        while not self.__q_log.empty():
            q=self.__q_log.get_nowait()
            if isinstance(q, (list, tuple)):
                self.logdata(*q)
            else:
                self.log(q)
        # non-thread version
##        for e in available_modem_coms:
##            self.do_get_data(e)
        # go through each phone and ask it
##        pm=phones.phonemodels
        if using_model:
            models=[using_model]
        else:
            models=phones.phonemodels
        found_port=found_model=None
        for model in models:
            self.log('Checking for model: '+model)
            module=common.importas(phones.module(model))
            # check for detectphone in module.Phone or
            # phone_model and phone_manufacturer in module.Profile
            if hasattr(module.Phone, 'detectphone'):
                if using_port is None:
                    likely_ports=[x['name'] for x in coms if \
                                  x['available'] and \
                                  comdiagnose.islikelyport(x, module)]
                else:
                    likely_ports=[using_port]
                self.log('Likely ports:'+str(likely_ports))
                found_port=getattr(module.Phone, 'detectphone')(coms,
                                                                likely_ports,
                                                                self.__data,
                                                                module,
                                                                self)
                self.log('Detect Phone result: '+`self.__data`)
                if found_port is not None:
                    self.log('Phone '+model+' returned port:'+`found_port`)
                    # found it
                    found_model=model
                    break
            found_port=self.__check_profile(module.Profile)
            if found_port is not None:
                found_model=model
                break
        if found_port is None and using_port is None and using_model is None:
            # if we're not looking for a specific model on a specific port,
            # scan for other CDMA phone
            found_port, found_model=self.__check_for_other_cdma()
        if found_port is not None and found_model is not None:
            self.log('Found phone:'+found_model+' port:'+`found_port`)
            return { 'port': found_port, 'phone_name': found_model,
                     'phone_module': phones.module(found_model),
                     'phone_esn': self.__data[found_port]['esn'] }