예제 #1
0
 def doInit(self, *args, **kwargs):
     """
     Action method.
     """
     self._do_block_rebuilding()
     self.known_suppliers = [
         _f
         for _f in contactsdb.suppliers(customer_idurl=self.customer_idurl)
         if _f
     ]
     if not self.EccMap:
         if self.customer_idurl == my_id.getIDURL():
             self.EccMap = eccmap.Current()
             lg.info('ECC map %r set from local for my own suppliers' %
                     self.EccMap)
     if not self.EccMap:
         known_eccmap_dict = {}
         for supplier_idurl in self.known_suppliers:
             known_ecc_map = contactsdb.get_supplier_meta_info(
                 supplier_idurl=supplier_idurl,
                 customer_idurl=self.customer_idurl,
             ).get('ecc_map', None)
             if known_ecc_map:
                 if known_ecc_map not in known_eccmap_dict:
                     known_eccmap_dict[known_ecc_map] = 0
                 known_eccmap_dict[known_ecc_map] += 1
         if known_eccmap_dict:
             all_known_eccmaps = list(known_eccmap_dict.items())
             all_known_eccmaps.sort(key=lambda i: i[1], reverse=True)
             self.EccMap = eccmap.eccmap(all_known_eccmaps[0][0])
             lg.info('ECC map %r recognized from suppliers meta info' %
                     self.EccMap)
         else:
             known_ecc_map = None
             if driver.is_on('service_shared_data'):
                 from access import shared_access_coordinator
                 active_share = shared_access_coordinator.get_active_share(
                     self.key_id)
                 if active_share:
                     known_ecc_map = active_share.known_ecc_map
             if known_ecc_map:
                 self.EccMap = eccmap.eccmap(known_ecc_map)
                 lg.info('ECC map %r recognized from active share %r' % (
                     self.EccMap,
                     active_share,
                 ))
             else:
                 num_suppliers = len(self.known_suppliers)
                 if num_suppliers not in eccmap.GetPossibleSuppliersCount():
                     num_suppliers = settings.DefaultDesiredSuppliers()
                 self.EccMap = eccmap.eccmap(
                     eccmap.GetEccMapName(num_suppliers))
                 lg.warn(
                     'no meta info found, guessed ECC map %r from %d known suppliers'
                     % (self.EccMap, len(self.known_suppliers)))
     self.max_errors = eccmap.GetCorrectableErrors(
         self.EccMap.NumSuppliers())
     if data_receiver.A():
         data_receiver.A().addStateChangedCallback(
             self._on_data_receiver_state_changed)
예제 #2
0
 def doInit(self, arg):
     """
     Action method.
     """
     if data_receiver.A():
         data_receiver.A().addStateChangedCallback(
             self._on_data_receiver_state_changed)
     self.known_suppliers = filter(
         None, contactsdb.suppliers(customer_idurl=self.customer_idurl))
     known_eccmap_dict = {}
     for supplier_idurl in self.known_suppliers:
         known_ecc_map = contactsdb.get_supplier_meta_info(
             supplier_idurl=supplier_idurl,
             customer_idurl=self.customer_idurl,
         ).get('ecc_map', None)
         if known_ecc_map:
             if known_ecc_map not in known_eccmap_dict:
                 known_eccmap_dict[known_ecc_map] = 0
             known_eccmap_dict[known_ecc_map] += 1
     if known_eccmap_dict:
         all_known_eccmaps = known_eccmap_dict.items()
         all_known_eccmaps.sort(key=lambda i: i[1], reverse=True)
         self.EccMap = eccmap.eccmap(all_known_eccmaps[0][0])
         lg.info('eccmap %s recognized from suppliers meta info' %
                 self.EccMap)
     else:
         self.EccMap = eccmap.eccmap(
             eccmap.GetEccMapName(len(self.known_suppliers)))
         lg.warn(
             'no meta info found, guessed eccmap %s from %d known suppliers'
             % (self.EccMap, len(self.known_suppliers)))
예제 #3
0
 def doInit(self, *args, **kwargs):
     """
     Action method.
     """
     self.known_suppliers = [
         _f
         for _f in contactsdb.suppliers(customer_idurl=self.customer_idurl)
         if _f
     ]
     known_eccmap_dict = {}
     for supplier_idurl in self.known_suppliers:
         known_ecc_map = contactsdb.get_supplier_meta_info(
             supplier_idurl=supplier_idurl,
             customer_idurl=self.customer_idurl,
         ).get('ecc_map', None)
         if known_ecc_map:
             if known_ecc_map not in known_eccmap_dict:
                 known_eccmap_dict[known_ecc_map] = 0
             known_eccmap_dict[known_ecc_map] += 1
     if known_eccmap_dict:
         all_known_eccmaps = list(known_eccmap_dict.items())
         all_known_eccmaps.sort(key=lambda i: i[1], reverse=True)
         self.EccMap = eccmap.eccmap(all_known_eccmaps[0][0])
         lg.info('eccmap %s recognized from suppliers meta info' %
                 self.EccMap)
     else:
         num_suppliers = len(self.known_suppliers)
         if num_suppliers == 0:
             num_suppliers = settings.DefaultDesiredSuppliers()
         self.EccMap = eccmap.eccmap(eccmap.GetEccMapName(num_suppliers))
         lg.warn(
             'no meta info found, guessed eccmap %s from %d known suppliers'
             % (self.EccMap, len(self.known_suppliers)))
     if data_receiver.A():
         data_receiver.A().addStateChangedCallback(
             self._on_data_receiver_state_changed)