def work_on_files(roboting_sgs): """ - search audiofiles from roboting-sgs, - if found, work on them """ lib_cm.message_write_to_console(ac, "work_on_files") # dropbox for item in roboting_sgs: lib_cm.message_write_to_console(ac, item[0].encode('ascii', 'ignore')) titel = item[0] # search in db for sheduled shows sendungen = load_sg(titel) if sendungen is None: lib_cm.message_write_to_console(ac, "Keine Sendungen gefunden") continue for sendung in sendungen: db.write_log_to_db_a(ac, "Sendung fuer VP nach extern gefunden: " + sendung[11].encode('ascii', 'ignore'), "t", "write_also_to_console") # create path and filename (success, path_f_source, path_file_cloud, path_ftp, filename_dest) = filepaths(item, sendung) if success is False: continue success_file = check_file_source(path_f_source, sendung) if success_file is False: continue if item[1].strip() == "T": # to Cloud lib_cm.message_write_to_console(ac, "dropbox") file_is_in_cloud = check_file_dest_cloud(path_file_cloud) if file_is_in_cloud is True: continue # copy to dropbox success_copy = copy_to_cloud(path_f_source, path_file_cloud) if success_copy is False: continue # info-txt-file success_write_temp, path_file_temp = write_to_info_file( filename_dest, item, sendung) if success_write_temp is False: # probs with file continue # copy info-file to dropbox filename_info = path_file_cloud.replace("mp3", "txt") success_copy = copy_to_cloud(path_file_temp, filename_info) if success_copy is False: continue #db.write_log_to_db_a(ac, # "VP in Dropbox kopiert: " + filename_dest, "i", # "write_also_to_console") db.write_log_to_db_a(ac, "VP in Dropbox kopiert: " + filename_dest, "n", "write_also_to_console") # delete tmp-info-file if success_write_temp is not False: lib_cm.erase_file(ac, db, path_file_temp) # ftp for sendung in sendungen: db.write_log_to_db_a(ac, "Sendung fuer VP nach extern gefunden: " + sendung[11].encode('ascii', 'ignore'), "t", "write_also_to_console") # create path and filename (success, path_f_source, path_file_cloud, path_ftp, filename_dest) = filepaths(item, sendung) if success is False: continue success_file = check_file_source(path_f_source, sendung) if success_file is False: continue if item[3].strip() == "T": # to ftp lib_cm.message_write_to_console(ac, "ftp") file_is_online = check_file_dest_ftp(path_ftp, filename_dest) if file_is_online is True: continue if file_is_online is None: # an error occures continue # ftp-upload success_upload = ftp_upload( path_f_source, path_ftp, filename_dest) if success_upload is False: continue # info-txt-file success_write_temp, path_file_temp = write_to_info_file( filename_dest, item, sendung) if success_write_temp is False: # probs with file continue # ftp-upload info-file filename_info = filename_dest.replace("mp3", "txt") success_upload = ftp_upload( path_file_temp, path_ftp, filename_info) if success_upload is False: continue #db.write_log_to_db_a(ac, # "VP auf ftp uebertragen: " + filename_dest, "i", # "write_also_to_console") db.write_log_to_db_a(ac, "VP auf ftp uebertragen: " + filename_dest, "n", "write_also_to_console") # delete tmp-info-file if success_write_temp is not False: lib_cm.erase_file(ac, db, path_file_temp)
def work_on_files(sendungen, base_path_source): """ - search for audio files of shows - if found, work on it """ lib_cm.message_write_to_console(ac, u"check_and_work_on_files") # dropbox for sendung in sendungen: db.write_log_to_db_a(ac, u"Sendung fuer VP nach extern gefunden: " + sendung[11].encode('ascii', 'ignore'), "t", "write_also_to_console") (success, path_f_source, path_file_cloud, path_ftp, filename_dest) = filepaths(sendung, base_path_source) if success is False: continue success_file = check_file_source(path_f_source, sendung) if success_file is False: continue # dropbox if db.ac_config_1[10] == "on": db.write_log_to_db_a(ac, "VP nach Dropbox bearbeiten: ", "p", "write_also_to_console") file_is_in_cloud = check_file_dest_cloud(path_file_cloud) if file_is_in_cloud is True: continue # copy to cloud success_copy = copy_to_cloud(path_f_source, path_file_cloud) if success_copy is None: continue # info-file success_write_temp, path_file_temp = write_to_info_file( filename_dest, sendung) if success_write_temp is False: # probs with file continue # copy info-file to dropbox filename_info = path_file_cloud.replace("mp3", "txt") success_copy = copy_to_cloud(path_file_temp, filename_info) if success_copy is False: continue db.write_log_to_db_a(ac, "VP in Dropbox kopiert: " + filename_dest, "n", "write_also_to_console") # delete files in cloud erase_files_prepaere() # delete tmp-info-file if success_write_temp is not False: lib_cm.erase_file(ac, db, path_file_temp) # ftp for sendung in sendungen: db.write_log_to_db_a(ac, u"Sendung fuer VP nach extern gefunden: " + sendung[11].encode('ascii', 'ignore'), "t", "write_also_to_console") (success, path_f_source, path_file_cloud, path_ftp, filename_dest) = filepaths(sendung, base_path_source) if success is False: continue success_file = check_file_source(path_f_source, sendung) if success_file is False: continue # ftp if db.ac_config_1[11] == "on": db.write_log_to_db_a(ac, "VP nach ftp bearbeiten: ", "p", "write_also_to_console") file_is_online = check_file_dest_ftp(path_ftp, filename_dest) if file_is_online is True: continue if file_is_online is None: # an error occures continue # ftp-upload success_upload = ftp_upload( path_f_source, path_ftp, filename_dest) if success_upload is False: continue # info-file success_write_temp, path_file_temp = write_to_info_file( filename_dest, sendung) if success_write_temp is False: # probs with file continue # ftp-upload info-file filename_info = filename_dest.replace("mp3", "txt") success_upload = ftp_upload( path_file_temp, path_ftp, filename_info) if success_upload is False: continue db.write_log_to_db_a(ac, "VP auf ftp uebertragen: " + filename_dest, "n", "write_also_to_console") # delete fiels on ftp erase_files_prepaere() # delete tmp-info-file if success_write_temp is not False: lib_cm.erase_file(ac, db, path_file_temp)
def work_on_files(sendungen, base_path_source): """ - search for audio files of shows - if found, work on it """ lib_cm.message_write_to_console(ac, u"check_and_work_on_files") # dropbox for sendung in sendungen: db.write_log_to_db_a( ac, u"Sendung fuer VP nach extern gefunden: " + sendung[11].encode('ascii', 'ignore'), "t", "write_also_to_console") (success, path_f_source, path_file_cloud, path_ftp, filename_dest) = filepaths(sendung, base_path_source) if success is False: continue success_file = check_file_source(path_f_source, sendung) if success_file is False: continue # dropbox if db.ac_config_1[10] == "on": db.write_log_to_db_a(ac, "VP nach Dropbox bearbeiten: ", "p", "write_also_to_console") file_is_in_cloud = check_file_dest_cloud(path_file_cloud) if file_is_in_cloud is True: continue # copy to cloud success_copy = copy_to_cloud(path_f_source, path_file_cloud) if success_copy is None: continue # info-file success_write_temp, path_file_temp = write_to_info_file( filename_dest, sendung) if success_write_temp is False: # probs with file continue # copy info-file to dropbox filename_info = path_file_cloud.replace("mp3", "txt") success_copy = copy_to_cloud(path_file_temp, filename_info) if success_copy is False: continue db.write_log_to_db_a(ac, "VP in Dropbox kopiert: " + filename_dest, "n", "write_also_to_console") # delete files in cloud erase_files_prepaere() # delete tmp-info-file if success_write_temp is not False: lib_cm.erase_file(ac, db, path_file_temp) # ftp for sendung in sendungen: db.write_log_to_db_a( ac, u"Sendung fuer VP nach extern gefunden: " + sendung[11].encode('ascii', 'ignore'), "t", "write_also_to_console") (success, path_f_source, path_file_cloud, path_ftp, filename_dest) = filepaths(sendung, base_path_source) if success is False: continue success_file = check_file_source(path_f_source, sendung) if success_file is False: continue # ftp if db.ac_config_1[11] == "on": db.write_log_to_db_a(ac, "VP nach ftp bearbeiten: ", "p", "write_also_to_console") file_is_online = check_file_dest_ftp(path_ftp, filename_dest) if file_is_online is True: continue if file_is_online is None: # an error occures continue # ftp-upload success_upload = ftp_upload(path_f_source, path_ftp, filename_dest) if success_upload is False: continue # info-file success_write_temp, path_file_temp = write_to_info_file( filename_dest, sendung) if success_write_temp is False: # probs with file continue # ftp-upload info-file filename_info = filename_dest.replace("mp3", "txt") success_upload = ftp_upload(path_file_temp, path_ftp, filename_info) if success_upload is False: continue db.write_log_to_db_a(ac, "VP auf ftp uebertragen: " + filename_dest, "n", "write_also_to_console") # delete fiels on ftp erase_files_prepaere() # delete tmp-info-file if success_write_temp is not False: lib_cm.erase_file(ac, db, path_file_temp)