Exemplo n.º 1
0
 def __init__(self, ID=None):
     self.Test = QProcess()
     self.ID = ID
     #a and b to test if i get a output or command error
     self.a = True
     self.Settings = QtCore.QSettings('Tyrant.cfg',
                                      QtCore.QSettings.IniFormat)
Exemplo n.º 2
0
 def get_output(cmd):
     if isinstance(cmd, list):
         cmd = ' '.join(cmd)
     process = QProcess()
     process.start(cmd)
     process.waitForFinished()
     return str(process.readAll())
Exemplo n.º 3
0
def main():
    app = QApplication(sys.argv)
    window = QSimpleShellWidget()
    proc = QProcess()
    window.setProcess(proc)
    proc.start('sh -c "while true; do echo foo; sleep 1; done"')
    window.show()
    app.exec_()
Exemplo n.º 4
0
 def testNoArgs(self):
     '''Connecting a lambda to a signal without arguments'''
     proc = QProcess()
     dummy = Dummy()
     QObject.connect(proc, SIGNAL('started()'),
                     lambda: setattr(dummy, 'called', True))
     proc.start(sys.executable, ['-c', '""'])
     proc.waitForFinished()
     self.assert_(dummy.called)
Exemplo n.º 5
0
    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 = ''
Exemplo n.º 6
0
 def testWithArgs(self):
     '''Connecting a lambda to a signal with arguments'''
     proc = QProcess()
     dummy = Dummy()
     QObject.connect(proc, SIGNAL('finished(int)'),
                     lambda x: setattr(dummy, 'called', x))
     proc.start(sys.executable, ['-c', '""'])
     proc.waitForFinished()
     self.assertEqual(dummy.called, proc.exitCode())
    def testQProcessFinished(self):
        '''Multiple connections to QProcess.finished(int)'''
        sender = QProcess()
        receivers = [BasicPySlotCase() for x in range(10)]

        def start_proc(*args):
            sender.start(sys.executable, ['-c', '""'])
            sender.waitForFinished()

        self.run_many(sender, 'finished(int)', start_proc, receivers, (0, ))
Exemplo n.º 8
0
 def __init__(self, finishedHook=None, stdoutHook=None, stderrHook=None):
     self.process = QProcess()
     self.finishedHook = finishedHook
     self.stdoutHook = stdoutHook
     self.stderrHook = stderrHook
     self.process.finished.connect(self.finished)
     self.process.readyReadStandardOutput.connect(self.readStdout)
     self.process.readyReadStandardError.connect(self.readStderr)
     self.print_next_error_lines = 0
     self.print_next_error_file = False
Exemplo n.º 9
0
def generate_completes(force=False):
    # check parsed functions
    cache_file = vex_settings.get_autocomplete_cache_file()
    if os.path.exists(cache_file) and not force:
        return True
    # get vcc
    vcc = os.path.join(hou.getenv('HFS'), 'bin', 'vcc').replace('/','\\')
    if os.name == 'nt':
        vcc = vcc + '.exe'
    if not os.path.exists(vcc):
        return False
    # generate new
    funcs = {}
    attrs = {}
    process = QProcess()
    process.start(' '.join([vcc, '-X']))
    process.waitForFinished()
    lines =  str(process.readAll()).split('\n')
    for context in lines:
        if context:
            process.start(' '.join([vcc, '-X', context]))
            process.waitForFinished()
            context_lines =  str(process.readAll())
            # variables
            variables = re.search(r'Global Variables:(.*)Control Statements:', context_lines, re.DOTALL)
            if variables:
                lines = variables.group(1).strip().split('\n')
                for l in lines:
                    s = l.split()
                    if len(s)==3:
                        attrs[s[-1]] = s[-2]
            # functions
            pat = r'^\s*(\w+\[?\]?)\s(\w+)(\(.+\))'
            for l in context_lines.split('\n'):
                func = re.findall(pat, str(l))
                if func:
                    f_name = func[0][1]
                    f_args = func[0][2]
                    if f_name in funcs:
                        if not f_args in funcs[f_name].get('args', []):
                            funcs[f_name]['args'].append(f_args)
                    else:
                        funcs[f_name] = {'args':  [f_args]}
    # parse help if Houdini 15
    if hou.applicationVersion()[0] >= 15:
        funcs = parse_help(funcs)
    # save to cache
    if os.path.exists(cache_file):
        comp = json.load(open(cache_file))
    else:
        comp = {}
    comp['functions'] = funcs
    comp['attributes'] = attrs
    json.dump(comp, open(cache_file, 'w'))
    return True
Exemplo n.º 10
0
 def process(self, command):
     #       print "process"
     content = "content"
     process = QProcess()
     process.start(command)
     process.closeWriteChannel()
     process.waitForFinished()
     #       process.closeWriteChannel()
     content = process.readAllStandardOutput()
     print "Content: " + content
     return unicode(content)
Exemplo n.º 11
0
    def run(self):

        self.logger.debug("patcher started")
        for patch in self.patches:
            mod = patch["mod"]
            fromFile = patch["patchfile"]
            toFile = patch["tofilename"]
            frommd5 = patch["md5"]
            tomd5 = patch["tomd5"]

            curPatchGen = "%s-%s.xdelta" % (fromFile, toFile)

            self.logger.debug(curPatchGen)

            self.logger.debug("opening database")
            self.db = QtSql.QSqlDatabase.cloneDatabase(self.parentDb,
                                                       curPatchGen)
            source = os.path.join(
                config['global']['content_path'] + r"updaterNew/", mod,
                fromFile)
            target = os.path.join(
                config['global']['content_path'] + r"updaterNew/", mod, toFile)

            self.logger.debug(source)
            self.logger.debug(target)

            patchdest = os.path.join(
                config['global']['content_path'] + r"xdelta/", curPatchGen)
            self.logger.debug(patchdest)

            if os.path.exists(source) and os.path.exists(target):

                executable = "python"
                arguments = [
                    config['global']['install_path'] + "patcher.py", source,
                    target, patchdest
                ]

                self.logger.debug(arguments)
                process = QProcess()

                process.start(executable, arguments)

                if not process.waitForFinished(28800000):
                    return

                self.db.open()
                query = QSqlQuery(self.db)
                queryStr = (
                    "INSERT INTO patchs_table (fromMd5, toMd5, patchFile) VALUES ('%s','%s','%s')"
                ) % (frommd5, tomd5, curPatchGen)
                query.exec_(queryStr)
                #
                self.db.close()
Exemplo n.º 12
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)
Exemplo n.º 13
0
    def run(self):
        if self.ui.cb_batch.isChecked():
            self.last_log_file = None
        else:
            f_next, _ = os.path.splitext(str(self.ui.edit_file.text()))        
            f_params = f_next + '.params'
            if not os.path.exists(f_params):
                self.create_params_file(f_params)
                self.ui.btn_param.setEnabled(True)
                return
            self.last_log_file = f_next + '.log'
        
        if self.ui.tabWidget.currentIndex() == 0:
            args = self.command_line_args()
        elif self.ui.tabWidget.currentIndex() == 1:
            args = self.gui_command_line_args()
        
        self.update_result_tab()

        # # Start process
        self.ui.edit_stdout.clear()
        format = self.ui.edit_stdout.currentCharFormat()
        format.setFontWeight(QFont.Normal)
        format.setForeground(QtCore.Qt.blue)
        self.ui.edit_stdout.setCurrentCharFormat(format)
        time_str = datetime.datetime.now().ctime()
        start_msg = '''\
                       Starting spyking circus at {time_str}.

                       Command line call:
                       {call}
                    '''.format(time_str=time_str, call=' '.join(args))
        self.ui.edit_stdout.appendPlainText(textwrap.dedent(start_msg))
        format.setForeground(QtCore.Qt.black)
        self.ui.edit_stdout.setCurrentCharFormat(format)
        self.ui.edit_stdout.appendPlainText('\n')

        self.process = QProcess(self)
        self.connect(self.process, SIGNAL('readyReadStandardOutput()'), self.append_output)
        self.connect(self.process, SIGNAL('readyReadStandardError()'),
                     self.append_error)
        self.connect(self.process, SIGNAL('started()'),
                     self.process_started)
        self.connect(self.process, SIGNAL('finished(int)'),
                     self.process_finished)
        self.connect(self.process, SIGNAL('error()'),
                     self.process_errored)
        self._interrupted = False
        self.process.start(args[0], args[1:])
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 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)
Exemplo n.º 16
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)
Exemplo n.º 17
0
 def __init__(self, media, parent):
     super(WebMediaView, self).__init__(media, parent)
     self.widget = QWidget(parent)
     self.process = QProcess(self.widget)
     self.process.setObjectName('%s-process' % self.objectName())
     self.std_out = []
     self.errors = []
     self.stopping = False
     self.mute = False
     self.widget.setGeometry(media['geometry'])
     self.connect(self.process, SIGNAL('error()'), self.process_error)
     self.connect(self.process, SIGNAL('finished()'), self.process_finished)
     self.connect(self.process, SIGNAL('started()'), self.process_started)
     self.set_default_widget_prop()
     self.stop_timer = QTimer(self)
     self.stop_timer.setSingleShot(True)
     self.stop_timer.setInterval(1000)
     self.stop_timer.timeout.connect(self.process_timeout)
     self.rect = self.widget.geometry()
