Пример #1
0
    def loadDisc(self):
        """ Read disc information and create the explorer tree accordingly """
        import DiscID

        try:
            discInfo = DiscID.disc_id(DiscID.open(prefs.get(__name__, 'device', PREFS_DFT_DEVICE)))
        except Exception, err:
            if err[0] == 123:
                self.tree.replaceContent([(icons.cdromMenuIcon(), None, _('No disc found'), None)])
                modules.postMsg(consts.MSG_CMD_EXPLORER_RENAME, {'modName': MOD_L10N, 'expName': self.expName, 'newExpName': MOD_L10N})
                self.expName = MOD_L10N
            else:
                logger.error('[%s] Unable to read device\n\n%s' % (MOD_INFO[modules.MODINFO_NAME], traceback.format_exc()))
            return
Пример #2
0
    def cddbRequest(self, discInfo):
        """ Return disc information from online CDDB, None if request fails """
        import CDDB, socket

        # Make sure to not be blocked by the request
        socket.setdefaulttimeout(consts.socketTimeout)

        try:
            (status, info) = CDDB.query(discInfo)

            if   status == 200: disc = info       # Success
            elif status == 210: disc = info[0]    # Exact multiple matches
            elif status == 211: disc = info[0]    # Inexact multiple matches
            else:               raise Exception, 'Unknown disc (phase 1 returned %u)' % status

            (status, info) = CDDB.read(disc['category'], disc['disc_id'])

            if status == 210: return info
            else:             raise Exception, 'Unknown disc (phase 2 returned %u)' % status
        except:
            logger.error('[%s] CDDB request failed\n\n%s' % (MOD_INFO[modules.MODINFO_NAME], traceback.format_exc()))
            return None