コード例 #1
0
def mount_Donor( line ):
    '''
    Mounts and returns a Donor object from a [line] (string) that meets Donor.encode() sintaxe.
    Note: No verification is run on this procedure.
    '''
    field = disassemble(line)
    #==========< "decode" of field >=========#
    number = field[0]
    name = field[1]
    SNS = field[2]
    ABO = field[3]
    Rh = field[4]
    gender = field[5]
    birthdate = datetime.strptime( field[6], '%d-%m-%Y').date()
    #==< contacts >==# (optional fields)
    street = field[7] if field[7] != 'None' else None
    postcode = field[8] if field[8] != 'None' else None
    city = field[9] if field[9] != 'None' else None
    country = field[10] if field[10] != 'None' else None
    email = field[11] if field[11] != 'None' else None
    phone = field[12] if field[12] != 'None' else None
    mobile = field[13] if field[13] != 'None' else None
    #=========< Assembly of Donor >=========#
    donor = Donor( Donor_num( number ), Name( name ), SNS_num( SNS ), Bloodtype( ABO, Rh ), Gender( gender ), Birthdate( birthdate ),\
                   Contacts( Address( street, postcode, city, country), Email( email ), Phone( phone ), Mobile( mobile )))
    return donor
コード例 #2
0
def registerDonor(f=None):
    """Register a donor"""
    name = getInput(str, "Enter donor name: ")
    pc = int(getInput(isPositive, "Enter postcode: "))
    btype = getInput(isBloodType, "Enter blood type: ")

    d = Donor(name, pc, btype)
    d.verify(btype)
コード例 #3
0
ファイル: Inventory.py プロジェクト: xyunsw/EarlyDafny
 def add_blood(self, donor_name: str, donor_id: str, source: str, blood_type="", use_by=-1) -> int:
     donor = Donor(donor_name, donor_id)
     blood = Blood(len(self._bloods), donor)
     if source == 'Bat-Mobile':
         blood.test_state = BloodTestState.NOT_TESTED
         donor.history.append(blood)
         
     elif source == 'Red Cross':
         blood.test_state = BloodTestState.GOOD
         blood.use_by = use_by
         blood.type = blood_type
         
     else:
         raise ValueError(f"invalid source: {source}")
     self._bloods.append(blood)
     self._lc.check_level()
     return len(self._bloods) - 1
コード例 #4
0
 def create_donor (self, name, sns_num, bloodtype, gender, birthdate, contacts):
     '''
     Returns an instance of Donor class with an previously unassigned donor number.
     Assumes that all arguments are valid (validated during input procedure).
     Generates a valid unassigned donor number.
     Note: Assumes that all donor numbers have 6 digits.
     '''
     #Warning:
     # We are aware that this method of generating donor's numbers imply that:
     #  1) The available numbers will eventually run out and the program will enter an infinite loop;
     #  2) Number generation will get slower as numbers available decrease.
     #  For the purpose of this exercise we considered those limitations acceptable.
     #==================<Notes>=====================
     #[name] is an instance of Name class
     #[sns_num] is an instance of SNS_num class
     #[bloodtype] is an instance of Bloodtype class
     #[ABO] is an attribute of Bloodtype class
     #[Rh] is an attribute of Bloodtype class
     #[gender] is an instance of Gender class
     #[birthdate] is an instance of Birthdate class
     #[contacts] is an instance of Contacts class
     #[address] is an instance of Address class
     #[street] is an attribute of Address class
     #[postcode] is an attribute of Address class
     #[city] is an attribute of Address class
     #[country] is an attribute of Address class
     #[email] is an instance of Email class
     #[phone] is an instance of Phone class
     #[mobile] is an instance of Mobile class
     #==============================================
     while True:
         intNumber = randint(1, 999999) #at most 6 digits
         strNumber = str( intNumber )
         rawNumber = strNumber.zfill(6) #assures 6 digits by filling the remainder with zeros to the left
         if rawNumber not in self.donor_Map:
             donorNumber = Donor_num(rawNumber) #[donorNumber] is an instance of Donor_num class
             break
     return Donor(donorNumber, name, sns_num, bloodtype, gender, birthdate, contacts)
