Now the launch subsystem allows to call an specific function before starting a process and after it ends (this is useful to remove the single process for just renaming the movie file when adding subtitles)
Fixed a bug when the process reads from a file for stdin and/or writes to a file for stdout, and it fails Fixed a bug in the creation of subtitles: now assigns a diferent stream id to each subtitle
This commit is contained in:
parent
cf1220d6c3
commit
8773cebfda
4 changed files with 45 additions and 66 deletions
|
|
@ -52,7 +52,6 @@ class executor(GObject.GObject):
|
||||||
self.handle = None
|
self.handle = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_dependency(self, dep):
|
def add_dependency(self, dep):
|
||||||
|
|
||||||
self.add_dependency2(dep)
|
self.add_dependency2(dep)
|
||||||
|
|
@ -73,6 +72,7 @@ class executor(GObject.GObject):
|
||||||
for child in self.childs:
|
for child in self.childs:
|
||||||
child.add_dependency(dep)
|
child.add_dependency(dep)
|
||||||
|
|
||||||
|
|
||||||
def remove_dependency(self,process):
|
def remove_dependency(self,process):
|
||||||
# dependencies are removed only in the parent because the running class have all the processes, parents and childs, and calls
|
# dependencies are removed only in the parent because the running class have all the processes, parents and childs, and calls
|
||||||
# this method on all of them
|
# this method on all of them
|
||||||
|
|
@ -86,6 +86,7 @@ class executor(GObject.GObject):
|
||||||
else:
|
else:
|
||||||
self.dependencies = None
|
self.dependencies = None
|
||||||
|
|
||||||
|
|
||||||
def add_child_process(self,child):
|
def add_child_process(self,child):
|
||||||
|
|
||||||
# the childs have the same dependencies than the parent process because, from outside, it is viewed as a single process
|
# the childs have the same dependencies than the parent process because, from outside, it is viewed as a single process
|
||||||
|
|
@ -96,16 +97,23 @@ class executor(GObject.GObject):
|
||||||
if (self.childs.count(child) == 0):
|
if (self.childs.count(child) == 0):
|
||||||
self.childs.append(child)
|
self.childs.append(child)
|
||||||
|
|
||||||
|
|
||||||
def run(self, progress_bar):
|
def run(self, progress_bar):
|
||||||
|
|
||||||
self.progress_bar = progress_bar
|
self.progress_bar = progress_bar
|
||||||
self.progress_bar[0].set_label(self.text)
|
self.progress_bar[0].set_label(self.text)
|
||||||
self.progress_bar[1].set_fraction(0.0)
|
self.progress_bar[1].set_fraction(0.0)
|
||||||
self.progress_bar[0].show_all()
|
self.progress_bar[0].show_all()
|
||||||
|
# call, if it exists, the pre-function
|
||||||
|
try:
|
||||||
|
self.pre_function()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.launch_process(self.command_var)
|
self.launch_process(self.command_var)
|
||||||
if self.use_pulse_mode != self.pulse_mode:
|
if self.use_pulse_mode != self.pulse_mode:
|
||||||
self.set_pulse_mode(self.use_pulse_mode)
|
self.set_pulse_mode(self.use_pulse_mode)
|
||||||
|
|
||||||
|
|
||||||
def remove_ansi(self,line):
|
def remove_ansi(self,line):
|
||||||
|
|
||||||
output=""
|
output=""
|
||||||
|
|
@ -221,6 +229,7 @@ class executor(GObject.GObject):
|
||||||
self.file_out.write(line_data)
|
self.file_out.write(line_data)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def read_stdin_from_file(self,source,condition):
|
def read_stdin_from_file(self,source,condition):
|
||||||
|
|
||||||
line_data = self.file_in.read1(4096)
|
line_data = self.file_in.read1(4096)
|
||||||
|
|
@ -265,7 +274,7 @@ class executor(GObject.GObject):
|
||||||
|
|
||||||
if (condition != GLib.IO_IN):
|
if (condition != GLib.IO_IN):
|
||||||
self.channel_stderr = None
|
self.channel_stderr = None
|
||||||
if ((self.channel_stdout == None) and (self.channel_stdin == None)):
|
if (((self.channel_stdout == None) or (self.stdout_file != None)) and ((self.channel_stdin == None) or (self.stdin_file != None))):
|
||||||
self.wait_end()
|
self.wait_end()
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
@ -286,6 +295,7 @@ class executor(GObject.GObject):
|
||||||
self.process_stderr(final_data)
|
self.process_stderr(final_data)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
|
|
||||||
""" Called to kill this process. """
|
""" Called to kill this process. """
|
||||||
|
|
@ -306,6 +316,12 @@ class executor(GObject.GObject):
|
||||||
|
|
||||||
self.set_pulse_mode(False)
|
self.set_pulse_mode(False)
|
||||||
|
|
||||||
|
# call, if it exists, the post-function
|
||||||
|
try:
|
||||||
|
self.post_function(retval,self.killed)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if self.killed:
|
if self.killed:
|
||||||
retval = 0
|
retval = 0
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import devede.converter
|
||||||
import devede.ask_subtitles
|
import devede.ask_subtitles
|
||||||
import devede.preview
|
import devede.preview
|
||||||
import devede.file_copy
|
import devede.file_copy
|
||||||
import devede.rename_file
|
|
||||||
import devede.subtitles_mux
|
import devede.subtitles_mux
|
||||||
|
|
||||||
class file_movie(devede.interface_manager.interface_manager):
|
class file_movie(devede.interface_manager.interface_manager):
|
||||||
|
|
@ -405,7 +404,7 @@ class file_movie(devede.interface_manager.interface_manager):
|
||||||
self.wtreview_subtitles = self.builder.get_object("treeview_subtitles")
|
self.wtreview_subtitles = self.builder.get_object("treeview_subtitles")
|
||||||
self.wdel_subtitles = self.builder.get_object("del_subtitles")
|
self.wdel_subtitles = self.builder.get_object("del_subtitles")
|
||||||
|
|
||||||
selection = self.wsubtitles_list.get_selection()
|
selection = self.wtreview_subtitles.get_selection()
|
||||||
selection.set_mode(Gtk.SelectionMode.BROWSE)
|
selection.set_mode(Gtk.SelectionMode.BROWSE)
|
||||||
|
|
||||||
# elements in page VIDEO OPTIONS
|
# elements in page VIDEO OPTIONS
|
||||||
|
|
@ -578,11 +577,8 @@ class file_movie(devede.interface_manager.interface_manager):
|
||||||
duration2 = self.original_length
|
duration2 = self.original_length
|
||||||
else:
|
else:
|
||||||
duration2 = duration
|
duration2 = duration
|
||||||
|
stream_id = 0
|
||||||
for subt in self.subtitles_list:
|
for subt in self.subtitles_list:
|
||||||
renamer = devede.rename_file.rename_file()
|
|
||||||
renamer.rename(output_path, output_path+".tmp")
|
|
||||||
renamer.add_dependency(last_process)
|
|
||||||
converter.add_child_process(renamer)
|
|
||||||
subt_file = subt[0]
|
subt_file = subt[0]
|
||||||
subt_codepage = subt[1]
|
subt_codepage = subt[1]
|
||||||
subt_lang = subt[2]
|
subt_lang = subt[2]
|
||||||
|
|
@ -592,11 +588,13 @@ class file_movie(devede.interface_manager.interface_manager):
|
||||||
else:
|
else:
|
||||||
final_aspect = "4:3"
|
final_aspect = "4:3"
|
||||||
subt_mux = devede.subtitles_mux.subtitles_mux()
|
subt_mux = devede.subtitles_mux.subtitles_mux()
|
||||||
subt_mux.multiplex_subtitles( output_path+".tmp", output_path, subt_file, subt_codepage, subt_lang, subt_upper,
|
subt_mux.multiplex_subtitles( output_path, subt_file, subt_codepage, subt_lang, subt_upper,
|
||||||
self.subt_font_size,self.format_pal,self.force_subtitles, final_aspect, duration2)
|
self.subt_font_size,self.format_pal,self.force_subtitles,
|
||||||
subt_mux.add_dependency(renamer)
|
final_aspect, duration2, stream_id)
|
||||||
|
subt_mux.add_dependency(last_process)
|
||||||
converter.add_child_process(subt_mux)
|
converter.add_child_process(subt_mux)
|
||||||
last_process = subt_mux
|
last_process = subt_mux
|
||||||
|
stream_id += 1
|
||||||
|
|
||||||
return converter
|
return converter
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
|
|
||||||
#
|
|
||||||
# This file is part of DeVeDe-NG
|
|
||||||
#
|
|
||||||
# DeVeDe-NG is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# DeVeDe-NG is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
|
|
||||||
import os
|
|
||||||
import devede.configuration_data
|
|
||||||
import devede.executor
|
|
||||||
|
|
||||||
class rename_file(devede.executor.executor):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
|
|
||||||
devede.executor.executor.__init__(self)
|
|
||||||
self.config = devede.configuration_data.configuration.get_config()
|
|
||||||
|
|
||||||
def rename(self,file_path_input, file_path_output):
|
|
||||||
|
|
||||||
self.text = _("Renaming %(L)s to %(X)s") % {"X": os.path.basename(file_path_output), "L": os.path.basename(file_path_input)}
|
|
||||||
|
|
||||||
self.command_var=[]
|
|
||||||
self.command_var.append("mv")
|
|
||||||
self.command_var.append("-f")
|
|
||||||
self.command_var.append(file_path_input)
|
|
||||||
self.command_var.append(file_path_output)
|
|
||||||
self.use_pulse_mode = True
|
|
||||||
|
|
||||||
def process_stdout(self,data):
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def process_stderr(self,data):
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import devede.configuration_data
|
import devede.configuration_data
|
||||||
import devede.executor
|
import devede.executor
|
||||||
|
|
||||||
|
|
@ -28,13 +30,14 @@ class subtitles_mux(devede.executor.executor):
|
||||||
devede.executor.executor.__init__(self)
|
devede.executor.executor.__init__(self)
|
||||||
self.config = devede.configuration_data.configuration.get_config()
|
self.config = devede.configuration_data.configuration.get_config()
|
||||||
|
|
||||||
def multiplex_subtitles(self,file_path_input, file_path_output, subtitles_path,subt_codepage, subt_lang,
|
def multiplex_subtitles(self, file_path, subtitles_path,subt_codepage, subt_lang,
|
||||||
subt_upper,font_size, pal, force_subtitles, aspect, duration):
|
subt_upper,font_size, pal, force_subtitles, aspect, duration, stream_id):
|
||||||
|
|
||||||
|
self.subt_path = file_path
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.text = _("Adding %(L)s subtitles to %(X)s") % {"X": os.path.basename(file_path_output), "L": subt_lang}
|
self.text = _("Adding %(L)s subtitles to %(X)s") % {"X": os.path.basename(file_path), "L": subt_lang}
|
||||||
|
|
||||||
out_xml = open(file_path_input+".xml","w")
|
out_xml = open(file_path+".xml","w")
|
||||||
out_xml.write('<subpictures format="')
|
out_xml.write('<subpictures format="')
|
||||||
if pal:
|
if pal:
|
||||||
out_xml.write('PAL')
|
out_xml.write('PAL')
|
||||||
|
|
@ -69,9 +72,19 @@ class subtitles_mux(devede.executor.executor):
|
||||||
mode = "svcd"
|
mode = "svcd"
|
||||||
self.command_var.append("-m")
|
self.command_var.append("-m")
|
||||||
self.command_var.append(mode)
|
self.command_var.append(mode)
|
||||||
self.command_var.append(file_path_input+".xml")
|
self.command_var.append("-s")
|
||||||
self.stdin_file = file_path_input
|
self.command_var.append(str(stream_id))
|
||||||
self.stdout_file = file_path_output
|
self.command_var.append(file_path+".xml")
|
||||||
|
self.stdin_file = file_path+".tmp"
|
||||||
|
self.stdout_file = file_path
|
||||||
|
|
||||||
|
|
||||||
|
def pre_function(self):
|
||||||
|
|
||||||
|
final_path = self.subt_path+".tmp"
|
||||||
|
if os.path.exists(final_path):
|
||||||
|
os.remove(final_path)
|
||||||
|
os.rename(self.subt_path, final_path)
|
||||||
|
|
||||||
|
|
||||||
def process_stderr(self,data):
|
def process_stderr(self,data):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue