def get_sobject_by_filename(my, filename): '''extract the code from the filename''' # EP01A_15_sometext.aiff # we can restrict the extension to aiff|mp3 if required in the future p = re.compile("(\w+)_(\d+)_(\w+).(\w+)") m = p.match(filename) if not m: return None groups = m.groups() episode_code = "%s" % groups[0] line = groups[1] # verify the code from pyasm.prod.biz import Episode episode = Episode.get_by_code(episode_code) if not episode or not line: return None from pyasm.flash.biz import FinalWave wav = FinalWave.get(episode_code, line) if not wav: wav = FinalWave.create(episode_code, line) return wav
def get_sobject_by_filename(my, filename): '''extract the code from the filename''' # EP01A_sometext.aiff # we can restrict the extension to aiff|mp3 if required in the future p = re.compile("(\w+)_(\w+).(\w+)") m = p.match(filename) if not m: return None groups = m.groups() episode_code = "%s" % groups[0] # verify the code from pyasm.prod.biz import Episode episode = Episode.get_by_code(episode_code) if not episode: return None from pyasm.flash.biz import NatPause nat = NatPause.get_by_episode_code(episode_code) if not nat: nat = NatPause.create(episode_code) return nat
class Usage(Exception): def __init__(self, msg): self.msg = msg if __name__ == '__main__': my_login = '******' batch = Batch(login_code=my_login) Project.set_project('flash') project_code = Project.get_project_code() args = sys.argv[1:] try: if len(args) != 1: raise Usage("A single episode code is expected.") seq = Episode.get_by_code(args[0]) if not seq: raise Usage("The episode code [%s] has not been registered for "\ "project [%s] in TACTIC. Please Insert it in the Episodes tab first." %(args[0], project_code)) except Usage, e: print e.msg sys.exit(2) command = AddFlashShotCmd(seq.get_code()) Command.execute_cmd(command)
def init(self): thumb_cache = {} div = DivWdg() # get all of the shots filter_div = DivWdg(css='filter_box') unit = 'an Episode' filter = shot_container = None search_columns = [] # pick the navigator depending on what project type if Project.get().get_type() == 'flash': # these navigators will have their empty option removed # and should have a different name so that if the user # comees from a tab with the same navigator, it won't # use the previous empty value if chosen filter = EpisodeFilterWdg('unique_episode_code') # set a default value which is used if there is nothing # stored in wdg_settings filter.set_option('default', SelectWdg.NONE_MODE) episode_code = filter.get_value() episode = Episode.get_by_code(episode_code) shot_container = episode search_columns = ['code', 'description', 'episode_code'] elif Project.get().get_type() == 'prod': filter = SequenceFilterWdg('unique_sequence_code') filter.set_option('default', SelectWdg.NONE_MODE) epi_code, seq_code = filter.get_value() seq = Sequence.get_by_code(seq_code) shot_container = seq unit = 'a Sequence' search_columns = ['code', 'description', 'sequence_code'] # name the empty option properly at least filter.get_navigator().get_select().add_empty_option(\ '-- Select %s --' % unit) #filter.remove_empty_option() #filter.add_none_option() filter_div.add(filter) search_filter = SearchFilterWdg(columns=search_columns) search_filter_value = search_filter.get_value() filter_div.add(search_filter) div.add(filter_div) self.add(div) if not shot_container and not search_filter_value: return search = Search(Shot.SEARCH_TYPE) if shot_container: key = shot_container.get_foreign_key() code = shot_container.get_code() search.add_filter(key, code) if search_filter_value: search_filter.alter_search(search) shots = search.get_sobjects() table = TableWdg(Shot.SEARCH_TYPE, 'layout_summary') table.set_sobjects(shots) self.add(table)
def init(my): thumb_cache = {} div = DivWdg() # get all of the shots filter_div = DivWdg(css='filter_box') unit = 'an Episode' filter = shot_container = None search_columns = [] # pick the navigator depending on what project type if Project.get().get_type() == 'flash': # these navigators will have their empty option removed # and should have a different name so that if the user # comees from a tab with the same navigator, it won't # use the previous empty value if chosen filter = EpisodeFilterWdg('unique_episode_code') # set a default value which is used if there is nothing # stored in wdg_settings filter.set_option('default', SelectWdg.NONE_MODE) episode_code = filter.get_value() episode = Episode.get_by_code(episode_code) shot_container = episode search_columns = ['code', 'description', 'episode_code'] elif Project.get().get_type() == 'prod': filter = SequenceFilterWdg('unique_sequence_code') filter.set_option('default', SelectWdg.NONE_MODE) epi_code, seq_code = filter.get_value() seq = Sequence.get_by_code(seq_code) shot_container = seq unit = 'a Sequence' search_columns = ['code', 'description', 'sequence_code'] # name the empty option properly at least filter.get_navigator().get_select().add_empty_option(\ '-- Select %s --' % unit) #filter.remove_empty_option() #filter.add_none_option() filter_div.add(filter) search_filter = SearchFilterWdg(columns=search_columns) search_filter_value = search_filter.get_value() filter_div.add(search_filter) div.add(filter_div) my.add(div) if not shot_container and not search_filter_value: return search = Search(Shot.SEARCH_TYPE) if shot_container: key = shot_container.get_foreign_key() code = shot_container.get_code() search.add_filter(key,code) if search_filter_value: search_filter.alter_search(search) shots = search.get_sobjects() table = TableWdg(Shot.SEARCH_TYPE, 'layout_summary') table.set_sobjects(shots) my.add(table)