Exemplo n.º 18
0
    def testWithoutArgs(self):
        '''Connect QProcess.started() to QTimeLine.togglePaused()'''
        process = QProcess()
        timeline = QTimeLine()

        QObject.connect(process, SIGNAL('finished(int, QProcess::ExitStatus)'),
                        timeline, SLOT('toggleDirection()'))

        orig_dir = timeline.direction()

        process.start(sys.executable, ['-c', '"print 42"'])
        process.waitForFinished()

        new_dir = timeline.direction()

        if orig_dir == QTimeLine.Forward:
            self.assertEqual(new_dir, QTimeLine.Backward)
        else:
            self.assertEqual(new_dir, QTimeLine.Forward)
Exemplo n.º 19
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)
Exemplo n.º 20
0
    def __init__(self, media, parent):
        super(VideoMediaView, self).__init__(media, parent)
        self._widget = QWidget(parent)
        self._process = QProcess(self._widget)
        self._process.setObjectName('%s-process' % self.objectName())
        self._std_out = []
        self._errors = []
        self._stopping = False
        self._mute = False
        if 'mute' in self._options:
            self._mute = bool(int(self._options['mute']))

        self._widget.setGeometry(media['_geometry'])
        self.connect(self._process, SIGNAL("error()"), self._process_error)
        self.connect(self._process, SIGNAL("finished()"), self.stop)
        self.connect(self._process, SIGNAL("readyReadStandardOutput()"),
                     self.__grep_std_out)
        self.set_default_widget_prop()

        self._stop_timer = QTimer(self)
        self._stop_timer.setSingleShot(True)
        self._stop_timer.setInterval(1000)
        self._stop_timer.timeout.connect(self._force_stop)
Exemplo n.º 21
0
def parse_asn1(*files, **options):
    ''' Call the ASN.1 parser on a number of files, and return the module
        containing the AST
        This function uses QProcess to launch the ASN.1 compiler because
        the subprocess module from Python has issues on the Windows platform
    '''
    ast_version = options.get('ast_version', ASN1.UniqueEnumeratedNames)
    rename_policy = options.get('rename_policy', ASN1.NoRename)
    flags = options.get('flags', [ASN1.AstOnly])
    pprint = options.get('pretty_print', False)
    assert isinstance(ast_version, ASN1)
    assert isinstance(rename_policy, ASN1)
    assert isinstance(flags, list)
    path_to_asn1scc = spawn.find_executable('asn1.exe')

    if not path_to_asn1scc:
        raise TypeError('ASN.1 Compiler not found in path')
    if os.name == 'posix':
        path_to_mono = spawn.find_executable('mono')
        if not path_to_mono:
            raise TypeErorr('"mono" not found in path. Please install it.')
        binary = path_to_mono
        arg0 = path_to_asn1scc
    else:
        binary = path_to_asn1scc
        arg0 = ''
    asn1scc_root = os.path.abspath(os.path.dirname(path_to_asn1scc))
    # Create a temporary directory to store dataview.py and import it
    tempdir = tempfile.mkdtemp()
    sys.path.append(tempdir)
    if os.name == 'nt':
        # On windows, remove the drive letter, workaround to ASN1SCC bug
        tempdir = tempdir[2:]
        asn1scc_root = asn1scc_root[2:]
    filename = str(uuid.uuid4()).replace('-', '_')
    filepath = tempdir + os.sep + filename + '.py'

    stg = asn1scc_root + os.sep + 'python.stg'

    if pprint:
        # Generate an html file with pretty-printed ASN.1 types
        stg_qrc = QFile(':misc/pretty_print_asn1.stg')
        stg_qrc.open(1)
        content = stg_qrc.readAll()
        stgfile = tempdir + os.sep + 'pretty_print_asn1.stg'
        with open(stgfile, 'w') as tmpfile:
            tmpfile.write(content.data())
        out_html = tempdir + os.sep + 'dataview.html'
        html = ['-customIcdUper', stgfile + '::' + out_html]
    else:
        html = []
    args = [
        arg0, '-customStgAstVerion',
        str(ast_version.value), '-customStg', stg + '::' + filepath,
        '-renamePolicy',
        str(rename_policy.value)
    ] + html + list(*files)
    asn1scc = QProcess()
    LOG.debug(os.getcwd())
    LOG.debug(binary + ' ' + ' '.join(args))
    asn1scc.start(binary, args)

    _ = waitfor_qprocess(asn1scc, "ASN.1 Compiler")

    if filename in AST.viewkeys():
        # Re-import module if it was already loaded
        ast = AST[filename]
        reload(ast)
    else:
        ast = importlib.import_module(filename)
        AST[filename] = ast
    if pprint:
        # add the path to the optionally-gernated pretty-printed HTML file
        ast.html = out_html
    return ast
