|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
"""
|
|
|
Module implementing MainWindow.
|
|
|
"""
|
|
|
|
|
|
from PyQt4.QtGui import QMainWindow
|
|
|
from PyQt4.QtCore import pyqtSignature
|
|
|
from PyQt4 import QtCore
|
|
|
from Ui_MainWindow import Ui_MainWindow
|
|
|
from PyQt4 import QtGui
|
|
|
from subprocess import *
|
|
|
import sys
|
|
|
import os
|
|
|
import subprocess
|
|
|
import commands
|
|
|
from functions import functions
|
|
|
from functions import functions2
|
|
|
|
|
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
"""
|
|
|
Class documentation goes here.
|
|
|
"""
|
|
|
|
|
|
def __init__(self, parent = None):
|
|
|
QMainWindow.__init__(self, parent)
|
|
|
self.setupUi(self)
|
|
|
self.setupUi2()
|
|
|
#sys.stdout = self #redirige salida estandar
|
|
|
|
|
|
def setupUi2(self):
|
|
|
|
|
|
functions2.detect_devices(self) #busca los dispositivos de grabacion
|
|
|
|
|
|
#Revisa si existe el archivo de confirguracion
|
|
|
if os.path.isfile("parameters.conf"):
|
|
|
self.txtInfo.append("Archivo de configuracion encontrado")
|
|
|
functions2.get_parameters_conf(self)
|
|
|
else:
|
|
|
self.txtInfo.append("Elija los parametros de configuracion")
|
|
|
functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
|
|
|
|
|
|
functions2.set_vars(self) #Carga las variables de la clase con los parametros seleccionados
|
|
|
|
|
|
self.statusDpath = functions.dir_exists(self.var_Dpath, self)
|
|
|
self.statusRpath = functions.dir_exists(self.var_Rpath, self)
|
|
|
|
|
|
self.var_n_discs=0
|
|
|
self.var_list=[]
|
|
|
self.var_sublist=[]
|
|
|
|
|
|
functions.load_days(self)
|
|
|
|
|
|
self.var_process = QtCore.QProcess()
|
|
|
self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput)
|
|
|
self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardError()'), self.readError)
|
|
|
self.connect(self.var_process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished)
|
|
|
|
|
|
def readOuput(self):
|
|
|
self.txtSburn.insertPlainText("stdout: " + QtCore.QString(self.var_process.readAllStandardOutput()))
|
|
|
|
|
|
|
|
|
def readError(self):
|
|
|
self.txtSburn.insertPlainText("stderr: " + QtCore.QString(self.var_process.readAllStandardError()))
|
|
|
|
|
|
|
|
|
def finished(self):
|
|
|
self.txtInfo.append("proceso terminado finished()")
|
|
|
print self.var_process.exitCode()
|
|
|
|
|
|
|
|
|
def write(self, txt):
|
|
|
self.txtInfo.append(str(txt))
|
|
|
|
|
|
#----------------------------------------------------- Obtencion de las ruta de los datos ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnDpath_clicked(self):
|
|
|
"""
|
|
|
Permite seleccionar graficamente el direcorio de los datos a grabar
|
|
|
"""
|
|
|
self.var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
|
|
|
self.txtDpath.setText(self.var_Dpath)
|
|
|
self.statusDpath = functions.dir_exists(self.var_Dpath, self)
|
|
|
functions.load_days(self)
|
|
|
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_txtDpath_editingFinished(self):
|
|
|
"""
|
|
|
Carga la ruta editada y verifica que sea correcta y carga la lista de dias
|
|
|
"""
|
|
|
self.var_Dpath=self.txtDpath.text() #Se carga la variable con la ruta recien editada
|
|
|
self.statusDpath = functions.dir_exists(self.var_Dpath, self)
|
|
|
functions.load_days(self)
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Obtencion de las ruta del proyecto ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnRpath_clicked(self):
|
|
|
"""
|
|
|
Permite seleccionar graficamente el direcorio del proyecto
|
|
|
"""
|
|
|
self.var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
|
|
|
self.txtRpath.setText(self.var_Rpath)
|
|
|
self.statusRpath = functions.dir_exists(self.var_Rpath, self)
|
|
|
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_txtRpath_editingFinished(self):
|
|
|
"""
|
|
|
Valida la ruta del proyecto
|
|
|
"""
|
|
|
self.var_Rpath=self.txtRpath.text() #Se carga la variable con la ruta recien editada
|
|
|
self.statusRpath = functions.dir_exists(self.var_Rpath, self)
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Tipo de datos ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("int")
|
|
|
def on_lstDtype_activated(self, index):
|
|
|
"""
|
|
|
Permite elegir entre los tipos de archivos
|
|
|
"""
|
|
|
self.txtDtype.setReadOnly(True)
|
|
|
if index == 0:
|
|
|
self.var_Dtype ='r'
|
|
|
elif index == 1:
|
|
|
self.var_Dtype ='pdata'
|
|
|
elif index == 2:
|
|
|
self.var_Dtype ='sswma'
|
|
|
else :
|
|
|
self.var_Dtype =''
|
|
|
self.txtDtype.setReadOnly(False)
|
|
|
|
|
|
self.txtDtype.setText(self.var_Dtype)
|
|
|
functions.load_days(self) #llamada a funcion
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_txtDtype_editingFinished(self):
|
|
|
self.var_Dtype=self.txtDtype.text()
|
|
|
functions.load_days(self) #llamada a funcion
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Etiqueta ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_txtElabel_editingFinished(self):
|
|
|
self.var_Elabel = self.txtElabel.text()
|
|
|
|
|
|
#----------------------------------------------------- Numero de copias ---------------------------------------------------------------
|
|
|
@pyqtSignature("")
|
|
|
def on_txtCopys_editingFinished(self):
|
|
|
self.var_Copys = self.txtCopys.value()
|
|
|
|
|
|
#----------------------------------------------------- Seleccion del rango de fechas ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("int") #CLOSED
|
|
|
def on_lstStartDay_activated(self, index):
|
|
|
"""
|
|
|
Cambia la lista de opciones en lstStopDay
|
|
|
"""
|
|
|
var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
|
|
|
self.lstStopDay.clear()
|
|
|
|
|
|
for i in self.var_list[index:]:
|
|
|
self.lstStopDay.addItem(i)
|
|
|
|
|
|
self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
|
|
|
|
|
|
functions.get_sub_list(self)
|
|
|
|
|
|
|
|
|
@pyqtSignature("int") #CLOSED
|
|
|
def on_lstStopDay_activated(self, index):
|
|
|
"""
|
|
|
Cambia la lista de opciones en lstStartDay
|
|
|
"""
|
|
|
var_StartDay_index=self.lstStartDay.currentIndex()
|
|
|
var_end_index = self.lstStopDay.count() - index
|
|
|
self.lstStartDay.clear()
|
|
|
|
|
|
for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
|
|
|
self.lstStartDay.addItem(i)
|
|
|
|
|
|
self.lstStartDay.setCurrentIndex(var_StartDay_index)
|
|
|
|
|
|
functions.get_sub_list(self)
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Capacidad del dispositivo de grabacion ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_txtDcapacity_editingFinished(self):
|
|
|
self.var_Dcapacity = self.txtDcapacity.value()
|
|
|
|
|
|
|
|
|
@pyqtSignature("int") #CLOSED
|
|
|
def on_lstDcapacity_activated(self, index):
|
|
|
"""
|
|
|
Permite elegir el tamaƱo del disco
|
|
|
"""
|
|
|
if index == 0:
|
|
|
var_size=25.0
|
|
|
elif index == 1:
|
|
|
var_size=8.5
|
|
|
elif index == 2:
|
|
|
var_size=4.7
|
|
|
elif index == 3:
|
|
|
var_size=0.7
|
|
|
|
|
|
if index != 4:
|
|
|
self.txtDcapacity.setValue(var_size*10**9/1024**2)
|
|
|
self.txtDcapacity.setReadOnly(True)
|
|
|
else:
|
|
|
self.txtDcapacity.setValue(100.0)
|
|
|
self.txtDcapacity.setReadOnly(False)
|
|
|
|
|
|
self.var_Dcapacity = self.txtDcapacity.value()
|
|
|
|
|
|
|
|
|
#==============================================================================
|
|
|
# Botones para la generacion de los archivos de configuracion y el proceso de grabacion
|
|
|
#==============================================================================
|
|
|
|
|
|
#----------------------------------------------------- Generacion de la configuracion usando los parametros ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnGbkp_clicked(self):
|
|
|
"""
|
|
|
Generacion de archivos de configuracion usando los parametros
|
|
|
"""
|
|
|
|
|
|
if functions.validate_parameters(self) == False:
|
|
|
return
|
|
|
|
|
|
#Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
|
|
|
list_dirs=['gpath','iso','ppath']
|
|
|
bool_make_dirs = functions.make_dirs(list_dirs, self)
|
|
|
if bool_make_dirs == False:
|
|
|
return
|
|
|
|
|
|
var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
|
|
|
self.var_n_discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
|
|
|
functions.make_files_print(self) # Se crean los archivos .print
|
|
|
functions2.make_parameters_conf(self) # se crea el archivo parameters.conf
|
|
|
|
|
|
#Se bloquean los parametros de configuracion
|
|
|
functions2.enabled_items1(True, self)
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Permite reiniciar la configuracion ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnRestart_clicked(self):
|
|
|
"""
|
|
|
Permite que se puedan cambiar los parametros
|
|
|
"""
|
|
|
functions2.enabled_items1(False, self)
|
|
|
os.remove("parameters.conf")
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Iniciar proceso de grabacion ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnStartburn_clicked(self):
|
|
|
"""
|
|
|
Se inicia el proceso de grabacion
|
|
|
"""
|
|
|
self.btnRestart.setEnabled(False)
|
|
|
self.btnStartburn.setEnabled(False)
|
|
|
self.btnStopburn.setEnabled(True)
|
|
|
|
|
|
sys.stdout = self
|
|
|
#sys.stderr = self
|
|
|
print "stdout_!!!"
|
|
|
|
|
|
#Inicializando variables
|
|
|
var_Rpath_ppath=self.var_Rpath+"/ppath"
|
|
|
var_Rpath_iso=self.var_Rpath+"/iso"
|
|
|
|
|
|
var_n=1
|
|
|
file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso"
|
|
|
file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(var_n)+".dat"
|
|
|
|
|
|
var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
|
|
|
var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel
|
|
|
var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
|
|
|
|
|
|
# self.process.start(var_cmd)
|
|
|
self.var_process.start(var_cmd)
|
|
|
# self.var_process.waitForFinished()
|
|
|
self.txtInfo.append("ejecutandose")
|
|
|
|
|
|
|
|
|
# # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
|
|
|
# for var_n in range(1, self.var_n_discs+1):
|
|
|
# self.txtInfo.append(str(var_n))
|
|
|
# file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso"
|
|
|
# file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(var_n)+".dat"
|
|
|
#
|
|
|
# var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
|
|
|
# var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel
|
|
|
# var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
|
|
|
# self.txtInfo.append(var_cmd)
|
|
|
#
|
|
|
# var_output=commands.getstatusoutput(str(var_cmd))[0]
|
|
|
# self.txtInfo.append(str(var_output))
|
|
|
|
|
|
#os.system(str(var_cmd))
|
|
|
#p = subprocess.Popen(str('ls /'), shell=True, stdout=self)
|
|
|
#os.waitpid(p.pid, 0)
|
|
|
####self.txtInfo.append(str(p.pid))
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Detener proceso de grabacion ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnStopburn_clicked(self):
|
|
|
"""
|
|
|
Slot documentation goes here.
|
|
|
"""
|
|
|
self.btnRestart.setEnabled(True)
|
|
|
self.btnStartburn.setEnabled(True)
|
|
|
self.btnStopburn.setEnabled(False)
|
|
|
|
|
|
|
|
|
#----------------------------------------------------- Testeo de las unidades de grabacion ---------------------------------------------------------------
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnTdevA_clicked(self):
|
|
|
var_dev = str(self.txtDeviceA.text())
|
|
|
var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
|
|
|
commands.getstatusoutput(var_cmd)
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnTdevB_clicked(self):
|
|
|
var_dev = str(self.txtDeviceB.text())
|
|
|
var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
|
|
|
commands.getstatusoutput(var_cmd)
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnTdevC_clicked(self):
|
|
|
var_dev = str(self.txtDeviceC.text())
|
|
|
var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
|
|
|
commands.getstatusoutput(var_cmd)
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
def on_btnTdevD_clicked(self):
|
|
|
var_dev = str(self.txtDeviceD.text())
|
|
|
var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
|
|
|
commands.getstatusoutput(var_cmd)
|
|
|
|