def collect_garbage(garbage_counter):
    """ clean up temp files"""
    if garbage_counter >= 2:
        #temp_file = lib_cm.extract_filename(ac, db.ac_config_1[6])
        temp_file = ac.app_file_orig_temp + ".mp3"
        lib_cm.erase_file_a(ac, db, temp_file,
                            u"Externe News-mp3-Datei geloescht ")

    if garbage_counter >= 2:
        temp_file_1 = temp_file.replace("mp3", "wav")
        lib_cm.erase_file_a(ac, db, temp_file_1,
                            u"Externe News-wav-Datei geloescht ")

    if garbage_counter >= 3:
        temp_file_2 = temp_file_1.replace(".wav", "_comp.wav")
        lib_cm.erase_file_a(ac, db, temp_file_2,
                            u"Externe News-comp-Datei geloescht ")

    if garbage_counter >= 4:
        lib_cm.erase_file_a(ac, db, ac.app_file_bed_trim,
                            u"Externe News-Bed-Datei geloescht ")

    if garbage_counter == 5:
        temp_file_2 = temp_file_1.replace(".wav", "_temp.wav")
        lib_cm.erase_file_a(ac, db, temp_file_2,
                            "Externe News-temp-Datei geloescht ")
示例#2
0
def collect_garbage(garbage_counter):
    """ clean up temp files"""
    if garbage_counter >= 2:
        #temp_file = lib_cm.extract_filename(ac, db.ac_config_1[6])
        temp_file = ac.app_file_orig_temp + ".mp3"
        lib_cm.erase_file_a(ac, db, temp_file,
            u"Externe News-mp3-Datei geloescht ")

    if garbage_counter >= 2:
        temp_file_1 = temp_file.replace("mp3", "wav")
        lib_cm.erase_file_a(ac, db, temp_file_1,
            u"Externe News-wav-Datei geloescht ")

    if garbage_counter >= 3:
        temp_file_2 = temp_file_1.replace(".wav", "_comp.wav")
        lib_cm.erase_file_a(ac, db, temp_file_2,
            u"Externe News-comp-Datei geloescht ")

    if garbage_counter >= 4:
        lib_cm.erase_file_a(ac, db, ac.app_file_bed_trim,
            u"Externe News-Bed-Datei geloescht ")

    if garbage_counter == 5:
        temp_file_2 = temp_file_1.replace(".wav", "_temp.wav")
        lib_cm.erase_file_a(ac, db, temp_file_2,
            "Externe News-temp-Datei geloescht ")
示例#3
0
        lib_cm.message_write_to_console(ac, dest_file)
        #os.rename(file_orig, dest_file)
        return True
    else:
        # no 100% message, trying to find another error, here in german!
        cmd_output_1 = string.find(p[1], "gibt es nicht")
        if cmd_output_1 != -1:
            db.write_log_to_db_a(ac, "Datei auf ftp-Server nicht vorhanden: "
                + url_source_file, "t", "write_also_to_console")
        else:
            db.write_log_to_db_a(ac, ac.app_errorslist[1]
            + u"100% beim Download nicht erreicht...",
            "x", "write_also_to_console")
            filename_ftp_temp = lib_cm.extract_filename(ac,
                                                        url_source_file)
            lib_cm.erase_file_a(ac, db, filename_ftp_temp,
                                    "temp-Datei geloescht ")
        return None


def copy_media_to_play_out(path_file_source, dest_file):
    """copy audiofile"""
    success_copy = None
    try:
        shutil.move(path_file_source, dest_file)
        db.write_log_to_db_a(ac, u"Audio Vorproduktion: "
                + path_file_source.encode('ascii', 'ignore'),
                "v", "write_also_to_console")
        db.write_log_to_db_a(ac, u"Audio kopiert: "
                + dest_file, "c", "write_also_to_console")
        success_copy = True
    except Exception, e:
示例#4
0
def lets_rock():
    """Mainfunction """
    print "lets_rock "
    # extendet params
    load_extended_params_ok = load_extended_params()
    if load_extended_params_ok is None:
        return

    # load from db
    podcast_sendungen = load_podcast()
    if podcast_sendungen is None:
        db.write_log_to_db_a(ac, u"Zur Zeit kein neuer Podcast vorgesehen", "k",
            "write_also_to_console")
        return

    # check whats not online
    podcast_offline = check_files_online(podcast_sendungen)
    if podcast_offline is None:
        # Error 1
        return

    if podcast_offline == "No files offline":
        db.write_log_to_db_a(ac, u"Alle Podcasts bereits online", "k",
            "write_also_to_console")
        return

    # take one item from offlines
    podcast_sendung = ()
    for item in podcast_sendungen:
        if item[12] == podcast_offline:
            # take all values for id3
            # insert one item to shift author in the tuple
            podcast_sendung_all = item[:14] + (" ",) + item[14:]
            # filename, titel, vorname, name, infotime, magazin
            podcast_sendung = (item[12], item[11], item[14], item[15],
                               item[4].strip(), item[5].strip())

    lib_cm.message_write_to_console(ac, podcast_sendung)
    podcast_sendung_temp = podcast_sendung
    # recode
    podcast_temp = encode_file(podcast_sendung)
    if podcast_temp is None:
        # try with next file
        # take one item from offlines
        podcast_sendung = ()
        for item in podcast_sendungen:
            if item[12] == podcast_offline:
                # take all values for id3
                # insert one item to shift author in the tuple
                podcast_sendung_all = item[:14] + (" ",) + item[14:]
                # nicht das vorige file nochmal
                print "podcast_sendung"
                print podcast_sendung
                if item[12] != podcast_sendung_temp[0]:
                    # filename, titel, vorname, name, infotime, magazin
                    podcast_sendung = (item[12], item[11], item[14],
                                item[15], item[4].strip(), item[5].strip())

        lib_cm.message_write_to_console(ac, podcast_sendung)

        if len(podcast_sendung) == 0:
            # nothing else to do
            return

        # recode nr 2. with next file
        podcast_temp_1 = encode_file(podcast_sendung)
        if podcast_temp_1 is None:
            # Error 2
            db.write_log_to_db_a(ac, ac.app_errorslist[2], "x",
                "write_also_to_console")
            return

    # tagging file in utf-8
    if db.ac_config_1[3] == "on":
        #tag_file_id3(podcast_sendung)
        path_source = lib_cm.check_slashes(ac, db.ac_config_1[10])
        file_dest = path_source + podcast_sendung[0]
        success_add_id3 = lib_au.add_id3(
                                ac, db, lib_cm, podcast_sendung_all, file_dest)

        if success_add_id3 is None:
            db.write_log_to_db_a(ac, ac.app_errorslist[3],
                                        "x", "write_also_to_console")

    # upload whats not online
    upload_ok = upload_file(podcast_sendung)
    if upload_ok is None:
        # Error 1
        db.write_log_to_db_a(ac, ac.app_errorslist[1], "x",
            "write_also_to_console")
        return

    # delete temp_file from encode
    delete_temp_ok = lib_cm.erase_file_a(ac, db, podcast_temp,
        u"Temp-Podcast-Datei geloescht ")
    if delete_temp_ok is None:
        # Error 4
        db.write_log_to_db_a(ac, ac.app_errorslist[4], "x",
            "write_also_to_console")

    # delete old online-files
    # switch protocol
    if db.ac_config_1[4] == "FTP":
        delete_ok = delete_files_online_ftp()
    if db.ac_config_1[4] == "SFTP":
        delete_ok = delete_files_online_sftp()
    if delete_ok is None:
        # Error 1
        db.write_log_to_db_a(ac, ac.app_errorslist[1], "x",
            "write_also_to_console")
示例#5
0
        lib_cm.message_write_to_console(ac, dest_file)
        # os.rename(file_orig, dest_file)
        return True
    else:
        # no 100% message, trying to find another error, here in german!
        cmd_output_1 = string.find(p[1], "gibt es nicht")
        if cmd_output_1 != -1:
            db.write_log_to_db_a(
                ac, "Datei auf ftp-Server nicht vorhanden: " + url_source_file, "t", "write_also_to_console"
            )
        else:
            db.write_log_to_db_a(
                ac, ac.app_errorslist[1] + u"100% beim Download nicht erreicht...", "x", "write_also_to_console"
            )
            filename_ftp_temp = lib_cm.extract_filename(ac, url_source_file)
            lib_cm.erase_file_a(ac, db, filename_ftp_temp, "temp-Datei geloescht ")
        return None


def copy_media_to_play_out(path_file_source, dest_file):
    """copy audiofile"""
    success_copy = None
    try:
        shutil.move(path_file_source, dest_file)
        db.write_log_to_db_a(
            ac, u"Audio Vorproduktion: " + path_file_source.encode("ascii", "ignore"), "v", "write_also_to_console"
        )
        db.write_log_to_db_a(ac, u"Audio kopiert: " + dest_file, "c", "write_also_to_console")
        success_copy = True
    except Exception, e:
        db.write_log_to_db_a(ac, ac.app_errorslist[1], "x", "write_also_to_console")