Exemplo n.º 22
0
def asn2dataModel(*files):
    ''' Call asn1DataModel, including the Makefile.python and return
    the imported module "name_of_dataview_asn.py"
    From this module it is possible to create native Asn1scc instances of
    ASN.1 data types, and to access to DV.py, which contains constants
    such as the _PRESENT fields for choice selectors '''
    assert len(files) > 0

    # 1) Create a temporary directory for the output
    tempdir = tempfile.mkdtemp()
    sys.path.insert(0, tempdir)
    # Use a unique name for the asn1 concatenated module
    concat_prefix = str(uuid.uuid4()).replace('-', '_')
    concat_path = os.path.join(tempdir, concat_prefix)

    # 2) Concat all input files to the output directory
    cat_bin = spawn.find_executable('cat')
    args = list(files)
    cat = QProcess()
    LOG.debug(os.getcwd())
    LOG.debug(cat_bin + ' ' + ' '.join(args))
    cat.start(cat_bin, args)
    merged = waitfor_qprocess(cat, 'Merge dataviews')
    with open(concat_path + '.asn', 'wt') as merged_file:
        merged_file.write(merged)

    # 3) Run asn2dataModel
    asn2dm_bin = spawn.find_executable('asn2dataModel')
    args = ['-toPython', '-o', tempdir, concat_path + '.asn']
    asn2dm = QProcess()
    LOG.debug(os.getcwd())
    LOG.debug(asn2dm_bin + ' ' + ' '.join(args))
    asn2dm.start(asn2dm_bin, args)
    waitfor_qprocess(asn2dm, 'DMT tool "asn2dataModel"')

    # 4) call make -f Makefile.python to build the .so
    make_bin = spawn.find_executable('make')
    args = ['-f', 'Makefile.python']
    make = QProcess()
    make.setWorkingDirectory(tempdir)
    LOG.debug(os.getcwd())
    LOG.debug(make_bin + ' ' + ' '.join(args))
    make.start(make_bin, args)
    waitfor_qprocess(make, 'make -f Makefile.python')

    if concat_prefix in ASN2DM.viewkeys():
        # Re-import module if it was already loaded
        asn1mod = ASN2DM[concat_prefix]
        reload(asn1mod)
        reload(asn1mod.DV)
        import Stubs
        reload(Stubs)
    else:
        asn1mod = importlib.import_module(concat_prefix + '_asn')
        # force reload of modules in case of multiple calls
        reload(asn1mod.DV)
        import Stubs
        reload(Stubs)
        ASN2DM[concat_prefix] = asn1mod
    sys.path.pop(0)
    return asn1mod
