예제 #1
0
    def start(self, messageElement):

        Stream.clear_streams()

        process = QProcess()

        self.process = process
        self.messageElement = messageElement

        process.setProcessChannelMode(QProcess.MergedChannels)
        process.start("livestreamer", self.arguments)
        process.readyReadStandardOutput.connect(self.show_messages)

        Stream.ALL_STREAMS.append(self)
예제 #2
0
    def start(self, messageElement):

        Stream.clear_streams()

        process = QProcess()

        self.process = process
        self.messageElement = messageElement

        process.setProcessChannelMode(QProcess.MergedChannels)
        process.start('livestreamer', self.arguments)
        process.readyReadStandardOutput.connect(self.show_messages)

        Stream.ALL_STREAMS.append(self)
예제 #3
0
class TasksPool(QObject):
    """
    This class allows you to add_task() for execution queue. Launch_list() starts the queue.
    """
    task_done = Signal()
    return_signal = Signal(str)

    def __init__(self):

        super(TasksPool, self).__init__()
        self.tasks_pool = []
        self.process = None
        if not QApplication.instance():
            self.qapp = QApplication([])

    def add_task(self, command):
        """
        :type command: str
        :param command: A console command with arguments
        Adds a task to the pool for later execution
        """
        self.tasks_pool.append(command)

    def __execute_task(self, task):
        """
        :param task: Is a string used to start a process
        """
        self.process = QProcess(self)
        self.process.finished.connect(
            lambda *x: logger.debug(task + ' reports complete'))
        self.process.finished.connect(lambda *x: self.return_signal.emit(
            '►' + task + '◄reports complete'))
        self.process.finished.connect(self.task_done)
        # self.process.readyRead.connect(lambda *x: print(str(self.process.readAll())))
        self.process.readyRead.connect(
            lambda *x: self.return_signal.emit(str(self.process.readAll())))
        self.process.setProcessChannelMode(QProcess.MergedChannels)
        self.process.start(task)

    def launch_list(self):
        """
        Starts the execution of the queue in consecutive order, waiting for previous process to finish
        """
        for task in self.tasks_pool:
            loop = QEventLoop()
            self.task_done.connect(loop.quit)
            self.__execute_task(task)
            loop.exec_()
예제 #4
0
	def is_online( self, tableWidgetItem ):

		Stream.clear_streams()
		process = QProcess()
		self.process = process
		self.table_widget_item = tableWidgetItem

		arguments = [ '--json' ] + self.arguments

		process.setProcessChannelMode( QProcess.MergedChannels )
		process.start( 'livestreamer', arguments )
		process.readyReadStandardOutput.connect( self.is_online_callback )

		itemWidget = self.table_widget_item
		tableWidget = itemWidget.tableWidget()
		tableWidget.setCellWidget( itemWidget.row(), 0, MovieWidget( fullpath( 'icons/loading_16.gif' ), tableWidget) )

		Stream.ALL_STREAMS.append( self )
예제 #5
0
    def is_online(self, tableWidgetItem):

        Stream.clear_streams()

        process = QProcess()

        self.process = process
        self.table_widget_item = tableWidgetItem

        arguments = ['--json'] + self.arguments

        process.setProcessChannelMode(QProcess.MergedChannels)
        process.start('livestreamer', arguments)
        process.readyReadStandardOutput.connect(self.is_online_callback)

        tableWidgetItem.setText('Checking..')

        Stream.ALL_STREAMS.append(self)
예제 #6
0
	def start( self, messageElement, tableWidgetItem ):

		Stream.clear_streams()

		process = QProcess()
		self.process = process
		self.messageElement = messageElement

		row = tableWidgetItem.row()
		tableWidget = tableWidgetItem.tableWidget()
		tableWidget.setCellWidget( tableWidgetItem.row(), 0, ImageWidget( fullpath( 'icons/play_16.png' ), tableWidget) )
		tableWidgetItem = tableWidget.item( row, 0 )

		process.setProcessChannelMode( QProcess.MergedChannels )
		process.start( 'livestreamer', self.arguments )
		process.readyReadStandardOutput.connect( self.show_messages )
		process.finished.connect( lambda: self.is_online( tableWidgetItem ) )

		Stream.ALL_STREAMS.append( self )
예제 #7
0
class TasksPool(QObject):
    startNextTaskSignal = Signal()
    allTasksCompleteSignal = Signal()

    def __init__(self):
        super(TasksPool, self).__init__()
        self.tasks_pool = []
        self.process = QProcess()

        self.startNextTaskSignal.connect(self.execute_task)
        self.allTasksCompleteSignal.connect(self.tasks_complete)

        self.source = ''

    def add_task(self, command):
        self.tasks_pool.append(command)
        self.startNextTaskSignal.emit()

    def execute_task(self):
        print('Start next?')
        if self.process.isOpen():
            self.process.waitForFinished()
        if not self.tasks_pool:
            self.allTasksCompleteSignal.emit()
            return
        self.process = QProcess()
        self.process.finished.connect(
            lambda *x: QTimer.singleShot(1000, self.startNextTaskSignal.emit))
        self.process.setProcessChannelMode(QProcess.MergedChannels)
        self.process.readyRead.connect(self.process_output)
        next_task = self.tasks_pool.pop(0)
        print('NEXT TASK', next_task)
        self.process.start(next_task)

    def process_output(self):
        output = self.process.readAll()
        output = str(output).strip()
        if output:
            print(output)

    def tasks_complete(self):
        print('ALL TASKS COMPLETE')
예제 #8
0
    def is_online(self, tableWidgetItem):

        Stream.clear_streams()

        process = QProcess()

        self.process = process
        self.table_widget_item = tableWidgetItem

        arguments = ["--json"] + self.arguments

        process.setProcessChannelMode(QProcess.MergedChannels)
        process.start("livestreamer", arguments)
        process.readyReadStandardOutput.connect(self.is_online_callback)

        brush = QBrush(Qt.SolidPattern)
        color = QColor(255, 255, 255)  # white
        brush.setColor(color)
        tableWidgetItem.setBackground(brush)
        tableWidgetItem.setText("Checking..")

        Stream.ALL_STREAMS.append(self)
예제 #9
0
    def is_online(self, tableWidgetItem):

        Stream.clear_streams()

        process = QProcess()

        self.process = process
        self.table_widget_item = tableWidgetItem

        arguments = ['--json'] + self.arguments

        process.setProcessChannelMode(QProcess.MergedChannels)
        process.start('livestreamer', arguments)
        process.readyReadStandardOutput.connect(self.is_online_callback)

        brush = QBrush(Qt.SolidPattern)
        color = QColor(255, 255, 255)  #white
        brush.setColor(color)
        tableWidgetItem.setBackground(brush)
        tableWidgetItem.setText('Checking..')

        Stream.ALL_STREAMS.append(self)