Exemple #1
0
    def __init__(self, parent, plugins=['lsp', 'kite', 'fallback']):
        SpyderCompletionPlugin.__init__(self, parent)
        self.clients = {}
        self.requests = {}
        self.language_status = {}
        self.started = False
        self.first_completion = False
        self.req_id = 0
        self.completion_first_time = 500
        self.waiting_time = 1000
        self.collection_mutex = QMutex()

        self.plugin_priority = {
            LSPRequestTypes.DOCUMENT_COMPLETION: 'lsp',
            LSPRequestTypes.DOCUMENT_SIGNATURE: 'lsp',
            LSPRequestTypes.DOCUMENT_HOVER: 'lsp',
            'all': 'lsp'
        }

        self.response_priority = ['lsp', 'kite', 'fallback']

        for plugin in plugins:
            if plugin in self.BASE_PLUGINS:
                Plugin = self.BASE_PLUGINS[plugin]
                plugin_client = Plugin(self.main)
                self.register_completion_plugin(plugin_client)
Exemple #2
0
 def __init__(self):
     EditorExtension.__init__(self)
     self.is_snippet_active = False
     self.active_snippet = -1
     self.node_number = 0
     self.index = None
     self.ast = None
     self.starting_position = None
     self.modification_lock = QMutex()
     self.event_lock = QMutex()
     self.node_position = {}
     self.snippets_map = {}
     self.undo_stack = []
     self.redo_stack = []
     if rtree_available:
         self.index = index.Index()
Exemple #3
0
    def __init__(self, parent, configuration=None):
        super().__init__(parent, configuration)

        # Available completion providers
        self._available_providers = {}

        # Instantiated completion providers
        self.providers = {}

        # Mapping that indicates if there are completion services available
        # for a given language
        self.language_status = {}

        # Mapping that contains the ids and the current completion/linting
        # requests in progress
        self.requests = {}

        # Current request sequence identifier
        self.req_id = 0

        # Lock to prevent concurrent access to requests mapping
        self.collection_mutex = QMutex(QMutex.Recursive)

        # Completion request priority
        self.source_priority = {}

        # Completion provider speed: slow or fast
        self.provider_speed = {}

        # Timeout limit for a response to be received
        self.wait_for_ms = self.get_conf('completions_wait_for_ms')

        # Save application menus to create if/when MainMenu is available.
        self.application_menus_to_create = []

        # Save items to add to application menus if/when MainMenu is
        # available.
        self.items_to_add_to_application_menus = []

        # Find and instantiate all completion providers registered via
        # entrypoints
        for entry_point in iter_entry_points(COMPLETION_ENTRYPOINT):
            try:
                logger.debug(f'Loading entry point: {entry_point}')
                Provider = entry_point.resolve()
                self._instantiate_and_register_provider(Provider)
            except Exception as e:
                logger.warning('Failed to load completion provider from entry '
                               f'point {entry_point}')
                raise e

        # Register statusbar widgets
        self.register_statusbar_widgets(plugin_loaded=False)

        # Define configuration page and tabs
        (conf_providers, conf_tabs) = self.gather_providers_and_configtabs()
        self.CONF_WIDGET_CLASS = partialclass(CompletionConfigPage,
                                              providers=conf_providers)
        self.ADDITIONAL_CONF_TABS = {'completions': conf_tabs}
Exemple #4
0
 def __init__(self, parent):
     QThread.__init__(self, parent)
     self.mailbox = Queue()
     self.stopped = False
     self.daemon = True
     self.mutex = QMutex()
     self.file_tokens = {}
     self.diff_patch = diff_match_patch()
 def __init__(self, algorithm: SegmentationAlgorithm):
     super().__init__()
     self.finished.connect(self.finished_task)
     self.algorithm = algorithm
     self.clean_later = False
     self.cache = None
     self.mutex = QMutex()
     self.rerun = False, QThread.InheritPriority
Exemple #6
0
    def __init__(self, presenter, plot_number, parent=None):
        super(PlotNameWidget, self).__init__(parent)

        self.presenter = presenter
        self.plot_number = plot_number

        self.mutex = QMutex()

        self.line_edit = QLineEdit(
            self.presenter.get_plot_name_from_number(plot_number))
        self.line_edit.setReadOnly(True)
        self.line_edit.setFrame(False)
        self.line_edit.setStyleSheet(
            "* { background-color: rgba(0, 0, 0, 0); }")
        self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.line_edit.editingFinished.connect(self.rename_plot)

        shown_icon = get_icon('fa.eye')
        self.hide_button = QPushButton(shown_icon, "")
        self.hide_button.setToolTip('Hide')
        self.hide_button.setFlat(True)
        self.hide_button.setMaximumWidth(self.hide_button.iconSize().width() *
                                         5 / 3)
        self.hide_button.clicked.connect(self.toggle_visibility)

        rename_icon = get_icon('fa.edit')
        self.rename_button = QPushButton(rename_icon, "")
        self.rename_button.setToolTip('Rename')
        self.rename_button.setFlat(True)
        self.rename_button.setMaximumWidth(
            self.rename_button.iconSize().width() * 5 / 3)
        self.rename_button.setCheckable(True)
        self.rename_button.toggled.connect(self.rename_button_toggled)

        close_icon = get_icon('fa.close')
        self.close_button = QPushButton(close_icon, "")
        self.close_button.setToolTip('Delete')
        self.close_button.setFlat(True)
        self.close_button.setMaximumWidth(
            self.close_button.iconSize().width() * 5 / 3)
        self.close_button.clicked.connect(
            lambda: self.close_pressed(self.plot_number))

        self.layout = QHBoxLayout()

        # Get rid of the top and bottom margins - the button provides
        # some natural margin anyway. Get rid of right margin and
        # reduce spacing to get buttons closer together.
        self.layout.setContentsMargins(5, 0, 0, 0)
        self.layout.setSpacing(0)

        self.layout.addWidget(self.line_edit)
        self.layout.addWidget(self.hide_button)
        self.layout.addWidget(self.rename_button)
        self.layout.addWidget(self.close_button)

        self.layout.sizeHint()
        self.setLayout(self.layout)
Exemple #7
0
    def __init__(self, presenter, plot_number, parent=None):
        super(PlotNameWidget, self).__init__(parent)

        self.presenter = presenter
        self.plot_number = plot_number

        self.mutex = QMutex()

        self.line_edit = QLineEdit(self.presenter.get_plot_name_from_number(plot_number))
        self.line_edit.setReadOnly(True)
        self.line_edit.setFrame(False)
        # changes the line edit to look like normal even when
        self.line_edit.setStyleSheet("""* { background-color: rgba(0, 0, 0, 0); }
        QLineEdit:disabled { color: black; }""")
        self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.line_edit.editingFinished.connect(self.rename_plot)
        # Disabling the line edit prevents it from temporarily
        # grabbing focus when changing code editors - this triggered
        # the editingFinished signal, which was causing #26305
        self.line_edit.setDisabled(True)

        shown_icon = get_icon('mdi.eye')
        self.hide_button = QPushButton(shown_icon, "")
        self.hide_button.setToolTip('Hide')
        self.hide_button.setFlat(True)
        self.hide_button.setMaximumWidth(self.hide_button.iconSize().width() * 5 / 3)
        self.hide_button.clicked.connect(self.toggle_visibility)

        rename_icon = get_icon('mdi.square-edit-outline')
        self.rename_button = QPushButton(rename_icon, "")
        self.rename_button.setToolTip('Rename')
        self.rename_button.setFlat(True)
        self.rename_button.setMaximumWidth(self.rename_button.iconSize().width() * 5 / 3)
        self.rename_button.setCheckable(True)
        self.rename_button.toggled.connect(self.rename_button_toggled)

        close_icon = get_icon('mdi.close')
        self.close_button = QPushButton(close_icon, "")
        self.close_button.setToolTip('Delete')
        self.close_button.setFlat(True)
        self.close_button.setMaximumWidth(self.close_button.iconSize().width() * 5 / 3)
        self.close_button.clicked.connect(lambda: self.close_pressed(self.plot_number))

        self.layout = QHBoxLayout()

        # Get rid of the top and bottom margins - the button provides
        # some natural margin anyway. Get rid of right margin and
        # reduce spacing to get buttons closer together.
        self.layout.setContentsMargins(5, 0, 0, 0)
        self.layout.setSpacing(0)

        self.layout.addWidget(self.line_edit)
        self.layout.addWidget(self.hide_button)
        self.layout.addWidget(self.rename_button)
        self.layout.addWidget(self.close_button)

        self.layout.sizeHint()
        self.setLayout(self.layout)
Exemple #8
0
    def __init__(self, cam_id, image_width, image_height):
        super(UpdateThread, self).__init__()
        self._width = 640
        self._height = 480
        self._stopped = False
        self._update_mutex = QMutex()

        self._cam_id = cam_id
        self._image_width = image_width
        self._image_height = image_height
Exemple #9
0
 def __init__(self, parent):
     QObject.__init__(self, parent)
     self.endpoint = None
     self.requests = {}
     self.languages = []
     self.mutex = QMutex()
     self.opened_files = {}
     self.thread_started = False
     self.thread = QThread()
     self.moveToThread(self.thread)
     self.thread.started.connect(self.started)
     self.sig_perform_request.connect(self.perform_request)
Exemple #10
0
    def __init__(self, parent):
        QObject.__init__(self)
        self.stopped = False
        self.daemon = True
        self.mutex = QMutex()
        self.file_tokens = {}
        self.diff_patch = diff_match_patch()
        self.thread = QThread()
        self.moveToThread(self.thread)

        self.thread.started.connect(self.started)
        self.sig_mailbox.connect(self.handle_msg)
Exemple #11
0
    def __init__(self, parent):
        QObject.__init__(self)
        self.stopped = False
        self.daemon = True
        self.mutex = QMutex()
        self.language_snippets = {}
        self.thread = QThread()
        self.moveToThread(self.thread)

        self.thread.started.connect(self.started)
        self.sig_mailbox.connect(self.handle_msg)
        self.sig_update_snippets.connect(self.update_snippets)
Exemple #12
0
    def __init__(self):
        self._mutex = QMutex()
        self.parser_collection = ParserCollection()
        self.element_collection = ElementCollection()
        self.factory = ElementFactory()

        self.add_parser('dxf', DXFParser())
        self.add_parser('off', OFFParser())
        self.add_parser('h5m', H5MParser())
        self.add_parser('h5p', H5PParser())
        self.add_parser('csv', CSVParser())
        self.add_parser('out', GSLibParser())
Exemple #13
0
    def __init__(self, parent, plugins=['lsp', 'kite', 'fallback']):
        SpyderCompletionPlugin.__init__(self, parent)
        self.clients = {}
        self.requests = {}
        self.language_status = {}
        self.started = False
        self.req_id = 0
        self.collection_mutex = QMutex(QMutex.Recursive)

        for plugin in plugins:
            if plugin in self.BASE_PLUGINS:
                Plugin = self.BASE_PLUGINS[plugin]
                plugin_client = Plugin(self.main)
                self.register_completion_plugin(plugin_client)
Exemple #14
0
 def __init__(self, parent, enable_code_snippets=True):
     QObject.__init__(self, parent)
     self.endpoint = None
     self.requests = {}
     self.languages = []
     self.mutex = QMutex()
     self.opened_files = {}
     self.opened_files_status = {}
     self.thread_started = False
     self.enable_code_snippets = enable_code_snippets
     self.thread = QThread()
     self.moveToThread(self.thread)
     self.thread.started.connect(self.started)
     self.sig_perform_request.connect(self.perform_request)
     self.sig_perform_status_request.connect(self.get_status)
Exemple #15
0
    def __init__(self, parent, plugins=ALL_COMPLETION_PLUGINS):
        SpyderCompletionPlugin.__init__(self, parent)
        self.clients = {}
        self.requests = {}
        self.language_status = {}
        self.started = False
        self.req_id = 0
        self.collection_mutex = QMutex(QMutex.Recursive)
        self.wait_for_ms = self.get_option('completions_wait_for_ms',
                                           section='editor')

        for plugin in plugins:
            if plugin in self.BASE_PLUGINS:
                Plugin = self.BASE_PLUGINS[plugin]
                plugin_client = Plugin(self.main)
                self.register_completion_plugin(plugin_client)
Exemple #16
0
 def __init__(self, parent):
     QThread.__init__(self, parent)
     self.mutex = QMutex()
     self.stopped = None
     self.results = None
     self.pathlist = None
     self.nb = None
     self.error_flag = None
     self.rootpath = None
     self.python_path = None
     self.hg_manifest = None
     self.include = None
     self.exclude = None
     self.texts = None
     self.text_re = None
     self.completed = None
     self.get_pythonpath_callback = None
Exemple #17
0
 def __init__(self, parent):
     QThread.__init__(self, parent)
     self.mutex = QMutex()
     self.stopped = None
     self.results = None
     self.pathlist = None
     self.total_matches = None
     self.error_flag = None
     self.rootpath = None
     self.exclude = None
     self.texts = None
     self.text_re = None
     self.completed = None
     self.case_sensitive = True
     self.results = {}
     self.total_matches = 0
     self.is_file = False
    def work(p):
        global i, j
        j += 1
        mutex = QMutex()
        print('start')
        while (1):
            mutex.lock()
            # print(self.thread())
            # self.wait_condition.wait(self.mutex)
            # for j in range(3):
            #     print(j)
            i += 1
            p.signal_print.emit(repr(('thread:%d' % p.id, i)))
            # print('thread:%d' % p.id, i, '\n')
            p.thread().msleep(10)

            # mutex.unlock()
            if i > 100:
                break