Exemplo n.º 23
0
def parse_asn1(*files, **options):
    ''' Call the ASN.1 parser on a number of files, and return the module
        containing the AST
        This function uses QProcess to launch the ASN.1 compiler because
        the subprocess module from Python has issues on the Windows platform
    '''
    # use basic caching to avoid re-parsing when loading the model
    project_cache = os.getenv ("PROJECT_CACHE")
    if project_cache is not None and not os.path.isdir(project_cache):
        raise TypeError (
            "The configured cache folder \""
            + project_cache + "\" is not there!\n")
    # make sure the same files are not parsed more than once if not modified
    filehash = hashlib.md5()
    file_list = sorted(list(*files))
    try:
        for each in file_list:
            filehash.update(open(each).read())
            # also hash the file path: it is used in the AST, so it is
            # not enough to hash the content of the ASN.1 files, as two sets
            # of input files may have the same hash
            filehash.update(each)
    except IOError as err:
        raise TypeError (str(err))
    new_hash = filehash.hexdigest()

    # names of the files that will be generated by asn1scc and then parsed
    out_py_name   = new_hash + ".py"
    out_html_name = new_hash + ".html"

    if new_hash in AST.viewkeys():
        return AST[new_hash]
    elif project_cache is not None:
        outdir = project_cache
    elif project_cache is None:
        outdir = tempfile.mkdtemp()

    # to allow the import
    sys.path.append(outdir)

    ast_version = options.get('ast_version', ASN1.UniqueEnumeratedNames)
    rename_policy = options.get('rename_policy', ASN1.NoRename)
    flags = options.get('flags', [ASN1.AstOnly])
    pprint = options.get('pretty_print', False)
    assert isinstance(ast_version, ASN1)
    assert isinstance(rename_policy, ASN1)
    assert isinstance(flags, list)
    path_to_asn1scc = spawn.find_executable('asn1.exe')

    if not path_to_asn1scc:
        raise TypeError('ASN.1 Compiler not found in path')
    if os.name == 'posix':
        path_to_mono = spawn.find_executable('mono')
        if not path_to_mono:
            raise TypeError('"mono" not found in path. Please install it.')
        binary = path_to_mono
        arg0 = path_to_asn1scc
    else:
        binary = path_to_asn1scc
        arg0 = ''
    asn1scc_root = os.path.abspath(os.path.dirname(path_to_asn1scc))

    if os.name == 'nt':
        # On windows, remove the drive letter, workaround to ASN1SCC bug
        outdir       = outdir[2:]
        asn1scc_root = asn1scc_root[2:]

    # The two possible files that can be generated with complete path:
    py_filepath   = outdir + os.sep + out_py_name
    html_filepath = outdir + os.sep + out_html_name

    # call the ASN.1 compiler only if there is no existing cached file
    if project_cache is None or not os.path.exists(py_filepath):
        stg = asn1scc_root + os.sep + 'python.stg'

        if pprint:
            # Generate an html file with pretty-printed ASN.1 types
            stg_qrc = QFile(':misc/pretty_print_asn1.stg')
            stg_qrc.open(1)
            content = stg_qrc.readAll()
            stgfile = outdir + os.sep + 'pretty_print_asn1.stg'
            with open(stgfile, 'w') as tmpfile:
                tmpfile.write(content.data())
            html = ['-customIcdUper', stgfile + '::' + html_filepath]
        else:
            html = []
        args = [arg0, '-customStgAstVersion', str(ast_version.value),
                '-customStg', stg + '::' + py_filepath,
                '-renamePolicy', str(rename_policy.value)] + html + file_list
        asn1scc = QProcess()
        LOG.debug(os.getcwd())
        LOG.debug(binary + ' ' + ' '.join(args))
        asn1scc.start(binary, args)

        _ = waitfor_qprocess(asn1scc, "ASN.1 Compiler")

    ast = importlib.import_module(new_hash)
    AST[new_hash] = ast
    if pprint:
        # add the path to the optionally-generated pretty-printed HTML file
        ast.html = html_filepath
    return ast
