body = body.replace( '<<List of files unavailable in sharepoint to be listed here>>', str(missing_files)[1:-1]) common.send_email(sp_username, sp_password, to, cc, subject, body) sys.exit() except: error_logger.error("Error while downloading", exc_info=True) audit_logger.info("Task Failed") sys.exit() # Step 13: updating the Column C and D try: Application = Dispatch("Excel.Application") Application.Visible = False Application.DisplayAlerts = False Application.AskToUpdateLinks = False Application.EnableEvents = False map_file_data = Application.Workbooks.Open(mapping_flpath) input_download_sheet = map_file_data.Worksheets('Input_Download') Application.Worksheets('Input_Download').Activate() row_count = 0 while True: row_count += 1 fname = input_download_sheet.Cells(row_count, 0).Value if fname: if fname in [missing_files]: input_download_sheet.Cells(row_count, 0).Value = 'Not Done' else: input_download_sheet.Cells(row_count, 2).Value = 'Done' input_download_sheet.Cells(row_count, 3).Value = datetime.strftime(
import os import glob from win32com.client import Dispatch excel = Dispatch('Excel.Application') excel.Visible = True XlDirectionDown = 4 #Not needed yet excel.DisplayAlerts = False excel.Application.CutCopyMode = False excel.AskToUpdateLinks = False #supposed to disable the update links popup machine = excel.Workbooks.Add( max(glob.iglob( r'C:\Users\andyd_000\Desktop\Python\Internal Machine Practice\Internal Machine\The Bible rev111*' ), key=os.path.getctime)) dom_vod = max(glob.iglob( r'C:\Users\andyd_000\Desktop\Python\Internal Machine Practice\1. Domestic Tracker\*.xlsx' ), key=os.path.getctime) uk_vod = max(glob.iglob( r'C:\Users\andyd_000\Desktop\Python\Internal Machine Practice\2. UK Tracker\*.xlsx' ), key=os.path.getctime) dom_linear_pb = max(glob.iglob( r'C:\Users\andyd_000\Desktop\Python\Internal Machine Practice\9. DOM Linear Tracker\2014_12_December PBTV*' ), key=os.path.getctime) dom_linear_hots = max(glob.iglob( r'C:\Users\andyd_000\Desktop\Python\Internal Machine Practice\9. DOM Linear Tracker\2014_12_Dec_Linear_Hots*' ),