def get_remote_filename(meeting_folder_name, tdoc_id, use_inbox=False, searching_for_a_file=False, use_email_approval_inbox=False): folder = get_remote_meeting_folder(meeting_folder_name, use_inbox, searching_for_a_file) if not use_inbox: # Check if this is a TDoc revision. If yes, change the folder to the revisions folder. Need to see how this works # duringa meeting, but this is something to test in 2021 :P year, tdoc_number, revision = tdoc.get_tdoc_year(tdoc_id, include_revision=True) if revision is not None: folder = get_remote_meeting_revisions_folder(folder) else: if use_email_approval_inbox: folder += 'Inbox/' else: folder += 'Docs/' elif use_inbox: # No need to add 'Docs/' pass return folder + tdoc_id + '.zip'
def set_tdoc_id_full(*args): # Sets the label for the download button tdoc_id = tkvar_tdoc_id.get() tdoc_year,tdoc_number = tdoc.get_tdoc_year(tdoc_id) if tkvar_search_tdoc.get(): command_string = 'Search' else: command_string = 'Open' button_label = command_string if tdoc.is_tdoc(tdoc_id): button_label += ' ' + tdoc_id tkvar_tdoc_id_full.set(button_label) if tdoc.is_tdoc(tdoc_id): # Enable button open_tdoc_button.configure(state=tkinter.NORMAL) else: # Disable button open_tdoc_button.configure(state=tkinter.DISABLED)
def get_local_folder(meeting_folder_name, tdoc_id, create_dir=True, email_approval=False): meeting_folder = get_meeting_folder(meeting_folder_name) year, tdoc_number, revision = tdoc.get_tdoc_year(tdoc_id, include_revision=True) if revision is not None: # Remove 'rXX' from the name for folder generation if found tdoc_id = tdoc_id[:-3] folder_name = os.path.join(meeting_folder, tdoc_id) if email_approval: folder_name = os.path.join(folder_name, 'email approval') if create_dir and (not os.path.exists(folder_name)): os.makedirs(folder_name, exist_ok=True) return folder_name
def download_and_open_tdoc(tdoc_id_to_override=None, cached_tdocs_list=None, copy_to_clipboard=False): global performing_search tkvar_tdoc_id.set(tkvar_tdoc_id.get().replace(' ','').replace('\r','').replace('\n','').strip()) if tdoc_id_to_override is None: # Normal flow tdoc_id = tkvar_tdoc_id.get() else: # Used to compare two tdocs tdoc_id = tdoc_id_to_override download_from_inbox = inbox_is_for_this_meeting() retrieved_files, tdoc_url = server.get_tdoc( application.sa2_meeting_data.get_server_folder_for_meeting_choice(tkvar_meeting.get()), tdoc_id, use_inbox=download_from_inbox, return_url=True, searching_for_a_file=True) if copy_to_clipboard: if tdoc_url is None: clipboard_text = tdoc_id else: clipboard_text = '{0}, {1}'.format(tdoc_id, tdoc_url) clipboard_copy(clipboard_text) print('Copied TDoc ID and URL (if available) to clipboard: {0}'.format(clipboard_text)) # Set file information if available tkvar_last_tdoc_url.set(tdoc_url) # Set current status if found try: tdoc_status = application.current_tdocs_by_agenda.tdocs.at[tdoc_id,'Result'] if tdoc_status is None: tdoc_status = '' except: tdoc_status = '<unknown>' tkvar_last_tdoc_status.set(tdoc_status) try: # ToDo: download current TDocs by agenda pass except: print('Could not load TDoc agenda info for {0}'.format(tkvar_tdoc_id.get())) if (retrieved_files is None) or (len(retrieved_files) == 0): tdoc_year,tdoc_number = tdoc.get_tdoc_year(tdoc_id) # Search on meetings from the given year if the TDoc is not found if tkvar_search_tdoc.get() and (tdoc_year is not None) and (not performing_search): # Retrieve search for all meetings of the year performing_search = True try: # Search while we still did not find a match meetings_to_check = application.sa2_meeting_data.get_meetings_for_given_year(tdoc_year) print('Will search meetings: {0}'.format('; '.join(meetings_to_check.meeting_folders))) for meeting_to_search in meetings_to_check.meeting_folders: tkvar_meeting.set(meeting_to_search) download_and_open_tdoc() if not performing_search: not_found_string = None break not_found_string = 'Not found (' + tdoc_id + ')' finally: performing_search = False else: not_found_string = 'Not found (' + tdoc_id + ')' if not_found_string is not None: tkvar_tdoc_download_result.set(not_found_string) else: if not open_downloaded_tdocs: found_string = 'Cached file(s)' opened_files = 0 metadata_list = [] if cached_tdocs_list is not None and isinstance(cached_tdocs_list, list): cached_tdocs_list.extend(retrieved_files) else: opened_files, metadata_list = tdoc.openfiles(retrieved_files, return_metadata=True) found_string = 'Opened {0} file(s)'.format(opened_files) tkvar_last_doc_tdoc.set(tkvar_tdoc_id.get()) if performing_search: found_string += ' (' + tkvar_meeting.get() + ')' performing_search = False tkvar_tdoc_download_result.set(found_string) if len(metadata_list)>0: last_metadata = metadata_list[-1] if last_metadata is not None: if last_metadata.title is not None: tkvar_last_doc_title.set(last_metadata.title) if last_metadata.source is not None: tkvar_last_doc_source.set(last_metadata.source)