def drive_validation(): """validate drive space utilisation""" dv_errors_found = False dv_space = 'unknown' dv_cmd = Popen(['df'], stdout=PIPE, stderr=PIPE) dv_stdout, dv_stderr = dv_cmd.communicate() MY_LOGGER.debug('stdout:%s', dv_stdout) MY_LOGGER.debug('stderr:%s', dv_stderr) dv_results = dv_stdout.decode('utf-8').splitlines() for dv_line in dv_results: if '/home' in dv_line: dv_space = dv_line.split()[4].split('%')[0] MY_LOGGER.debug('dv_space = %s used on %s', dv_space, platform.node()) wxcutils.save_file(OUTPUT_PATH, 'used-' + platform.node() + '.txt', dv_space)
def animate(a_frames, a_resolution): """create animation file""" def add_txt(at_path, at_file, add_duration): """add text""" if add_duration: line = 'file \'' + at_path + '/' + at_file + '\'' + os.linesep + 'duration 0.05' + os.linesep else: line = 'file \'' + at_path + '/' + at_file + '\'' + os.linesep return line MY_LOGGER.debug('frames = %d', a_frames) a_files = len(FILES) a_text = '' MY_LOGGER.debug('Going throught the last %d frames', a_frames) a_counter = a_files - a_frames while a_counter < a_files: a_text = a_text + add_txt( FILES[a_counter]['dir'], FILES[a_counter]['file'] + FILES[a_counter]['ext'], True) a_counter += 1 # add last frame again, but with no duration a_text += add_txt(FILES[a_files - 1]['dir'], FILES[a_files - 1]['file'] + FILES[a_files - 1]['ext'], False) # save as a file wxcutils.save_file(WORKING_PATH, 'framelist.txt', a_text) # create animation a_res = str(a_resolution) + ':' + str(a_resolution) a_res_text = str(a_resolution) + 'x' + str(a_resolution) # mobile friendly version a_generate = 'ffmpeg -y -threads ' + str( CORES ) + ' -stream_loop -1 -i ' + AUDIO + ' -safe 0 -f concat -i ' + WORKING_PATH + 'framelist.txt -shortest -c:v libx264 -pix_fmt yuv420p -vf scale=' + a_res + ' ' + OUTPUT_PATH + PREFIX + '-' + str( a_frames) + '-' + a_res_text + '.mp4' MY_LOGGER.debug(a_generate) wxcutils.run_cmd(a_generate) # create file with date time info date_time = 'Last generated at ' + get_local_date_time( ) + ' ' + LOCAL_TIME_ZONE + ' [' + get_utc_date_time() + ' UTC].' wxcutils.save_file(OUTPUT_PATH, PREFIX + '-' + str(a_frames) + '.txt', date_time)
def drive_validation(): """validate drive space utilisation""" dv_space = 'unknown' dv_cmd = Popen(['df'], stdout=PIPE, stderr=PIPE) dv_stdout, dv_stderr = dv_cmd.communicate() MY_LOGGER.debug('stdout:%s', dv_stdout) MY_LOGGER.debug('stderr:%s', dv_stderr) dv_results = dv_stdout.decode('utf-8').splitlines() for dv_line in dv_results: if '/dev/root' in dv_line: dv_space = dv_line.split()[4].split('%')[0] MY_LOGGER.debug('dv_space = %s used on %s', dv_space, platform.node()) dv_filename = 'used-' + platform.node() + '.txt' wxcutils.save_file(OUTPUT_PATH, dv_filename, dv_space) # rsync files to server MY_LOGGER.debug('rsync: %s', dv_filename) wxcutils.run_cmd('rsync -t ' + OUTPUT_PATH + dv_filename + ' ' + \ RSYNC_CONFIG['remote user'] + '@' + RSYNC_CONFIG['remote host'] + \ ':' + RSYNC_CONFIG['remote directory'] + '/' + dv_filename)
NEW = wxcutils.load_json(WORKING_PATH, STATION + '-filefound.json') # find what is in the master but not in the new one # DELTA = [x for x in MASTER + NEW if x not in MASTER or x not in NEW] DELTA = [_dict for _dict in NEW if _dict not in MASTER] NUM_DIFFERENCES = len(DELTA) MY_LOGGER.debug('Number of differences = %d', NUM_DIFFERENCES) # save out request from station list wxcutils.save_json(WORKING_PATH, STATION + '-filerequest.json', DELTA) if NUM_DIFFERENCES > 0: KEYS = DELTA[0].KEYS() with open(WORKING_PATH + STATION + '-filerequest.csv', 'w', newline='') as output_file: DICT_WRITER = csv.DictWriter(output_file, KEYS) DICT_WRITER.writeheader() DICT_WRITER.writerows(DELTA) else: MY_LOGGER.debug('No differences to write to a csv file, writing empty file') wxcutils.save_file(WORKING_PATH, STATION + '-filerequest.csv', '') # create zip command CMD = 'zip ' + STATION + '-GK-2a.zip ' for line in DELTA: CMD += ' ' + BASE_DIR + line['date'] + '/' + line['type'] + '/' + \ line['filename'] + line['extension'] wxcutils.save_file(WORKING_PATH, STATION + '-zip-command.txt', CMD) MY_LOGGER.debug('Execution end') MY_LOGGER.debug('-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+')
def animate(a_directory, a_filename, a_extenstion, a_frames, a_suffix, a_resolution): """create animation file""" def add_txt(at_path, at_file, add_duration): """add text""" if add_duration: line = 'file \'' + at_path + '/' + at_file + '\'' + os.linesep + 'duration 0.05' + os.linesep else: line = 'file \'' + at_path + '/' + at_file + '\'' + os.linesep return line MY_LOGGER.debug( 'directory = %s, filename = %s, extenstion = %s, frames = %d, suffix = %s', a_directory, a_filename, a_extenstion, a_frames, a_suffix) a_files = len(FILES) if a_frames > a_files: a_frames = a_files MY_LOGGER.debug( 'Reduced frames to %d as not enough frames exist (max = %d)', a_frames, a_files) a_text = '' MY_LOGGER.debug('Going throught the last %d frames', a_frames) if a_suffix != '': a_suffix = '_' + a_suffix a_counter = a_files - a_frames while a_counter < a_files: a_text = a_text + add_txt( FILES[a_counter]['dir'], FILES[a_counter]['file'] + a_suffix + FILES[a_counter]['ext'], True) if not os.path.exists(FILES[a_counter]['dir'] + '/' + FILES[a_counter]['file'] + a_suffix + FILES[a_counter]['ext']): # need to generate file if a_suffix == '_sanchez': MY_LOGGER.debug('sanchez file to create') MY_LOGGER.debug( '/home/mike/sanchez/Sanchez -s ' + FILES[a_counter]['dir'] + '/' + FILES[a_counter]['file'] + FILES[a_counter]['ext'] + ' -m /home/mike/sanchez/Resources/Mask.jpg -u /home/mike/sanchez/Resources/GK-2A/Underlay.jpg -o ' + FILES[a_counter]['dir'] + '/' + FILES[a_counter]['file'] + a_suffix + FILES[a_counter]['ext'] + ' -t 0070BA') wxcutils.run_cmd( '/home/mike/sanchez/Sanchez -s ' + FILES[a_counter]['dir'] + '/' + FILES[a_counter]['file'] + FILES[a_counter]['ext'] + ' -m /home/mike/sanchez/Resources/Mask.jpg -u /home/mike/sanchez/Resources/GK-2A/Underlay.jpg -o ' + FILES[a_counter]['dir'] + '/' + FILES[a_counter]['file'] + a_suffix + FILES[a_counter]['ext'] + ' -t 0070BA') else: MY_LOGGER.debug('%s file to create', a_suffix) a_counter += 1 # add last frame again, but with no duration a_text += add_txt( FILES[a_files - 1]['dir'], FILES[a_files - 1]['file'] + a_suffix + FILES[a_files - 1]['ext'], False) # save as a file wxcutils.save_file(WORKING_PATH, 'framelist.txt', a_text) # create animation if a_suffix == '': a_suffix = 'raw' a_res = str(a_resolution) + ':' + str(a_resolution) a_res_text = str(a_resolution) + 'x' + str(a_resolution) a_generate = 'ffmpeg -y -safe 0 -threads ' + str( CORES ) + ' -f concat -i ' + WORKING_PATH + 'framelist.txt -c:v libx264 -pix_fmt yuv420p -vf scale=' + a_res + ' ' + OUTPUT_PATH + 'FD-' + a_suffix + '-' + str( a_frames) + '-' + a_res_text + '.mp4' MY_LOGGER.debug(a_generate) wxcutils.run_cmd(a_generate) # create file with date time info date_time = 'Last generated at ' + get_local_date_time( ) + ' ' + LOCAL_TIME_ZONE + ' [' + get_utc_date_time() + ' UTC].' wxcutils.save_file(OUTPUT_PATH, 'FD-' + a_suffix + '-' + str(a_frames) + '.txt', date_time)
def proccess_satellite(sat_info): """process satellite info from web""" # set up variables file_directory = FILE_BASE + sat_info['File base'] MY_LOGGER.debug('Satellite = %s', sat_info['Name']) MY_LOGGER.debug('file_directory = %s', file_directory) MY_LOGGER.debug('last directory = %s', sat_info['Last Directory']) MY_LOGGER.debug('URL = %s', sat_info['URL']) directories = sorted(listFD(sat_info['URL'], '')) # loop through directories for directory in directories: MY_LOGGER.debug('directory = %s', directory) directory_datetime = directory.split('/')[5] MY_LOGGER.debug('directory_datetime = %s', directory_datetime) # skip where getting a website (Cloudflare) if directory_datetime == 'https:': MY_LOGGER.debug('Skipping invalid directory %s', directory_datetime) else: if directory_datetime >= sat_info['Last Directory']: MY_LOGGER.debug('-' * 5) MY_LOGGER.debug('Need to process %s', directory_datetime) elements = directory_datetime.split('_') date_element = elements[0] MY_LOGGER.debug('date_element = %s', date_element) image_files = listFD(directory, 'png') channel_locator = len(sat_info['File in prefix']) + 1 MY_LOGGER.debug('channel_locator = %s', channel_locator) # create directories MY_LOGGER.debug('file_directory = %s', file_directory) mk_dir(file_directory + '/' + date_element) mk_dir(file_directory + '/' + date_element + '/1') mk_dir(file_directory + '/' + date_element + '/2') mk_dir(file_directory + '/' + date_element + '/3') mk_dir(file_directory + '/' + date_element + '/4') mk_dir(file_directory + '/' + date_element + '/5') mk_dir(file_directory + '/' + date_element + '/FC') # make directory for web files (goes13 only) if sat_info['Name'] == 'GOES 13': mk_dir(WEB_PATH + '/goes13/fd/1/' + date_element) mk_dir(WEB_PATH + '/goes13/fd/2/' + date_element) mk_dir(WEB_PATH + '/goes13/fd/3/' + date_element) mk_dir(WEB_PATH + '/goes13/fd/4/' + date_element) mk_dir(WEB_PATH + '/goes13/fd/5/' + date_element) mk_dir(WEB_PATH + '/goes13/fd/FC/' + date_element) existsCount = 0 for file in image_files: filename = file.split('/')[-1] if sat_info['File in prefix'] in filename: MY_LOGGER.debug('filename = %s', filename) channel = '?' if filename[channel_locator] == 'F': file_location = file_directory + '/' + date_element + '/FC/' channel = 'FC' else: file_location = file_directory + '/' + date_element + '/' + filename[ channel_locator] + '/' channel = filename[channel_locator] MY_LOGGER.debug('file_location = %s', file_location) MY_LOGGER.debug('channel = %s', channel) # see if file exists, if not, get it if not os.path.exists( file_location + filename.replace('.png', '.jpg')): # get file MY_LOGGER.debug('Getting file %s', filename) data = requests.get(file) MY_LOGGER.debug('Writing file %s', filename) open(file_location + filename, 'wb').write(data.content) # non-channel 1 and FC images are ~5k x 5k pixels # channel 1 and FC images are 20832 x 18956 ~190MB each # convert all to jpg images, aligned with GOES images size, which are 5424x5424 # keeping the correct aspect ratio so 5424 x 4936 if channel not in ('1', 'FC'): ratio = ' 1' else: ratio = ' 0.2604' cmd = 'vips resize ' + file_location + filename + ' ' + file_location + filename.replace( '.png', '.jpg') + ratio MY_LOGGER.debug('cmd %s', cmd) wxcutils.run_cmd(cmd) # can now delete the original image to save space wxcutils.run_cmd('rm ' + file_location + filename) if sat_info['Name'] == 'GOES 13': bits = filename.split('_') for bit in bits: MY_LOGGER.debug('bit %s', bit) year = bits[-1][:4] month = calendar.month_abbr[int(bits[-1][4:6])] day = bits[-1][6:8] hour = bits[-1][9:11] min = bits[-1][11:13] MY_LOGGER.debug( 'year = %s, month = %s, day = %s, hour = %s min = %s', year, month, day, hour, min) im_date = day + '-' + month + '-' + year im_time = hour + ':' + min + ' UTC' MY_LOGGER.debug( 'Creating branded image - %s, date %s, time %s', channel, im_date, im_time) web_file = create_branded( 'goes', '13', 'fd', channel, file_location, filename.replace('.png', ''), '.jpg', im_date, im_time) # copy to output directory new_filename = 'goes13-' + channel + '.jpg' MY_LOGGER.debug('new_filename = %s', new_filename) wxcutils.copy_file( web_file, os.path.join(OUTPUT_PATH, new_filename)) else: # non-GOES 13 # copy file to output folder wxcutils.copy_file( file_location + filename.replace('.png', '.jpg'), OUTPUT_PATH + sat_info['File out prefix'] + '-' + channel + '.jpg') # create thumbnail and txt file cmd = 'vips resize ' + OUTPUT_PATH + sat_info[ 'File out prefix'] + '-' + channel + '.jpg' + ' ' + OUTPUT_PATH + sat_info[ 'File out prefix'] + '-' + channel + '-tn.jpg' + ' 0.1' MY_LOGGER.debug('cmd %s', cmd) wxcutils.run_cmd(cmd) # create file with date time info MY_LOGGER.debug( 'Writing out last generated date file') wxcutils.save_file( OUTPUT_PATH, sat_info['File out prefix'] + '-' + channel + '.txt', get_last_generated_text( filename.replace('.png', '.jpg'))) else: MY_LOGGER.debug('Already exists %s', file_location + filename) existsCount += 1 # check age of directory to skip over "OLD" directories # 2021-08-11_16-56 directory_datetime_dt = datetime.datetime.strptime( directory_datetime, '%Y-%m-%d_%H-%M') directory_datetime_epoch = wxcutils.utc_datetime_to_epoch( directory_datetime_dt) current_epoch = time.time() directory_age = current_epoch - float( directory_datetime_epoch) MY_LOGGER.debug('current_epoch = %f', current_epoch) MY_LOGGER.debug('directory_datetime_epoch = %f', float(directory_datetime_epoch)) MY_LOGGER.debug('age = %f', directory_age) if existsCount == 6 or directory_age > (6 * 60 * 60): if existsCount == 6: MY_LOGGER.debug( 'all 6 files exist - update last directory') else: MY_LOGGER.debug( 'Directory age is too old, assuming files will not appear - 6 hours' ) if directory_datetime > sat_info['Last Directory']: MY_LOGGER.debug( 'Old last directory = %s, new last directory = %s', sat_info['Last Directory'], directory_datetime) sat_info['Last Directory'] = directory_datetime else: MY_LOGGER.debug( 'No change required - Old last directory = %s, new last directory = %s', sat_info['Last Directory'], directory_datetime)
wxcutils.copy_file( FILE_BASE + image_date + '/' + channel + '/' + filename, OUTPUT_PATH + 'electro-l-2-rgb.jpg' ) # create file with date time info MY_LOGGER.debug( 'Writing out last generated date file' ) wxcutils.save_file( OUTPUT_PATH, 'electro-l-2-rgb.txt', get_last_generated_text( filename)) else: MY_LOGGER.debug( 'File already downloaded' ) # end of time, go up a directory ftp.cwd('..') MY_LOGGER.debug( 'current directory = %s', ftp.pwd()) # end of day, go up a directory ftp.cwd('..')
wxcutils.run_cmd(cmd) # can now delete the original image to save space wxcutils.run_cmd('rm ' + file_location + filename) # save a thumbnail of a channel 1 image to send to webserver if filename[4] == '1': cmd = 'vips resize ' + file_location + filename.replace( '.png', '.jpg' ) + ' ' + OUTPUT_PATH + 'ews-g1-1.jpg' + ' 0.1843' MY_LOGGER.debug('cmd %s', cmd) wxcutils.run_cmd(cmd) # create file with date time info MY_LOGGER.debug('Writing out last generated date file') wxcutils.save_file( OUTPUT_PATH, 'ews-g1-1.txt', get_last_generated_text( filename.replace('.png', '.jpg'))) else: MY_LOGGER.debug('File already exists') last_read = directory_datetime # update config file with latest directory # only if directories were processed if last_read: CONFIG_INFO['Last Directory'] = last_read wxcutils.save_json(CONFIG_PATH, 'ews-g1.json', CONFIG_INFO) MY_LOGGER.debug('Execution end') MY_LOGGER.debug('-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+')
def fix_file(ff_path, ff_filename): """fix file for upgrade""" def update_page(up_page, up_search, up_replace): """update text file with search / replace""" MY_LOGGER.debug('%s %s', up_search, up_replace) if up_search in up_page: MY_LOGGER.debug('%s found', up_search) ff_location = up_page.find(up_search) if ff_location > 0: MY_LOGGER.debug('string found at %d', ff_location) # up_page.replace(up_search, up_replace, 1) left = up_page[0:ff_location] skip = ff_location + len(up_search) right = up_page[skip:] up_page = left + up_replace + right else: MY_LOGGER.debug('string NOT found') else: MY_LOGGER.debug('%s NOT found', up_search) # MY_LOGGER.debug('%s', up_page) return up_page def fix_img(fi_page, fi_path, fi_filename): """fix up the img tags for lightbox""" MY_LOGGER.debug('starting fix_img %s %s', fi_path, fi_filename) start_tag = '<a href=\"images/' mid_tag = '\"><img src=\"images/' end_tag = '\"></a>' parse_pos = 0 new_page = '' img_pos = fi_path.find('/wxcapture/') img_path = fi_path[img_pos:] + 'images/' MY_LOGGER.debug('img_path = %s', img_path) while parse_pos >= 0: if fi_page.find(start_tag, parse_pos) > 0: first_pos_left = fi_page.find(start_tag, parse_pos) + len(start_tag) first_pos_right = fi_page.find(mid_tag, first_pos_left) second_pos_left = first_pos_right + len(mid_tag) second_pos_right = fi_page.find(end_tag, second_pos_left) main_img = fi_page[first_pos_left:first_pos_right] thumb_img = fi_page[second_pos_left:(second_pos_right)] bits = main_img[:10].split('-') img_path = CONFIG_INFO['Link Base'] + bits[0] + '/' + bits[ 1] + '/' + bits[2] + '/images/' MY_LOGGER.debug('%d %s %s %s', parse_pos, main_img, thumb_img, img_path) new_bit_1 = fi_page[parse_pos:(first_pos_left - len(start_tag))] new_bit_2 = '<a class=\"example-image-link\" href=\"' + img_path + \ main_img+ \ '\" data-lightbox=\"' + img_path + main_img + \ '\"><img class=\"example-image\" src=\"' + img_path + \ thumb_img + '"></a>' MY_LOGGER.debug('-start-----------------') MY_LOGGER.debug(new_page) MY_LOGGER.debug('-new_bit_1-------------') MY_LOGGER.debug(new_bit_1) MY_LOGGER.debug('-new_bit_2-------------') MY_LOGGER.debug(new_bit_2) MY_LOGGER.debug('-end-------------------') new_page += new_bit_1 + new_bit_2 parse_pos = second_pos_right + len(end_tag) else: # get the rest of the page new_page += fi_page[parse_pos:] parse_pos = -1 MY_LOGGER.debug('completed fix_img') # fix plot reference MY_LOGGER.debug('fix plot reference') new_page = update_page(new_page, '<img src=\"images/', '<img src=\"' + img_path) return new_page def fix_img_iss(fi_page, fi_path, fi_filename): """fix up the img tags only, no lightbox required""" MY_LOGGER.debug('starting fix_img %s %s', fi_path, fi_filename) start_tag = '<img src=\"images/' end_tag = '\">' parse_pos = 0 new_page = '' img_pos = fi_path.find('/wxcapture/') img_path = fi_path[img_pos:] + 'images/' MY_LOGGER.debug('img_path = %s', img_path) while parse_pos >= 0: if fi_page.find(start_tag, parse_pos) > 0: MY_LOGGER.debug('img tag found') pos_left = fi_page.find(start_tag, parse_pos) + len(start_tag) pos_right = fi_page.find(end_tag, pos_left) main_img = fi_page[pos_left:pos_right] bits = main_img[:10].split('-') img_path = CONFIG_INFO['Link Base'] + bits[0] + '/' + bits[ 1] + '/' + bits[2] + '/images/' MY_LOGGER.debug('%d %s %s', parse_pos, main_img, img_path) new_bit_1 = fi_page[parse_pos:(pos_left - len(start_tag))] new_bit_2 = '<img src=\"' + img_path + main_img + '\">' MY_LOGGER.debug('-start-----------------') MY_LOGGER.debug(new_page) MY_LOGGER.debug('-new_bit_1-------------') MY_LOGGER.debug(new_bit_1) MY_LOGGER.debug('-new_bit_2-------------') MY_LOGGER.debug(new_bit_2) MY_LOGGER.debug('-end-------------------') new_page += new_bit_1 + new_bit_2 parse_pos = pos_right + len(end_tag) else: # get the rest of the page new_page += fi_page[parse_pos:] parse_pos = -1 MY_LOGGER.debug('completed fix_img') # # fix plot reference # MY_LOGGER.debug('fix plot reference') # new_page = update_page(new_page, '<img src=\"images/', '<img src=\"' + img_path) return new_page def fix_audio(fi_page, fi_path, fi_filename): """fix up the audio tags only""" MY_LOGGER.debug('starting fix_audio %s %s', fi_path, fi_filename) start_tag = '<a href=\"audio/' end_tag = '\">' parse_pos = 0 new_page = '' audio_pos = fi_path.find('/wxcapture/') audio_path = fi_path[audio_pos:] + 'audio/' MY_LOGGER.debug('audio_path = %s', audio_path) while parse_pos >= 0: if fi_page.find(start_tag, parse_pos) > 0: MY_LOGGER.debug('audio tag found') pos_left = fi_page.find(start_tag, parse_pos) + len(start_tag) pos_right = fi_page.find(end_tag, pos_left) main_audio = fi_page[pos_left:pos_right] bits = main_audio[:10].split('-') audio_path = CONFIG_INFO['Link Base'] + bits[0] + '/' + bits[ 1] + '/' + bits[2] + '/audio/' MY_LOGGER.debug('%d %s %s', parse_pos, main_audio, audio_path) new_bit_1 = fi_page[parse_pos:(pos_left - len(start_tag))] new_bit_2 = '<a href=\"' + audio_path + main_audio + '\">' MY_LOGGER.debug('-start-----------------') MY_LOGGER.debug(new_page) MY_LOGGER.debug('-new_bit_1-------------') MY_LOGGER.debug(new_bit_1) MY_LOGGER.debug('-new_bit_2-------------') MY_LOGGER.debug(new_bit_2) MY_LOGGER.debug('-end-------------------') new_page += new_bit_1 + new_bit_2 parse_pos = pos_right + len(end_tag) else: # get the rest of the page new_page += fi_page[parse_pos:] parse_pos = -1 MY_LOGGER.debug('completed fix_audio') return new_page MY_LOGGER.debug('fix_file %s %s', ff_path, ff_filename) # load config CONFIG_INFO = wxcutils.load_json(CONFIG_PATH, 'config.json') # create page backup file # only if there isn't an existing .backup file (i.e. our backup of the original) if not os.path.isfile(ff_path + ff_filename + '.backup'): MY_LOGGER.debug('no existing backup, so creating page backup file') wxcutils.copy_file(ff_path + ff_filename, ff_path + ff_filename + '.backup') else: MY_LOGGER.debug('File backup exists, so retaining original backup') # restore the backup and re-fix it wxcutils.copy_file(ff_path + ff_filename + '.backup', ff_path + ff_filename) # load file MY_LOGGER.debug('load file') ff_page = wxcutils.load_file(ff_path, ff_filename) # add stylesheets MY_LOGGER.debug('add stylesheets') ff_page = update_page( ff_page, '</head>', '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><meta name=\"description\" content=\"Satellite pass capture page for NOAA / Meteor / International Space Station (ISS) SSTV / Amsat (Amateur Satellites)\"><meta name=\"keywords\" content=\"wxcapture, weather, satellite, NOAA, Meteor, images, ISS, Zarya, SSTV, Amsat, orbit, APT, LRPT, SDR, Mike, KiwiinNZ, Predictions, Auckland, New Zealand, storm, cyclone, hurricane, front, rain, wind, cloud\"><meta name=\"author\" content=\"WxCapture\"><link rel=\"stylesheet\" href=\"/css/styles.css\"><link rel=\"stylesheet\" href=\"/lightbox/css/lightbox.min.css\"></head>' ) # add script code MY_LOGGER.debug('add script code') ff_page = update_page( ff_page, '</body>', '<script src=\"/lightbox/js/lightbox-plus-jquery.min.js\"></script></body>' ) # remove table start MY_LOGGER.debug('remove table start') ff_page = update_page(ff_page, '</h2><table><tr><td>', '</h2>') # remove table end MY_LOGGER.debug('remove table end') ff_page = update_page(ff_page, '</td><td></table>', '<br>') # remove table border MY_LOGGER.debug('remove table border') ff_page = update_page(ff_page, '<table border = 1>', '<table>') # fix audio link - amsat only if 'ISS' in ff_filename or 'SSTV' in ff_filename or 'SAUDISAT' in ff_filename or 'FOX' in ff_filename: ff_page = fix_audio(ff_page, ff_path, ff_filename) # update img tags to use lightbox if 'ISS' in ff_filename or 'SSTV' in ff_filename: ff_page = fix_img_iss(ff_page, ff_path, ff_filename) else: ff_page = fix_img(ff_page, ff_path, ff_filename) # MY_LOGGER.debug('%s', ff_page) # save file wxcutils.save_file(ff_path, ff_filename, ff_page)