Exemplo n.º 24
0
    def __init__(self, parent=None):
        super(RobocompDslGui, self).__init__(parent)
        self.setWindowTitle("Create new component")
        # self._idsl_paths = []
        self._communications = {
            "implements": [],
            "requires": [],
            "subscribesTo": [],
            "publishes": []
        }
        self._interfaces = {}
        self._cdsl_doc = CDSLDocument()
        self._command_process = QProcess()

        self._main_widget = QWidget()
        self._main_layout = QVBoxLayout()
        self.setCentralWidget(self._main_widget)

        self._name_layout = QHBoxLayout()
        self._name_line_edit = QLineEdit()
        self._name_line_edit.textEdited.connect(self.update_component_name)
        self._name_line_edit.setPlaceholderText("New component name")
        self._name_layout.addWidget(self._name_line_edit)
        self._name_layout.addStretch()

        # DIRECTORY SELECTION
        self._dir_line_edit = QLineEdit()
        # self._dir_line_edit.textEdited.connect(self.update_completer)
        self._dir_completer = QCompleter()
        self._dir_completer_model = QFileSystemModel()
        if os.path.isdir(ROBOCOMP_COMP_DIR):
            self._dir_line_edit.setText(ROBOCOMP_COMP_DIR)
            self._dir_completer_model.setRootPath(ROBOCOMP_COMP_DIR)
        self._dir_completer.setModel(self._dir_completer_model)
        self._dir_line_edit.setCompleter(self._dir_completer)

        self._dir_button = QPushButton("Select directory")
        self._dir_button.clicked.connect(self.set_output_directory)
        self._dir_layout = QHBoxLayout()
        self._dir_layout.addWidget(self._dir_line_edit)
        self._dir_layout.addWidget(self._dir_button)

        # LIST OF ROBOCOMP INTERFACES
        self._interface_list = QListWidget()
        self._interface_list.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        self._interface_list.itemSelectionChanged.connect(
            self.set_comunication)

        # LIST OF CONNECTION TyPES
        self._type_combo_box = QComboBox()
        self._type_combo_box.addItems(
            ["publishes", "implements", "subscribesTo", "requires"])
        self._type_combo_box.currentIndexChanged.connect(
            self.reselect_existing)

        # BUTTON TO ADD A NEW CONNECTION
        # self._add_connection_button = QPushButton("Add")
        # self._add_connection_button.clicked.connect(self.add_new_comunication)
        self._add_connection_layout = QHBoxLayout()
        # self._add_connection_layout.addWidget(self._add_connection_button)
        self._language_combo_box = QComboBox()
        self._language_combo_box.addItems(["Python", "Cpp", "Cpp11"])
        self._language_combo_box.currentIndexChanged.connect(
            self.update_language)
        self._add_connection_layout.addWidget(self._language_combo_box)
        self._add_connection_layout.addStretch()
        self._gui_check_box = QCheckBox()
        self._gui_check_box.stateChanged.connect(self.update_gui_selection)
        self._gui_label = QLabel("Use Qt GUI")
        self._add_connection_layout.addWidget(self._gui_label)
        self._add_connection_layout.addWidget(self._gui_check_box)

        # WIDGET CONTAINING INTERFACES AND TYPES
        self._selection_layout = QVBoxLayout()
        self._selection_layout.addWidget(self._type_combo_box)
        self._selection_layout.addWidget(self._interface_list)
        self._selection_layout.addLayout(self._add_connection_layout)
        self._selection_widget = QWidget()
        self._selection_widget.setLayout(self._selection_layout)

        # TEXT EDITOR WITH THE RESULTING CDSL CODE
        self._editor = QTextEdit(self)
        self._editor.setHtml("")

        self._document = self._editor.document()
        self._component_directory = None

        # SPLITTER WITH THE SELECTION AND THE CODE
        self._body_splitter = QSplitter(Qt.Horizontal)
        self._body_splitter.addWidget(self._selection_widget)
        self._body_splitter.addWidget(self._editor)
        self._body_splitter.setStretchFactor(0, 2)
        self._body_splitter.setStretchFactor(1, 9)

        # CREATION BUTTONS
        self._create_button = QPushButton("Create .cdsl")
        self._create_button.clicked.connect(self.write_cdsl_file)
        self._creation_layout = QHBoxLayout()
        self._creation_layout.addStretch()
        self._creation_layout.addWidget(self._create_button)

        self._console = QConsole()
        self._command_process.readyReadStandardOutput.connect(
            self._console.standard_output)
        self._command_process.readyReadStandardError.connect(
            self._console.error_output)

        # ADDING WIDGETS TO MAIN LAYOUT
        self._main_widget.setLayout(self._main_layout)
        self._main_layout.addLayout(self._name_layout)
        self._main_layout.addLayout(self._dir_layout)
        self._main_layout.addWidget(self._body_splitter)
        self._main_layout.addLayout(self._creation_layout)
        self._main_layout.addWidget(self._console)
        self.setMinimumSize(800, 500)
        self._editor.setText(self._cdsl_doc.generate_doc())
Exemplo n.º 25
0
 def testIt(self):
     self.arg = None
     p = QProcess()
     p.stateChanged.connect(self.slot)
     p.stateChanged.emit(QProcess.NotRunning)
     self.assertEqual(self.arg, QProcess.NotRunning)
Exemplo n.º 26
0
 def testArgsToNoArgsSignal(self):
     '''Passing arguments to a signal without arguments'''
     process = QProcess()
     self.assertRaises(TypeError, process.emit, SIGNAL('started()'), 42)
Exemplo n.º 27
0
 def testMoreArgs(self):
     '''Passing more arguments than needed'''
     process = QProcess()
     self.assertRaises(TypeError, process.emit, SIGNAL('finished(int)'), 55, 55)