コード例 #5
0
ファイル: Inventory.py プロジェクト: xyunsw/EarlyDafny
 def get_blood_by_donor(self, donor_name: str, donor_id: str) -> list:
     donor = Donor(donor_name, donor_id)
     return donor.history
コード例 #6
0
    def autoTune(self):
        self.log('autoTune, Init')
        curtime = time.time()
        chanlist = ChannelList.ChannelList()
        chanlist.background = True
        # chanlist.needsreset = True
        chanlist.makenewlists = True
        try:
            self.Donor = Donor()
        except:
            pass
        settingsFile = xbmc.translatePath(
            os.path.join(Globals.SETTINGS_LOC, 'settings2.xml'))

        if FileAccess.exists(settingsFile):
            try:
                os.remove(settingsFile)
            except:
                self.log("autoTune, Unable to delete " + str(settingsFile))

        channelNum = 0
        updateDialogProgress = 0

        self.updateDialog = xbmcgui.DialogProgress()
        self.updateDialog.create("PseudoTV Live", "Auto Tune")

        # LiveTV - PVR
        self.updateDialogProgress = 5
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindLivePVR"
        ) == "true" and Globals.REAL_SETTINGS.getSetting('xmltvLOC') != '':
            self.log("autoTune, Adding Live PVR Channels")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Live PVR Channels", "")
            CHnum = 0
            RCHnum = 0
            CHid = 0
            CHlst = ''
            CHname = ''
            CHzapit = ''
            if channelNum == 0:
                channelNum = 1
            try:
                json_query = '{"jsonrpc":"2.0","method":"PVR.GetChannels","params":{"channelgroupid":2}, "id":1}'
                json_folder_detail = chanlist.sendJSON(json_query)
                file_detail = re.compile("{(.*?)}",
                                         re.DOTALL).findall(json_folder_detail)
                self.logDebug('autoFindLivePVR, file_detail = ' +
                              str(file_detail))
                self.xmlTvFile = xbmc.translatePath(
                    os.path.join(Globals.REAL_SETTINGS.getSetting('xmltvLOC'),
                                 'xmltv.xml'))

                f = FileAccess.open(self.xmlTvFile, "rb")
                tree = ET.parse(f)
                root = tree.getroot()

                file_detail = str(file_detail)
                CHnameLST = re.findall('"label" *: *(.*?),', file_detail)
                CHidLST = re.findall('"channelid" *: *(.*?),', file_detail)
                self.logDebug('autoFindLivePVR, CHnameLST = ' + str(CHnameLST))
                self.logDebug('autoFindLivePVR, CHidLST = ' + str(CHidLST))

                for CHnum in range(len(file_detail)):
                    CHname = CHnameLST[CHnum]
                    CHname = str(CHname)
                    CHname = CHname.split('"', 1)[-1]
                    CHname = CHname.split('"')[0]
                    CHlst = (CHname + ',' + CHidLST[CHnum])
                    inSet = False
                    self.logDebug('autoFindLivePVR, CHlst.1 = ' + str(CHlst))
                    # search xmltv for channel name, then find its id
                    for elem in root.getiterator():
                        if elem.tag == ("channel"):
                            name = elem.findall('display-name')
                            for i in name:
                                RCHnum = (CHnum + 1)
                                if CHname == i.text:
                                    CHzapit = elem.attrib
                                    CHzapit = str(CHzapit)
                                    CHzapit = CHzapit.split(": '", 1)[-1]
                                    CHzapit = CHzapit.split("'")[0]
                                    CHlst = (CHlst + ',' + str(CHzapit))
                                    self.logDebug(
                                        'autoFindLivePVR, CHlst.2 = ' +
                                        str(CHlst))
                                    inSet = True

                    self.log('autoFindLivePVR, inSet = ' + str(inSet) + ' , ' +
                             str(CHlst))
                    if inSet == True:
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_type", "8")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_time", "0")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_1", CHzapit)
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_2",
                            "pvr://channels/tv/All TV channels/" + str(CHnum) +
                            ".pvr")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_3", "xmltv")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_4", "")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rulecount", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_id", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_opt_1",
                            CHname + ' LiveTV')
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_changed", "true")
                        channelNum = channelNum + 1

                    if inSet == False:
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_type", "9")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_time", "0")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_1", "5400")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_2",
                            "pvr://channels/tv/All TV channels/" + str(CHnum) +
                            ".pvr")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_3", CHname)
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_4",
                            "XMLTV DATA NOT FOUND")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rulecount", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_id", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_opt_1",
                            CHname + ' LiveTV')
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_changed", "true")
                        channelNum = channelNum + 1
            except:
                pass
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        # Custom Channels
        self.updateDialogProgress = 15
        if Globals.REAL_SETTINGS.getSetting("autoFindCustom") == "true":
            self.log("autoTune, Adding Custom Channel")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Custom Channel", "")
            i = 1
            for i in range(500):
                if os.path.exists(
                        xbmc.translatePath('special://profile/playlists/video')
                        + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Video Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        str(
                            xbmc.translatePath(
                                'special://profile/playlists/video/') +
                            "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_opt_1",
                        Globals.uni(
                            chanlist.cleanString(
                                chanlist.getSmartPlaylistName(
                                    xbmc.translatePath(
                                        'special://profile/playlists/video') +
                                    '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "PseudoTV Live",
                        "Found " + Globals.uni(
                            chanlist.getSmartPlaylistName(
                                xbmc.translatePath(
                                    'special://profile/playlists/video') +
                                '/Channel_' + str(i + 1) + '.xsp')), "")
                elif os.path.exists(
                        xbmc.translatePath('special://profile/playlists/mixed')
                        + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Mixed Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        str(
                            xbmc.translatePath(
                                'special://profile/playlists/mixed/') +
                            "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_opt_1",
                        Globals.uni(
                            chanlist.cleanString(
                                chanlist.getSmartPlaylistName(
                                    xbmc.translatePath(
                                        'special://profile/playlists/mixed') +
                                    '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "PseudoTV Live",
                        "Found " + Globals.uni(
                            chanlist.getSmartPlaylistName(
                                xbmc.translatePath(
                                    'special://profile/playlists/mixed') +
                                '/Channel_' + str(i + 1) + '.xsp')), "")
                elif os.path.exists(
                        xbmc.translatePath('special://profile/playlists/music')
                        + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Music Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        str(
                            xbmc.translatePath(
                                'special://profile/playlists/music/') +
                            "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_opt_1",
                        Globals.uni(
                            chanlist.cleanString(
                                chanlist.getSmartPlaylistName(
                                    xbmc.translatePath(
                                        'special://profile/playlists/music') +
                                    '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "PseudoTV Live",
                        "Found " + Globals.uni(
                            chanlist.getSmartPlaylistName(
                                xbmc.translatePath(
                                    'special://profile/playlists/music') +
                                '/Channel_' + str(i + 1) + '.xsp')), "")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        #TV - Networks/Genres
        self.updateDialogProgress = 20
        self.log("autoTune, autoFindNetworks " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindNetworks")))
        self.log("autoTune, autoFindTVGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindTVGenres")))
        if (Globals.REAL_SETTINGS.getSetting("autoFindNetworks") == "true"
                or Globals.REAL_SETTINGS.getSetting("autoFindTVGenres")
                == "true"):
            self.log("autoTune, Searching for TV Channels")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for TV Channels", "")
            chanlist.fillTVInfo()

        # need to add check for auto find network channels
        self.updateDialogProgress = 21
        if Globals.REAL_SETTINGS.getSetting("autoFindNetworks") == "true":
            self.log("autoTune, Adding TV Networks")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding TV Networks", "")
            i = 1
            for i in range(len(chanlist.networkList)):
                channelNum = channelNum + 1
                # add network presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1",
                    Globals.uni(chanlist.networkList[i]))
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,
                                         "Auto Tune", "Adding TV Network",
                                         Globals.uni(chanlist.networkList[i]))

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 22
        if Globals.REAL_SETTINGS.getSetting("autoFindTVGenres") == "true":
            self.log("autoTune, Adding TV Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding TV Genres", "")
            channelNum = channelNum - 1
            for i in range(len(chanlist.showGenreList)):
                channelNum = channelNum + 1
                # add network presets
                if chanlist.showGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "3")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        Globals.uni(chanlist.showGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "Auto Tune",
                        "Adding TV Genres",
                        Globals.uni(chanlist.showGenreList[i]) + " TV")
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 23
        self.log("autoTune, autoFindStudios " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindStudios")))
        self.log("autoTune, autoFindMovieGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres")))
        if (Globals.REAL_SETTINGS.getSetting("autoFindStudios") == "true"
                or Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres")
                == "true"):
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for Movie Channels", "")
            chanlist.fillMovieInfo()

        self.updateDialogProgress = 24
        if Globals.REAL_SETTINGS.getSetting("autoFindStudios") == "true":
            self.log("autoTune, Adding Movie Studios")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Movie Studios", "")
            i = 1
            for i in range(len(chanlist.studioList)):
                channelNum = channelNum + 1
                self.updateDialogProgress = self.updateDialogProgress + (
                    10 / len(chanlist.studioList))
                # add network presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "2")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1",
                    Globals.uni(chanlist.studioList[i]))
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,
                                         "Auto Tune", "Adding Movie Studios",
                                         Globals.uni(chanlist.studioList[i]))

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 25
        if Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres") == "true":
            self.log("autoTune, Adding Movie Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Movie Genres", "")
            channelNum = channelNum - 1
            for i in range(len(chanlist.movieGenreList)):
                channelNum = channelNum + 1
                self.updateDialogProgress = self.updateDialogProgress + (
                    10 / len(chanlist.movieGenreList))
                # add network presets
                if chanlist.movieGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "4")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        Globals.uni(chanlist.movieGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "Auto Tune",
                        "Adding Movie Genres", "Found " +
                        Globals.uni(chanlist.movieGenreList[i]) + " Movies")
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 26
        self.log("autoTune, autoFindMixGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindMixGenres")))
        if Globals.REAL_SETTINGS.getSetting("autoFindMixGenres") == "true":
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for Mixed Channels", "")
            chanlist.fillMixedGenreInfo()

        self.updateDialogProgress = 27
        if Globals.REAL_SETTINGS.getSetting("autoFindMixGenres") == "true":
            self.log("autoTune, Adding Mixed Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Mixed Genres", "")
            channelNum = channelNum - 1
            for i in range(len(chanlist.mixedGenreList)):
                channelNum = channelNum + 1
                # add network presets
                if chanlist.mixedGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "5")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        Globals.uni(chanlist.mixedGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "Auto Tune",
                        "Adding Mixed Genres",
                        Globals.uni(chanlist.mixedGenreList[i]) + " Mix")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 28
        self.log("autoTune, autoFindMusicGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres")))
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres") == "true":
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for Music Channels", "")
            chanlist.fillMusicInfo()

        self.updateDialogProgress = 29
        #Music Genre
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres") == "true":
            self.log("autoTune, Adding Music Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Music Genres", "")
            i = 1
            for i in range(len(chanlist.musicGenreList)):
                channelNum = channelNum + 1
                # add network presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "12")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1",
                    Globals.uni(chanlist.musicGenreList[i]))
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(
                    self.updateDialogProgress, "Auto Tune",
                    "Adding Music Genres",
                    Globals.uni(chanlist.musicGenreList[i]) + " Music")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - Last.fm user
        self.updateDialogProgress = 30
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosLastFM") == "true":
            self.log("autoTune, Adding Last.FM Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Last.FM Music Videos", "")
            if channelNum == 0:
                channelNum = 1
            user = Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosLastFMuser")
            lastapi = "http://api.tv.timbormans.com/user/" + user + "/topartists.xml"
            for i in range(1):
                # add Last.fm user presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "13")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", lastapi)
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1", "Last.FM")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - Youtube
        self.updateDialogProgress = 35
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosYoutube") == "true":
            self.log("autoTune, Adding Youtube Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Youtube Music Videos", "")
            if channelNum == 0:
                channelNum = 1
            for i in range(1):
                # add HungaryRChart presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", "HungaryRChart")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1", "HRChart")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                # add BillbostdHot100 presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1", "BillbostdHot100")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "BillbostdHot100")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")
                # add TheTesteeTop50Charts presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_1",
                    "TheTesteeTop50Charts")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_opt_1",
                    "TheTesteeTop50Charts")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - VevoTV
        self.updateDialogProgress = 40
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosVevoTV") == "true":
            self.log("autoTune, Adding VevoTV Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding VevoTV Music Videos", "")
            if channelNum == 0:
                channelNum = 1

            for i in range(1):
                # add VevoTV presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2",
                    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/06/prog_index.m3u8"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "VEVO TV (US: Hits)")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_4",
                    "Sit back and enjoy a 24/7 stream of music videos on VEVO TV."
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1",
                    "VevoTV - Hits")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_2",
                    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch2/06/prog_index.m3u8"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_3",
                    "VEVO TV (US: Flow)")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_4",
                    "Sit back and enjoy a 24/7 stream of music videos on VEVO TV."
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "VevoTV - Flow")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_2",
                    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch3/06/prog_index.m3u8"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_3",
                    "VEVO TV (Nashville)")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_4",
                    "Sit back and enjoy a 24/7 stream of music videos on VEVO TV."
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_opt_1",
                    "VevoTV - Nashville")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - Local
        self.updateDialogProgress = 45
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosLocal") != "":
            self.log("autoTune, Adding Local Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Local Music Videos", "")
            if channelNum == 0:
                channelNum = 1
            LocalVideo = str(
                Globals.REAL_SETTINGS.getSetting('autoFindMusicVideosLocal'))
            for i in range(1):
                # add Local presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "7")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1",
                    "" + LocalVideo + "")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "Music Videos")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")

            channelNum = channelNum + 1
            self.logDebug('channelNum = ' + str(channelNum))

        #InternetTV - Strms
        self.updateDialogProgress = 50
        if Globals.REAL_SETTINGS.getSetting("autoFindInternetStrms") == "true":
            self.log("autoTune, Adding InternetTV Strms")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding InternetTV Strms", "")
            if channelNum == 0:
                channelNum = 1

            for i in range(1):
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", "BBCWorldwide")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_4", "")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1",
                    "BBC World News")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "11")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1",
                    "http://revision3.com/hdnation/feed/Quicktime-High-Definition"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "HD Nation")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))

            if Globals.REAL_SETTINGS.getSetting("Donor_Enabled") == "true":
                try:
                    self.Donor.migrateDonor(channelNum)
                except:
                    pass

        Globals.ADDON_SETTINGS.writeSettings()

        #set max channels
        # chanlist.setMaxChannels()

        self.updateDialogProgress = 100
        # reset auto tune settings
        Globals.REAL_SETTINGS.setSetting('Autotune', "false")
        Globals.REAL_SETTINGS.setSetting('Warning1', "false")
        Globals.REAL_SETTINGS.setSetting('autoFindLivePVR', "false")
        Globals.REAL_SETTINGS.setSetting("autoFindCustom", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindNetworks", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindStudios", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindTVGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMovieGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMixGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindTVShows", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosYoutube", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosVevoTV", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosLastFM", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosLocal", "")
        Globals.REAL_SETTINGS.setSetting("autoFindInternetStrms", "false")
        Globals.REAL_SETTINGS.setSetting("ForceChannelReset", "true")

        Globals.ADDON_SETTINGS.setSetting('LastExitTime', str(int(curtime)))
        self.updateDialog.close()
コード例 #7
0
bag3.verify("B-")

m3.addBlood(bag1)
m3.addBlood(bag2)
m3.addBlood(bag3)

bag1 = Blood(today, 250)
bag1.verify("O-")

bag2 = Blood(today, 450)
bag2.verify("O-")

bag3 = Blood(today, 350)
bag3.verify("B-")

m3.addBlood(bag1)
m3.addBlood(bag2)
m3.addBlood(bag3)

donorList.clear()

p1 = Donor("John", 2033, "AB+")
p1.verify("AB+")

p2 = Donor("David", 2035, "B+")
p2.verify("B+")

# Save to file
saveFacilities()
saveBlood()
saveDonors()