Exemple #19
0
 def __init__(self, serl, codegen, que):
     self.pressureque = que
     self.serl = serl
     self.codegen = codegen
     self.codegen.GenerateCMV()
     self.codelist = self.codegen.gcodestr.splitlines()
     self.linecount = len(self.codelist)
     self.flagStop = False
     self.pause = True
     self.gcode_exec_state = GcodeStates.READY_TO_SEND
     self.gcode_move_count = 0
     self.presentPosition = (0,0)
     self.Tic = 0
     self.Toc = 0
     self.xyIncr = self.codegen.Dt
     self.gstr = ""
     self.sremsg = ""
     self.serialmutex = QMutex()
     self.startdelay = -1
     super().__init__()
Exemple #20
0
    def __init__(self, parent, search_text, text_color=None):
        super().__init__(parent)
        self.mutex = QMutex()
        self.stopped = None
        self.search_text = search_text
        self.text_color = text_color
        self.pathlist = None
        self.total_matches = None
        self.error_flag = None
        self.rootpath = None
        self.exclude = None
        self.texts = None
        self.text_re = None
        self.completed = None
        self.case_sensitive = True
        self.total_matches = 0
        self.is_file = False
        self.results = {}

        self.num_files = 0
        self.files = []
        self.partial_results = []
Exemple #21
0
 def __init__(self):
     QThread.__init__(self)
     self.app = QApplication.instance()
     self.app.aboutToQuit.connect(self.requestInterruption)
     self.map_lock = QMutex()
     self.widget_map = dict()
Exemple #22
0
 def __init__(self, *args, **kwargs):
     super(ConsoleInitThread, self).__init__(*args, **kwargs)
     self.mutex = QMutex()
     self.wait_condition = QWaitCondition()
Exemple #23
0
class Q7FingerPrint:
    STATUS_UNCHANGED = 'U'
    STATUS_MODIFIED = 'M'
    STATUS_SAVEABLE = 'S'
    STATUS_CONVERTED = 'C'
    STATUS_LIST = (STATUS_UNCHANGED, STATUS_MODIFIED, STATUS_CONVERTED,
                   STATUS_SAVEABLE)
    __mutex = QMutex()
    __chloneproxy = None
    __viewscounter = 0
    __fingerprintcounter = 0
    __extension = [
    ]  # the single variable that holds the fingerprint reference

    @classmethod
    def proxy(cls):
        cls.Lock()
        if cls.__chloneproxy is None:
            thrd = OCTXT.ActivateMultiThreading
            # BLOCK ACTUAL MULTI-THREADING HERE
            cls.__chloneproxy = Q7CHLoneProxy(thrd)
        cls.Unlock()
        return cls.__chloneproxy

    @classmethod
    def killProxy(cls):
        cls.Lock()
        if cls.__chloneproxy is not None:
            cls.__chloneproxy.kill()
        cls.Unlock()

    @classmethod
    def Lock(cls):
        cls.__mutex.lock()

    @classmethod
    def Unlock(cls):
        cls.__mutex.unlock()

    @classmethod
    def fileconversion(cls, fdir, filein, control):
        fileout = OCTXT.TemporaryDirectory + '/' + filein + '.hdf'
        count = 1
        while os.path.exists(fileout):
            fileout = OCTXT.TemporaryDirectory + '/' + filein + '.%.3d.hdf' % count
            count += 1
        com = '(cd %s; %s -f -h %s %s)' % (fdir, OCTXT.ADFConversionCom,
                                           filein, fileout)
        os.system(com)
        return fileout

    @classmethod
    def treeLoad(cls, control, selectedfile):
        control.loadOptions()
        proxy = cls.proxy()
        proxy.load(control, selectedfile)
        cls.refreshScreen()
        return

    @classmethod
    def treeSave(cls, control, fgprint, f, saveas):
        flags = CGNS.MAP.S2P_DEFAULT
        if OCTXT.CHLoneTrace:
            flags |= CGNS.MAP.S2P_TRACE
        if not saveas:
            flags |= CGNS.MAP.S2P_UPDATE
            flags |= CGNS.MAP.S2P_DELETEMISSING
        tree = fgprint.tree
        lazylist = [CGU.getPathNoRoot(path) for path in list(fgprint.lazy)]
        try:
            CGNS.MAP.save(f,
                          tree,
                          links=fgprint.links,
                          flags=flags,
                          skip=lazylist)
        except (CGNS.MAP.error, ) as chlex:
            txt = """The current save operation has been aborted (CHLone):"""
            control.readyCursor()
            MSG.wError(control, 130, txt, chlex.args[0][1])
            return None
        except (Exception, ) as e:
            txt = """The current save operation has been aborted: %s""" % e
            control.readyCursor()
            MSG.wError(control, 131, txt, '')
            return None
        fgprint.updateFileStats(f, saveas=True)

    @classmethod
    def closeAllTrees(cls):
        while cls.__extension:
            x = cls.__extension[0]
            x.closeAllViews()

    @classmethod
    def refreshScreen(cls):
        QCoreApplication.processEvents()

    @classmethod
    def disableAllViewsButtons(cls, lock):
        cls.Lock()
        for x in cls.__extension:
            for vtype in x.views:
                for (v, i) in x.views[vtype]:
                    for wid in v._lockableWidgets:
                        if not lock and wid in v._lockedWidgets:
                            wid.setDisabled(lock)
                            v._lockedWidgets.remove(wid)
                        if lock and wid.isEnabled():
                            v._lockedWidgets.append(wid)
                            wid.setDisabled(lock)
                    if v.FG is not None:
                        v.FG._locked = lock
        cls.Unlock()

    @classmethod
    def raiseView(cls, idx):
        cls.Lock()
        for x in cls.__extension:
            for vtype in x.views:
                for (v, i) in x.views[vtype]:
                    if i == int(idx):
                        v.raise_()
        cls.Unlock()

    @classmethod
    def infoView(cls, idx):
        f = cls.getFingerPrint(idx)
        v = cls.getView(idx)
        if f is None:
            return (None, None, None)
        if not f.isfile:
            return (f, None, None)
        return (f, v, f.getInfo())

    @classmethod
    def getView(cls, idx):
        for x in cls.__extension:
            for vtype in x.views:
                for (v, i) in x.views[vtype]:
                    if i == int(idx):
                        return v
        return None

    @classmethod
    def getViewType(cls, idx):
        vw = cls.getView(idx)
        for x in cls.__extension:
            for vtype in x.views:
                for (v, i) in x.views[vtype]:
                    if (v == vw) and (i == int(idx)):
                        return vtype
        return None

    @classmethod
    def getFingerPrint(cls, idx):
        ix = int(idx)
        for x in cls.__extension:
            for vtype in x.views:
                for (v, i) in x.views[vtype]:
                    if i == ix:
                        return x
        return None

    @classmethod
    def getUniqueTreeViewIdList(cls):
        r = set()
        for x in cls.__extension:
            for vtype in x.views:
                if vtype == Q7Window.VIEW_TREE:
                    for (v, i) in x.views[vtype]:
                        r.add(i)
        return list(r)

    @classmethod
    def getExpandedFilenameList(cls):
        l = []
        for x in cls.__extension:
            l.append("%s/%s" % (x.filedir, x.filename))
        return l

    @classmethod
    def removeNoMoreView(cls):
        for fg in list(Q7FingerPrint.__extension):
            if fg.views == {}:
                fg.model.doRelease()
                fg.doRelease()
                Q7FingerPrint.__extension.remove(fg)

    @classmethod
    def getByIndex(cls, index):
        for fg in Q7FingerPrint.__extension:
            if fg.index == index:
                return fg
        return None

    # -------------------------------------------------------------
    def __init__(self, control, filedir, filename, tree, links, paths, **kw):
        if control is None:
            return  # __root instance, empty
        self.index = Q7FingerPrint.__fingerprintcounter
        self.filename = filename
        self.tree = tree
        self.filedir = filedir
        self.links = links
        self.model = None
        self.depth = 0
        self.nodes = 0
        self.views = {}
        self.control = control
        self.converted = False
        self.isfile = False
        self.infoData = {}
        self.tmpfile = ''
        self._kw = kw
        self._status = []
        self._locked = False
        if 'isfile' in kw:
            self.isfile = True
        if 'converted' in kw:
            self.converted = kw['converted']
            self.tmpfile = kw['convertedAs']
            if self.converted:
                self._status = []
        self.lazy = {}
        for p in paths:
            self.lazy['/CGNSTree' + p[0]] = p[1]
        if ((self.lazy == {}) and
            (checkFilePermission(filedir + '/' + filename, write=True))):
            self._status = [Q7FingerPrint.STATUS_SAVEABLE]
        Q7FingerPrint.__extension.append(self)
        Q7FingerPrint.__fingerprintcounter += 1
        self.updateFileStats(filedir + '/' + filename)

    def __len__(self):
        return 0

    def isLocked(self):
        return self._locked

    def updateNodeData(self, pathdict):
        tfile = "%s/%s" % (self.filedir, self.filename)
        slp = OCTXT.LinkSearchPathList
        slp += [self.filedir]
        minpath = CGU.getPathListCommonAncestor(list(pathdict))
        flags = CGNS.MAP.S2P_DEFAULTS
        if OCTXT.CHLoneTrace:
            flags |= CGNS.MAP.S2P_TRACE
        if OCTXT.FollowLinksAtLoad:
            flags |= CGNS.MAP.S2P_FOLLOWLINKS
        (t, l, p) = CGNS.MAP.load(tfile,
                                  flags=flags,
                                  path=minpath,
                                  lksearch=slp,
                                  update=pathdict)
        return (t, l, p)

    def updateFileStats(self, fname, saveas=False):
        (filedir, filename) = (os.path.normpath(os.path.dirname(fname)),
                               os.path.basename(fname))
        self.filename = filename
        self.filedir = filedir
        self.version = CGU.getVersion(self.tree)
        self.removeTreeStatus(Q7FingerPrint.STATUS_MODIFIED)
        self.addTreeStatus(Q7FingerPrint.STATUS_UNCHANGED)
        if saveas:
            self.converted = False
            self.isfile = True
            self.tmpfile = ''
            self.removeTreeStatus(Q7FingerPrint.STATUS_CONVERTED)
            self.addTreeStatus(Q7FingerPrint.STATUS_SAVEABLE)

    def isFile(self):
        return self.isfile

    def isLink(self, path):
        pth = CGU.getPathNoRoot(path)
        for lk in self.links:
            if lk[3] == pth:
                return lk
        return False

    def fileHasChanged(self):
        dnow = {}
        self.readInfoFromOS(dnow)
        for k in dnow:
            if dnow[k] != self.infoData[k]:
                print(k, dnow[k], self.infoData[k])
                return True
        return False

    def readInfoFromOS(self, d):
        f = '%s/%s' % (self.filedir, self.filename)
        d['eFilename'] = f
        d['eDirSource'] = self.filedir
        d['eFileSource'] = self.filename
        d['eTmpFile'] = self.tmpfile
        d['eDepth'] = self.depth
        d['eNodes'] = self.nodes
        d['eVersion'] = str(self.version)
        d['eVersionHDF5'] = '???'
        try:
            st = os.stat(f)
            d['eFileSize'] = "%.3f Mb" % (1.0 * st[6] / (1024 * 1024))
            d['eMergeSize'] = "%.3f Mb" % (1.0 * st[6] / (1024 * 1024))
            dfmt = "%Y-%m-%d %H:%M"
            d['eLastDate'] = time.strftime(dfmt, time.localtime(int(st[7])))
            d['eModifDate'] = time.strftime(dfmt, time.localtime(int(st[8])))
            e = getpwuid(st[4])
            g = getgrgid(st[5])
            d['eOwner'] = e[0]
            d['eGroup'] = g[0]
            d['cNoFollow'] = False
            d['cHasLinks'] = (len(self.links) != 0)
            d['cSameFS'] = False
            d['cBadLinks'] = False
            d['cModeProp'] = False
            m = ""
            if st[0] & stat.S_IRUSR:
                m += "r"
            else:
                m += "-"
            if st[0] & stat.S_IWUSR:
                m += "w"
            else:
                m += "-"
            if st[0] & stat.S_IXUSR:
                m += "x"
            else:
                m += "-"
            if st[0] & stat.S_IRGRP:
                m += "r"
            else:
                m += "-"
            if st[0] & stat.S_IWGRP:
                m += "w"
            else:
                m += "-"
            if st[0] & stat.S_IXGRP:
                m += "x"
            else:
                m += "-"
            if st[0] & stat.S_IROTH:
                m += "r"
            else:
                m += "-"
            if st[0] & stat.S_IWOTH:
                m += "w"
            else:
                m += "-"
            if st[0] & stat.S_IXOTH:
                m += "x"
            else:
                m += "-"
            d['eRights'] = m
        except OSError:
            pass
        d['cConverted'] = self.converted
        d['cADF'] = self.converted
        d['cHDF5'] = not self.converted
        d['cREAD'] = not self.isSaveable()
        d['cMODIFY'] = self.isSaveable()
        d['cNODATA'] = False
        d['cHasInt64'] = False
        return d

    def getInfo(self, force=False):
        if force or not self.infoData:
            if self.isFile:
                self.readInfoFromOS(self.infoData)
            else:
                print('MEMORY TREE')
        return self.infoData

    def raiseControlView(self):
        self.control.show()
        self.control.raise_()

    def addChild(self, viewtype, view):
        Q7FingerPrint.__viewscounter += 1
        idx = Q7FingerPrint.__viewscounter
        if viewtype not in self.views:
            self.views[viewtype] = []
        self.views[viewtype].append((view, idx))
        return Q7FingerPrint.__viewscounter

    def closeView(self, i):
        idx = int(i)
        fg = self.getFingerPrint(idx)
        vw = self.getView(idx)
        if vw is not None:
            vt = self.getViewType(idx)
            if vt in self.views:
                self.views[vt].remove((vw, idx))
                if self.views[vt] == []:
                    del self.views[vt]
            vw.doRelease()
            vw.close()
        Q7FingerPrint.removeNoMoreView()

    def doRelease(self):
        self.model = None
        self.tree = None
        self.links = None

    def unlockAllViews(self):
        self.lockAllViews(lock=False)

    def lockAllViews(self, lock=True):
        vtlist = list(self.views)
        for vtype in vtlist:
            for (v, i) in self.views[vtype]:
                v.lockView(lock)

    def closeAllViews(self):
        vtlist = list(self.views)
        for vtype in vtlist:
            for (v, i) in self.views[vtype]:
                self.closeView(i)

    def isModified(self):
        return (Q7FingerPrint.STATUS_MODIFIED in self._status)

    def isSaveable(self):
        return (Q7FingerPrint.STATUS_SAVEABLE in self._status)

    def removeTreeStatus(self, status):
        if status not in Q7FingerPrint.STATUS_LIST:
            return
        if status in self._status:
            self._status.remove(status)
        self.control.updateViews()

    def addTreeStatus(self, status):
        if status not in Q7FingerPrint.STATUS_LIST:
            return
        if status not in self._status:
            self._status.append(status)
        self.control.updateViews()

    def pushGrammarPaths(self):
        if not OCTXT.ValKeyList:
            return
        tag = OCTXT.ValKeyList[0]
        pths = []
        self._oldsys = sys.path
        for p in OCTXT.GrammarSearchPathList:
            pths.append(str(p))
        for p in sys.path:
            pths.append(str(p))
        pths_uniq = []
        for p in pths:
            if p not in pths_uniq:
                pths_uniq.append(p)
        sys.path = pths_uniq

    def popGrammarPaths(self):
        sys.path = self._oldsys

    def nextGrammarTag(self):
        keyset = set(OCTXT.ValKeyList)
        keyset.add('SIDS')
        for t in keyset:
            yield t
Exemple #24
0
 def __init__(self, parent: QWidget) -> None:
     super(BaseThread, self).__init__(parent)
     self.finished.connect(self.deleteLater)
     self.is_stop = False
     self.mutex = QMutex()
Exemple #25
0
 def __init__(self):
     QThread.__init__(self)
     self.map_lock = QMutex()
     self.widget_map = dict()
Exemple #26
0
    def __init__(self, presenter, parent=None):
        """
        Initialise a new instance of PlotSelectorWidget
        :param presenter: The presenter controlling this view
        :param parent: Optional - the parent QWidget
        running as a unit test, in which case skip file dialogs
        """
        super(PlotSelectorView, self).__init__(parent)
        self.presenter = presenter

        # This mutex prevents multiple operations on the table at the
        # same time. Wrap code in - with QMutexLocker(self.mutex):
        self.mutex = QMutex()
        self.active_plot_number = -1

        self.show_button = QPushButton('Show')
        self.hide_button = QPushButton('Hide')
        # Note this button is labeled delete, but for consistency
        # with matplotlib 'close' is used in the code
        self.close_button = QPushButton('Delete')
        self.select_all_button = QPushButton('Select All')
        self.sort_button = self._make_sort_button()
        self.export_button = self._make_export_button()
        self.filter_box = self._make_filter_box()
        self.table_widget = self._make_table_widget()

        # Add the context menu
        self.table_widget.setContextMenuPolicy(Qt.CustomContextMenu)
        self.context_menu, self.export_menu = self._make_context_menu()
        self.table_widget.customContextMenuRequested.connect(
            self.context_menu_opened)

        buttons_layout = FlowLayout()
        buttons_layout.setSpacing(1)
        buttons_layout.addWidget(self.show_button)
        buttons_layout.addWidget(self.hide_button)
        buttons_layout.addWidget(self.close_button)
        buttons_layout.addWidget(self.select_all_button)
        buttons_layout.addWidget(self.sort_button)
        buttons_layout.addWidget(self.export_button)

        filter_layout = QHBoxLayout()
        filter_layout.addWidget(self.filter_box)

        layout = QVBoxLayout()
        layout.addLayout(buttons_layout)
        layout.addLayout(filter_layout)
        layout.addWidget(self.table_widget)
        # todo: Without the sizeHint() call the minimum size is not set correctly
        #       This needs some investigation as to why this is.
        layout.sizeHint()
        self.setLayout(layout)

        # Any updates that originate from the matplotlib figure
        # windows must be wrapped in a QAppThreadCall. Not doing this
        # WILL result in segfaults.
        self.set_plot_list_orig = self.set_plot_list
        self.set_plot_list = QAppThreadCall(self.set_plot_list_orig)
        self.append_to_plot_list_orig = self.append_to_plot_list
        self.append_to_plot_list = QAppThreadCall(
            self.append_to_plot_list_orig)
        self.remove_from_plot_list_orig = self.remove_from_plot_list
        self.remove_from_plot_list = QAppThreadCall(
            self.remove_from_plot_list_orig)
        self.rename_in_plot_list_orig = self.rename_in_plot_list
        self.rename_in_plot_list = QAppThreadCall(
            self.rename_in_plot_list_orig)
        self.set_active_font_orig = self.set_active_font
        self.set_active_font = QAppThreadCall(self.set_active_font_orig)
        self.set_visibility_icon_orig = self.set_visibility_icon
        self.set_visibility_icon = QAppThreadCall(
            self.set_visibility_icon_orig)
        self.set_last_active_values_orig = self.set_last_active_values
        self.set_last_active_values = QAppThreadCall(
            self.set_last_active_values_orig)
        self.sort_type_orig = self.sort_type
        self.sort_type = QAppThreadCall(self.sort_type_orig)

        # Connect presenter methods to things in the view
        self.show_button.clicked.connect(self.presenter.show_multiple_selected)
        self.hide_button.clicked.connect(self.presenter.hide_selected_plots)
        self.close_button.clicked.connect(self.presenter.close_action_called)
        self.select_all_button.clicked.connect(self.table_widget.selectAll)
        self.table_widget.doubleClicked.connect(
            self.presenter.show_single_selected)
        self.filter_box.textChanged.connect(self.presenter.filter_text_changed)
        self.deleteKeyPressed.connect(self.presenter.close_action_called)

        if DEBUG_MODE:
            self.table_widget.clicked.connect(self.show_debug_info)
 def __init__(self):
     self.buffer = []
     self.mutex = QMutex()
