#NEWLINE# @ classmethod #NEWLINE# def upload_output( cls , version , output_file_full_path ) : #NEWLINE# #INDENT# 'sets the given file as the output of the given version, also\n        generates a thumbnail and a web version if it is a movie file\n\n        :param version: The stalker version instance\n        :param output_file_full_path: the path of the media file\n        ' #NEWLINE# from stalker import Version #NEWLINE# if ( not isinstance ( version , Version ) ) : #NEWLINE# #INDENT# raise RuntimeError ( 'version should be a stalker version instance!' ) #NEWLINE# #UNINDENT# hires_extension = '.mov' #NEWLINE# webres_extension = '.webm' #NEWLINE# thumbnail_extension = '.png' #NEWLINE# output_file_name = os . path . basename ( output_file_full_path ) #NEWLINE# hires_output_file_name = ( '%s%s' % ( os . path . splitext ( output_file_name ) [ 0 ] , hires_extension ) ) #NEWLINE# webres_output_file_name = ( '%s%s' % ( os . path . splitext ( output_file_name ) [ 0 ] , webres_extension ) ) #NEWLINE# thumbnail_output_file_name = ( '%s%s' % ( os . path . splitext ( output_file_name ) [ 0 ] , thumbnail_extension ) ) #NEWLINE# task = version . task #NEWLINE# hires_path = os . path . join ( task . absolute_path , 'Outputs' , 'Stalker_Pyramid' , hires_output_file_name ) #NEWLINE# webres_path = os . path . join ( task . absolute_path , 'Outputs' , 'Stalker_Pyramid' , 'ForWeb' , webres_output_file_name ) #NEWLINE# thumbnail_path = os . path . join ( task . absolute_path , 'Outputs' , 'Stalker_Pyramid' , 'Thumbnail' , thumbnail_output_file_name ) #NEWLINE# try : #NEWLINE# #INDENT# os . makedirs ( os . path . dirname ( hires_path ) ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# os . makedirs ( os . path . dirname ( webres_path ) ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# os . makedirs ( os . path . dirname ( output ) ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# shutil . copy ( output_file_full_path , hires_path ) #NEWLINE# from anima.utils import MediaManager #NEWLINE# m = MediaManager ( ) #NEWLINE# temp_web_version_full_path = m . generate_media_for_web ( output_file_full_path ) #NEWLINE# try : #NEWLINE# #INDENT# shutil . copy ( temp_web_version_full_path , webres_path ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# temp_thumbnail_full_path = m . generate_thumbnail ( output_file_full_path ) #NEWLINE# try : #NEWLINE# #INDENT# shutil . copy ( temp_thumbnail_full_path , thumbnail_path ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# project = task . project #NEWLINE# repo = project . repository #NEWLINE# from stalker import db , Link #NEWLINE# found = None #NEWLINE# hires_os_independent_path = repo . to_os_independent_path ( hires_path ) #NEWLINE# for output in version . outputs : #NEWLINE# #INDENT# if ( output . full_path == hires_os_independent_path ) : #NEWLINE# #INDENT# found = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not found ) : #NEWLINE# #INDENT# l_hires = Link ( full_path = repo . to_os_independent_path ( hires_path ) , original_filename = hires_output_file_name ) #NEWLINE# l_for_web = Link ( full_path = repo . to_os_independent_path ( webres_path ) , original_filename = hires_output_file_name ) #NEWLINE# l_hires . thumbnail = l_for_web #NEWLINE# version . outputs . append ( l_hires ) #NEWLINE# l_thumb = Link ( full_path = repo . to_os_independent_path ( thumbnail_path ) , original_filename = hires_output_file_name ) #NEWLINE# l_for_web . thumbnail = l_thumb #NEWLINE# db . DBSession . add_all ( [ l_hires , l_for_web , l_thumb ] ) #NEWLINE# db . DBSession . commit ( ) #NEWLINE# #UNINDENT# return hires_path