n@1118: #!/usr/bin/python n@1118: # -*- coding: utf-8 -*- n@1118: n@1118: import xml.etree.ElementTree as ET n@1118: import os # for getting files from directory n@1118: import operator # for sorting data with multiple keys n@1118: import sys # for accessing command line arguments n@1118: import subprocess # for calling pdflatex n@1118: import shlex # for calling pdflatex n@1118: import matplotlib.pyplot as plt # plots n@1118: import numpy as np # numbers n@1118: n@1118: # Command line arguments n@1118: assert len(sys.argv)<4, "generate_report takes at most 2 command line arguments\n"+\ n@1118: "Use: python generate_report.py [results_folder] [no_render | -nr]" n@1118: n@1118: render_figures = True n@1118: n@1118: # XML results files location n@1118: if len(sys.argv) == 1: n@1118: folder_name = "../saves/" # Looks in 'saves/' folder from 'scripts/' folder n@1118: print "Use: python generate_report.py [results_folder] [no_render | -nr]" n@1118: print "Using default path: " + folder_name n@1118: elif len(sys.argv) == 2: n@1118: folder_name = sys.argv[1] # First command line argument is folder n@1118: elif len(sys.argv) == 3: n@1118: folder_name = sys.argv[1] # First command line argument is folder n@1118: assert sys.argv[2] in ('no_render','-nr'), "Second argument not recognised. \n" +\ n@1118: "Use: python generate_report.py [results_folder] [no_render | -nr]" n@1118: # Second command line argument is [no_render | -nr] n@1118: render_figures = False n@1118: n@1118: def isNaN(num): n@1118: return num != num n@1118: n@1118: # Turn number of seconds (int) to '[minutes] min [seconds] s' (string) n@1118: def seconds2timestr(time_in_seconds): n@1118: if time_in_seconds is not None and not isNaN(time_in_seconds): n@1118: time_in_minutes = int(time_in_seconds/60) n@1118: remaining_seconds = int(time_in_seconds%60) n@1118: return str(time_in_minutes) + " min " + str(remaining_seconds) + " s" n@1118: else: n@1118: return 'N/A' n@1118: n@1118: # stats initialisation n@1118: number_of_XML_files = 0 n@1118: number_of_pages = 0 n@1118: number_of_fragments = 0 n@1118: total_empty_comments = 0 n@1118: total_not_played = 0 n@1118: total_not_moved = 0 n@1118: time_per_page_accum = 0 n@1118: n@1118: # arrays initialisation n@1118: page_names = [] n@1118: real_page_names = [] # regardless of differing numbers of fragments n@1118: subject_count = [] # subjects per audioholder name n@1118: page_count = [] n@1118: duration_page = [] # duration of experiment in function of page content n@1118: duration_order = [] # duration of experiment in function of page number n@1118: fragments_per_page = [] # number of fragments for corresponding page n@1118: n@1118: # survey stats n@1118: gender = [] n@1118: age = [] n@1118: n@1118: # get username if available n@1118: for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'): n@1118: user = os.environ.get(name) n@1118: if user: n@1118: break n@1118: else: n@1118: user = '' n@1118: n@1118: n@1118: # begin LaTeX document n@1118: header = r'''\documentclass[11pt, oneside]{article} n@1118: \usepackage{geometry} n@1118: \geometry{a4paper} n@1118: \usepackage[parfill]{parskip} % empty line instead of indent n@1118: \usepackage{graphicx} % figures n@1118: \usepackage[space]{grffile} % include figures with spaces in paths n@1118: \usepackage{hyperref} n@1118: \usepackage{tikz} % pie charts n@1118: \title{Report} n@1118: \author{'''+\ n@1118: user+\ n@1118: r'''} n@1118: \graphicspath{{'''+\ n@1118: folder_name+\ n@1118: r'''}} n@1118: %\setcounter{section}{-1} % Summary section 0 so number of sections equals number of files n@1118: \begin{document} n@1118: \maketitle n@1118: This is an automatically generated report using the `generate\_report.py' Python script n@1118: included with the Web Audio Evaluation Tool \cite{WAET} distribution which can be found n@1118: at \texttt{code.soundsoftware.ac.uk/projects/webaudioevaluationtool}. n@1118: \tableofcontents n@1118: n@1118: ''' n@1118: n@1118: footer = '\n\t\t'+r'''\begin{thebibliography}{9} n@1118: \bibitem{WAET} % reference to accompanying publication n@1118: Nicholas Jillings, Brecht De Man, David Moffat and Joshua D. Reiss, n@1118: ``Web Audio Evaluation Tool: A browser-based listening test environment,'' n@1118: presented at the 12th Sound and Music Computing Conference, July 2015. n@1118: \end{thebibliography} n@1118: \end{document}''' n@1118: n@1118: body = '' n@1118: n@1118: # make sure folder_name ends in '/' n@1118: folder_name = os.path.join(folder_name, '') n@1118: n@1118: # generate images for later use n@1118: if render_figures: n@1118: subprocess.call("python timeline_view_movement.py '"+folder_name+"'", shell=True) n@1118: subprocess.call("python score_parser.py '"+folder_name+"'", shell=True) n@1118: subprocess.call("python score_plot.py '"+folder_name+"ratings/'", shell=True) n@1118: n@1118: # get every XML file in folder n@1118: files_list = os.listdir(folder_name) n@1118: for file in files_list: # iterate over all files in files_list n@1118: if file.endswith(".xml"): # check if XML file n@1118: number_of_XML_files += 1 n@1118: tree = ET.parse(folder_name + file) n@1118: root = tree.getroot() n@1118: n@1118: # PRINT name as section n@1118: body+= '\n\section{'+file[:-4].capitalize()+'}\n' # make section header from name without extension n@1118: n@1118: # reset for new subject n@1118: total_duration = 0 n@1118: page_number = 0 n@1118: n@1118: individual_table = '\n' # table with stats for this individual test file n@1118: timeline_plots = '' # plots of timeline (movements and plays) n@1118: n@1118: # DEMO survey stats n@1118: # get gender n@1118: this_subjects_gender = root.find("./posttest/radio/[@id='gender']") n@1118: if this_subjects_gender is not None: n@1118: gender.append(this_subjects_gender.get("name")) n@1118: else: n@1118: gender.append('UNAVAILABLE') n@1118: # get age n@1118: this_subjects_age = root.find("./posttest/number/[@id='age']") n@1118: if this_subjects_age is not None: n@1118: age.append(this_subjects_age.text) n@1118: #TODO add plot of age n@1118: n@1118: # get list of all page names n@1118: for audioholder in root.findall("./audioholder"): # iterate over pages n@1118: page_name = audioholder.get('id') # get page name n@1118: n@1118: if page_name is None: # ignore 'empty' audio_holders n@1118: print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)" n@1118: break # move on to next n@1118: n@1118: number_of_comments = 0 # for this page n@1118: number_of_missing_comments = 0 # for this page n@1118: not_played = [] # for this page n@1118: not_moved = [] # for this page n@1118: n@1118: if audioholder.find("./metric/metricresult[@id='testTime']") is not None: # check if time is included n@1118: # 'testTime' keeps total duration: subtract time so far for duration of this audioholder n@1118: duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration n@1118: n@1118: # total duration of test n@1118: total_duration += duration n@1118: else: n@1118: duration = float('nan') n@1118: total_duration = float('nan') n@1118: n@1118: # number of audio elements n@1118: audioelements = audioholder.findall("./audioelement") # get audioelements n@1118: number_of_fragments += len(audioelements) # add length of this list to total n@1118: n@1118: # number of comments (interesting if comments not mandatory) n@1118: for audioelement in audioelements: n@1118: response = audioelement.find("./comment/response") n@1118: was_played = audioelement.find("./metric/metricresult/[@name='elementFlagListenedTo']") n@1118: was_moved = audioelement.find("./metric/metricresult/[@name='elementFlagMoved']") n@1118: if response.text is not None and len(response.text) > 1: n@1118: number_of_comments += 1 n@1118: else: n@1118: number_of_missing_comments += 1 n@1118: if was_played is not None and was_played.text == 'false': n@1118: not_played.append(audioelement.get('id')) n@1118: if was_moved is not None and was_moved.text == 'false': n@1118: not_moved.append(audioelement.get('id')) n@1118: n@1118: # update global counters n@1118: total_empty_comments += number_of_missing_comments n@1118: total_not_played += len(not_played) n@1118: total_not_moved += len(not_moved) n@1118: n@1118: # PRINT alerts when elements not played or markers not moved n@1118: # number of audio elements not played n@1118: if len(not_played) > 1: n@1118: body += '\t\t\\emph{\\textbf{ATTENTION: '+str(len(not_played))+\ n@1118: ' fragments were not listened to in '+page_name+'! }}'+\ n@1118: ', '.join(not_played)+'\\\\ \n' n@1118: if len(not_played) == 1: n@1118: body += '\t\t\\emph{\\textbf{ATTENTION: one fragment was not listened to in '+page_name+'! }}'+\ n@1118: not_played[0]+'\\\\ \n' n@1118: n@1118: # number of audio element markers not moved n@1118: if len(not_moved) > 1: n@1118: body += '\t\t\\emph{\\textbf{ATTENTION: '+str(len(not_moved))+\ n@1118: ' markers were not moved in '+page_name+'! }}'+\ n@1118: ', '.join(not_moved)+'\\\\ \n' n@1118: if len(not_moved) == 1: n@1118: body += '\t\t\\emph{\\textbf{ATTENTION: one marker was not moved in '+page_name+'! }}'+\ n@1118: not_moved[0]+'\\\\ \n' n@1118: n@1118: # PRINT song-specific statistic n@1118: individual_table += '\t\t'+page_name+'&'+\ n@1118: str(number_of_comments) + '/' +\ n@1118: str(number_of_comments+number_of_missing_comments)+'&'+\ n@1118: seconds2timestr(duration)+'\\\\\n' n@1118: n@1118: # get timeline for this audioholder n@1118: img_path = 'timelines_movement/'+file[:-4]+'-'+page_name+'.pdf' n@1118: n@1118: # check if available n@1118: if os.path.isfile(folder_name+img_path): n@1118: # SHOW timeline image n@1118: timeline_plots += '\\includegraphics[width=\\textwidth]{'+\ n@1118: folder_name+img_path+'}\n\t\t' n@1118: n@1118: # keep track of duration in function of page index n@1118: if len(duration_order)>page_number: n@1118: duration_order[page_number].append(duration) n@1118: else: n@1118: duration_order.append([duration]) n@1118: n@1118: # keep list of audioholder ids and count how many times each audioholder id n@1118: # was tested, how long it took, and how many fragments there were n@1118: # (if number of fragments is different, store as different audioholder id) n@1118: if page_name in page_names: n@1118: page_index = page_names.index(page_name) # get index n@1118: # check if number of audioelements the same n@1118: if len(audioelements) == fragments_per_page[page_index]: n@1118: page_count[page_index] += 1 n@1118: duration_page[page_index].append(duration) n@1118: else: # make new entry n@1118: alt_page_name = page_name+"("+str(len(audioelements))+")" n@1118: if alt_page_name in page_names: # if already there n@1118: alt_page_index = page_names.index(alt_page_name) # get index n@1118: page_count[alt_page_index] += 1 n@1118: duration_page[alt_page_index].append(duration) n@1118: else: n@1118: page_names.append(alt_page_name) n@1118: page_count.append(1) n@1118: duration_page.append([duration]) n@1118: fragments_per_page.append(len(audioelements)) n@1118: else: n@1118: page_names.append(page_name) n@1118: page_count.append(1) n@1118: duration_page.append([duration]) n@1118: fragments_per_page.append(len(audioelements)) n@1118: n@1118: # number of subjects per audioholder regardless of differing numbers of n@1118: # fragments (for inclusion in box plots) n@1118: if page_name in real_page_names: n@1118: page_index = real_page_names.index(page_name) # get index n@1118: subject_count[page_index] += 1 n@1118: else: n@1118: real_page_names.append(page_name) n@1118: subject_count.append(1) n@1118: n@1118: # bookkeeping n@1118: page_number += 1 # increase page count for this specific test n@1118: number_of_pages += 1 # increase total number of pages n@1118: time_per_page_accum += duration # total duration (for average time spent per page) n@1118: n@1118: # PRINT table with statistics about this test n@1118: body += '\t\t'+r'''\begin{tabular}{|p{3.5cm}|c|p{2.5cm}|} n@1118: \hline n@1118: \textbf{Song name} & \textbf{Comments} & \textbf{Duration} \\ \hline '''+\ n@1118: individual_table+'\t\t'+\ n@1118: r'''\hline n@1118: \textbf{TOTAL} & & \textbf{'''+\ n@1118: seconds2timestr(total_duration)+\ n@1118: r'''}\\ n@1118: \hline n@1118: \end{tabular} n@1118: n@1118: ''' n@1118: # PRINT timeline plots n@1118: body += timeline_plots n@1118: n@1118: # join to footer n@1118: footer = body + footer n@1118: n@1118: # empty body again n@1118: body = '' n@1118: n@1118: # PRINT summary of everything (at start) n@1118: # unnumbered so that number of sections equals number of files n@1118: body += '\section*{Summary}\n\t\t\\addcontentsline{toc}{section}{Summary}\n' n@1118: n@1118: # PRINT table with statistics n@1118: body += '\t\t\\begin{tabular}{ll}\n\t\t\t' n@1118: body += r'Number of XML files: &' + str(number_of_XML_files) + r'\\'+'\n\t\t\t' n@1118: body += r'Number of pages: &' + str(number_of_pages) + r'\\'+'\n\t\t\t' n@1118: body += r'Number of fragments: &' + str(number_of_fragments) + r'\\'+'\n\t\t\t' n@1118: body += r'Number of empty comments: &' + str(total_empty_comments) +\ n@1118: " (" + str(round(100.0*total_empty_comments/number_of_fragments,2)) + r"\%)\\"+'\n\t\t\t' n@1118: body += r'Number of unplayed fragments: &' + str(total_not_played) +\ n@1118: " (" + str(round(100.0*total_not_played/number_of_fragments,2)) + r"\%)\\"+'\n\t\t\t' n@1118: body += r'Number of unmoved markers: &' + str(total_not_moved) +\ n@1118: " (" + str(round(100.0*total_not_moved/number_of_fragments,2)) + r"\%)\\"+'\n\t\t\t' n@1118: body += r'Average time per page: &' + seconds2timestr(time_per_page_accum/number_of_pages) + r"\\"+'\n\t\t' n@1118: body += '\\end{tabular} \\vspace{1.5cm} \\\\ \n' n@1118: n@1118: # Average duration for first, second, ... page n@1118: body += "\t\t\\vspace{.5cm} \n\n\t\tAverage duration per page (see also Figure \\ref{fig:avgtimeperpage}): \\\\ \n\t\t" n@1118: body += r'''\begin{tabular}{lll} n@1118: \textbf{Page} & \textbf{Duration} & \textbf{\# subjects}\\''' n@1118: tpp_averages = [] # store average time per page n@1118: for page_number in range(len(duration_order)): n@1118: body += '\n\t\t\t'+str(page_number+1) + "&" +\ n@1118: seconds2timestr(sum(duration_order[page_number])/len(duration_order[page_number])) +\ n@1118: "&"+str(len(duration_order[page_number]))+r"\\" n@1118: tpp_averages.append(sum(duration_order[page_number])/len(duration_order[page_number])) n@1118: n@1118: body += '\n\t\t\\end{tabular} \\vspace{1.5cm} \\\\ \n\n\t\t' n@1118: n@1118: # SHOW bar plot of average time per page n@1118: plt.bar(range(1,len(duration_order)+1), np.array(tpp_averages)/60) n@1118: plt.xlabel('Page order') n@1118: plt.xlim(.8, len(duration_order)+1) n@1118: plt.xticks(np.arange(1,len(duration_order)+1)+.4, range(1,len(duration_order)+1)) n@1118: plt.ylabel('Average time [minutes]') n@1118: plt.savefig(folder_name+"time_per_page.pdf", bbox_inches='tight') n@1118: plt.close() n@1118: #TODO add error bars n@1118: n@1118: n@1118: # Sort pages by number of audioelements, then by duration n@1118: n@1118: # average duration and number of subjects per page n@1118: average_duration_page = [] n@1118: number_of_subjects_page = [] n@1118: for line in duration_page: n@1118: number_of_subjects_page.append(len(line)) n@1118: average_duration_page.append(sum(line)/len(line)) n@1118: n@1118: # combine and sort in function of number of audioelements and duration n@1118: combined_list = [page_names, average_duration_page, fragments_per_page, number_of_subjects_page] n@1118: combined_list = sorted(zip(*combined_list), key=operator.itemgetter(1, 2)) # sort n@1118: n@1118: # Show average duration for all songs n@1118: body += r'''\vspace{.5cm} n@1118: Average duration per audioholder (see also Figure \ref{fig:avgtimeperaudioholder}): \\ n@1118: \begin{tabular}{llll} n@1118: \textbf{Audioholder} & \textbf{Duration} & \textbf{\# subjects} & \textbf{\# fragments} \\''' n@1118: audioholder_names_ordered = [] n@1118: average_duration_audioholder_ordered = [] n@1118: number_of_subjects = [] n@1118: for page_index in range(len(page_names)): n@1118: audioholder_names_ordered.append(combined_list[page_index][0]) n@1118: average_duration_audioholder_ordered.append(combined_list[page_index][1]) n@1118: number_of_subjects.append(combined_list[page_index][3]) n@1118: body += '\n\t\t\t'+combined_list[page_index][0] + "&" +\ n@1118: seconds2timestr(combined_list[page_index][1]) + "&" +\ n@1118: str(combined_list[page_index][3]) + "&" +\ n@1118: str(combined_list[page_index][2]) + r"\\" n@1118: body += '\n\t\t\\end{tabular}\n' n@1118: n@1118: # SHOW bar plot of average time per page n@1118: plt.bar(range(1,len(audioholder_names_ordered)+1), np.array(average_duration_audioholder_ordered)/60) n@1118: plt.xlabel('Audioholder') n@1118: plt.xlim(.8, len(audioholder_names_ordered)+1) n@1118: plt.xticks(np.arange(1,len(audioholder_names_ordered)+1)+.4, audioholder_names_ordered, rotation=90) n@1118: plt.ylabel('Average time [minutes]') n@1118: plt.savefig(folder_name+"time_per_audioholder.pdf", bbox_inches='tight') n@1118: plt.close() n@1118: n@1118: # SHOW bar plot of average time per page n@1118: plt.bar(range(1,len(audioholder_names_ordered)+1), number_of_subjects) n@1118: plt.xlabel('Audioholder') n@1118: plt.xlim(.8, len(audioholder_names_ordered)+1) n@1118: plt.xticks(np.arange(1,len(audioholder_names_ordered)+1)+.4, audioholder_names_ordered, rotation=90) n@1118: plt.ylabel('Number of subjects') n@1118: ax = plt.gca() n@1118: ylims = ax.get_ylim() n@1118: yint = np.arange(int(np.floor(ylims[0])), int(np.ceil(ylims[1]))+1) n@1118: plt.yticks(yint) n@1118: plt.savefig(folder_name+"subjects_per_audioholder.pdf", bbox_inches='tight') n@1118: plt.close() n@1118: n@1118: # SHOW both figures n@1118: body += r''' n@1118: \begin{figure}[htbp] n@1118: \begin{center} n@1118: \includegraphics[width=.65\textwidth]{'''+\ n@1118: folder_name+'time_per_page.pdf'+\ n@1118: r'''} n@1118: \caption{Average time spent per page.} n@1118: \label{fig:avgtimeperpage} n@1118: \end{center} n@1118: \end{figure} n@1118: n@1118: ''' n@1118: body += r'''\begin{figure}[htbp] n@1118: \begin{center} n@1118: \includegraphics[width=.65\textwidth]{'''+\ n@1118: folder_name+'time_per_audioholder.pdf'+\ n@1118: r'''} n@1118: \caption{Average time spent per audioholder.} n@1118: \label{fig:avgtimeperaudioholder} n@1118: \end{center} n@1118: \end{figure} n@1118: n@1118: ''' n@1118: body += r'''\begin{figure}[htbp] n@1118: \begin{center} n@1118: \includegraphics[width=.65\textwidth]{'''+\ n@1118: folder_name+'subjects_per_audioholder.pdf'+\ n@1118: r'''} n@1118: \caption{Number of subjects per audioholder.} n@1118: \label{fig:subjectsperaudioholder} n@1118: \end{center} n@1118: \end{figure} n@1118: n@1118: ''' n@1118: #TODO add error bars n@1118: #TODO layout of figures n@1118: n@1118: # SHOW boxplot per audioholder n@1118: #TODO order in decreasing order of participants n@1118: for audioholder_name in page_names: # get each name n@1118: # plot boxplot if exists (not so for the 'alt' names) n@1118: if os.path.isfile(folder_name+'ratings/'+audioholder_name+'-ratings-box.pdf'): n@1118: body += r'''\begin{figure}[htbp] n@1118: \begin{center} n@1118: \includegraphics[width=.65\textwidth]{'''+\ n@1118: folder_name+"ratings/"+audioholder_name+'-ratings-box.pdf'+\ n@1118: r'''} n@1118: \caption{Box plot of ratings for audioholder '''+\ n@1118: audioholder_name+' ('+str(subject_count[real_page_names.index(audioholder_name)])+\ n@1118: ''' participants).} n@1118: \label{fig:boxplot'''+audioholder_name.replace(" ", "")+'''} n@1118: \end{center} n@1118: \end{figure} n@1118: n@1118: ''' n@1118: n@1118: # DEMO pie chart of gender distribution among subjects n@1118: genders = ['male', 'female', 'other', 'preferNotToSay', 'UNAVAILABLE'] n@1118: # TODO: get the above automatically n@1118: gender_distribution = '' n@1118: for item in genders: n@1118: number = gender.count(item) n@1118: if number>0: n@1118: gender_distribution += str("{:.2f}".format((100.0*number)/len(gender)))+\ n@1118: '/'+item.capitalize()+' ('+str(number)+'),\n' n@1118: n@1118: body += r''' n@1118: % Pie chart of gender distribution n@1118: \def\angle{0} n@1118: \def\radius{3} n@1118: \def\cyclelist{{"orange","blue","red","green"}} n@1118: \newcount\cyclecount \cyclecount=-1 n@1118: \newcount\ind \ind=-1 n@1118: \begin{figure}[htbp] n@1118: \begin{center}\begin{tikzpicture}[nodes = {font=\sffamily}] n@1118: \foreach \percent/\name in {'''+\ n@1118: gender_distribution+\ n@1118: r'''} {\ifx\percent\empty\else % If \percent is empty, do nothing n@1118: \global\advance\cyclecount by 1 % Advance cyclecount n@1118: \global\advance\ind by 1 % Advance list index n@1118: \ifnum6<\cyclecount % If cyclecount is larger than list n@1118: \global\cyclecount=0 % reset cyclecount and n@1118: \global\ind=0 % reset list index n@1118: \fi n@1118: \pgfmathparse{\cyclelist[\the\ind]} % Get color from cycle list n@1118: \edef\color{\pgfmathresult} % and store as \color n@1118: % Draw angle and set labels n@1118: \draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius) n@1118: arc (\angle:\angle+\percent*3.6:\radius) -- cycle; n@1118: \node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\,\%}; n@1118: \node[pin=\angle+0.5*\percent*3.6:\name] n@1118: at (\angle+0.5*\percent*3.6:\radius) {}; n@1118: \pgfmathparse{\angle+\percent*3.6} % Advance angle n@1118: \xdef\angle{\pgfmathresult} % and store in \angle n@1118: \fi n@1118: }; n@1118: \end{tikzpicture} n@1118: \caption{Representation of gender across subjects} n@1118: \label{default} n@1118: \end{center} n@1118: \end{figure} n@1118: n@1118: ''' n@1118: # problem: some people entered twice? n@1118: n@1118: #TODO n@1118: # time per page in function of number of fragments (plot) n@1118: # time per participant in function of number of pages n@1118: # plot total time for each participant n@1118: # show 'count' per page (in order) n@1118: n@1118: # clear up page_index <> page_count <> page_number confusion n@1118: n@1118: n@1118: texfile = header+body+footer # add bits together n@1118: n@1118: print 'pdflatex -output-directory="'+folder_name+'"" "'+ folder_name + 'Report.tex"' # DEBUG n@1118: n@1118: # write TeX file n@1118: with open(folder_name + 'Report.tex','w') as f: n@1118: f.write(texfile) n@1118: proc=subprocess.Popen(shlex.split('pdflatex -output-directory="'+folder_name+'" "'+ folder_name + 'Report.tex"')) n@1118: proc.communicate() n@1118: # run again n@1118: proc=subprocess.Popen(shlex.split('pdflatex -output-directory="'+folder_name+'" "'+ folder_name + 'Report.tex"')) n@1118: proc.communicate() n@1118: n@1118: #TODO remove auxiliary LaTeX files n@1118: try: n@1118: os.remove(folder_name + 'Report.aux') n@1118: os.remove(folder_name + 'Report.log') n@1118: os.remove(folder_name + 'Report.out') n@1118: os.remove(folder_name + 'Report.toc') n@1118: except OSError: n@1118: pass n@1118: