示例#1
0
	def __init__(self):
		self.measures = 0
		self.writtenMeasures = 0
		QMainWindow.__init__(self)
		self.ice = ReplayCompIce()
		self.icerunning = False
		self.ice.start()
		while self.icerunning == False:
			try:
				while self.ice.running == False: time.sleep(0.05)
				self.icerunning = True
			except:
				time.sleep(0.05)
		self.ui = Ui_ReplayFrameskipMainWindow()
		self.ui.setupUi(self)
		self.ui.inputFile.setText(global_ic.getProperties().getProperty('Replay.File'))
		self.connect(self.ui.fileButton, SIGNAL('clicked()'), self.startConversion)
		for i in range(3):
			self.ui.tabWidget.setTabEnabled(i, False)
		self.ui.tabWidget.setTabEnabled(0, True)
		self.ui.tabWidget.setCurrentIndex(0)
示例#2
0
class ReplayFrameskipUI(QMainWindow):
    #
    # Constructor
    def __init__(self):
        self.measures = 0
        self.writtenMeasures = 0
        QMainWindow.__init__(self)
        self.ice = ReplayCompIce()
        self.icerunning = False
        self.ice.start()
        while self.icerunning == False:
            try:
                while self.ice.running == False:
                    time.sleep(0.05)
                self.icerunning = True
            except:
                time.sleep(0.05)
        self.ui = Ui_ReplayFrameskipMainWindow()
        self.ui.setupUi(self)
        self.ui.inputFile.setText(
            global_ic.getProperties().getProperty('Replay.File'))
        self.connect(self.ui.fileButton, SIGNAL('clicked()'),
                     self.startConversion)
        for i in range(3):
            self.ui.tabWidget.setTabEnabled(i, False)
        self.ui.tabWidget.setTabEnabled(0, True)
        self.ui.tabWidget.setCurrentIndex(0)

    def startConversion(self):
        self.entrada = None
        self.salida = None
        try:
            self.entrada = open(str(self.ui.inputFile.text()), 'r')
            self.salida = open(str(self.ui.outputFile.text()), 'w')
            self.mps = self.ui.mps.value()
            for i in range(3):
                self.ui.tabWidget.setTabEnabled(i, False)
            self.ui.tabWidget.setTabEnabled(1, True)
            self.ui.tabWidget.setCurrentIndex(1)
            self.disconnect(self.ui.fileButton, SIGNAL('clicked()'),
                            self.startConversion)
            self.ui.tabWidget.setCurrentIndex(1)
            self.header_pointer = int(self.entrada.read(15))
            self.entrada.seek(self.header_pointer, os.SEEK_SET)
            self.header = pickle.load(self.entrada)
            self.entrada.seek(15, os.SEEK_SET)
            self.salida.write('0' * 15)
            self.endReached = False
            self.timer = QTimer()
            self.timer.start(1)
            self.index = list()
            self.connect(self.timer, SIGNAL('timeout()'), self.timeout)
        except:
            traceback.print_exc()
            if self.entrada != None: self.entrada.close()
            if self.salida != None: self.salida.close()
#
# Timeout

    def timeout(self):
        if not self.endReached:
            if self.header_pointer > self.entrada.tell():
                try:
                    self.ret = pickle.load(self.entrada)
                    self.measures += 1
                    if self.writtenMeasures <= self.ret.time * self.mps / 1000 or self.writtenMeasures == 0:
                        salidaTell = self.salida.tell()
                        pickle.dump(self.ret, self.salida, 2)
                        self.index.append(salidaTell)
                        self.writtenMeasures += 1
                    self.ui.progressBar.setValue(
                        (self.measures * 99.9) / len(self.header.index))
                except EOFError:
                    print "Nos hemos pasado leyendo"
                    self.endReached = True
                except:
                    print "Algun otro error"
                    self.endReached = True
            else:
                self.endReached = True
        else:
            self.header.index = self.index
            self.header_pointer = self.salida.tell()
            pickle.dump(self.header, self.salida, 2)
            self.salida.seek(0, os.SEEK_SET)
            self.salida.write(str(self.header_pointer).zfill(15))
            self.timer.stop()
            self.salida.close()
            print 'done'
            for i in range(3):
                self.ui.tabWidget.setTabEnabled(i, False)
            self.ui.tabWidget.setTabEnabled(2, True)
            self.ui.tabWidget.setCurrentIndex(2)

#
# Close event

    def closeEvent(self, e):
        pass