Exemple #28
0
    def __init__(self,
                 parent=None,
                 fname=None,
                 wdir=None,
                 history_filename=None,
                 show_icontext=True,
                 light_background=True,
                 menu_actions=None,
                 show_buttons_inside=True,
                 show_elapsed_time=True):
        QWidget.__init__(self, parent)

        self.menu_actions = menu_actions
        self.write_lock = QMutex()
        self.buffer_lock = QMutex()
        self.buffer = []

        self.run_button = None
        self.kill_button = None
        self.options_button = None
        self.icontext_action = None

        self.show_elapsed_time = show_elapsed_time

        self.fname = fname
        if wdir is None:
            wdir = osp.dirname(osp.abspath(fname))
        self.wdir = wdir if osp.isdir(wdir) else None
        self.arguments = ""

        self.shell = self.SHELL_CLASS(parent, get_conf_path(history_filename))
        self.shell.set_light_background(light_background)
        self.shell.execute.connect(self.send_to_process)
        self.shell.sig_keyboard_interrupt.connect(self.keyboard_interrupt)
        # Redirecting some SIGNALs:
        self.shell.redirect_stdio.connect(
            lambda state: self.redirect_stdio.emit(state))

        self.state_label = None
        self.time_label = None

        vlayout = QVBoxLayout()
        toolbar_buttons = self.get_toolbar_buttons()
        if show_buttons_inside:
            self.state_label = QLabel()
            hlayout = QHBoxLayout()
            hlayout.addWidget(self.state_label)
            hlayout.addStretch(0)
            hlayout.addWidget(self.create_time_label())
            hlayout.addStretch(0)
            for button in toolbar_buttons:
                hlayout.addWidget(button)
            vlayout.addLayout(hlayout)
        else:
            vlayout.setContentsMargins(0, 0, 0, 0)
        vlayout.addWidget(self.get_shell_widget())
        self.setLayout(vlayout)
        self.resize(640, 480)
        if parent is None:
            self.setWindowIcon(self.get_icon())
            self.setWindowTitle(_("Console"))

        self.t0 = None
        self.timer = QTimer(self)

        self.process = None

        self.is_closing = False

        if show_buttons_inside:
            self.update_time_label_visibility()
Exemple #29
0
 def __init__(self, obj: T):
     super().__init__()
     self.obj = obj
     self.lock = QMutex()
 def __init__(self, worker_id: int):
     super(PMGThreadWorker, self).__init__()
     self.quit = False
     self.id = worker_id
     self.mutex = QMutex()
     self.wait_condition = QWaitCondition()