Exemplo n.º 1
0
    def __init__(self, items, default="name", parent=None):
        QtGui.QWidget.__init__(self, parent)
        QtGui.QVBoxLayout(self)
        self.__default = default

        self.setMaximumHeight(200)

        self.list_widget = QtGui.QListWidget(self)
        self.list_widget.itemDoubleClicked.connect(self.list_widget.editItem)
        for item in (items or []):
            list_item = self.__newItem(item)
            self.list_widget.addItem(list_item)
        self.list_widget.sortItems()

        self.btn_add = QtGui.QPushButton(QtGui.QIcon(":/images/plus.png"), "",
                                         self)
        self.btn_add.setFlat(True)
        self.btn_add.clicked.connect(self.addItem)
        self.btn_sub = QtGui.QPushButton(QtGui.QIcon(":/images/minus.png"), "",
                                         self)
        self.btn_sub.setFlat(True)
        self.btn_sub.clicked.connect(self.removeItems)

        layout_btn = QtGui.QHBoxLayout()
        layout_btn.setContentsMargins(0, 0, 0, 0)
        layout_btn.setSpacing(1)
        layout_btn.addStretch()
        layout_btn.addWidget(self.btn_add)
        layout_btn.addWidget(self.btn_sub)

        self.layout().addWidget(self.list_widget)
        self.layout().addLayout(layout_btn)
Exemplo n.º 2
0
    def init(self):
        titleBar = self.titleBarWidget()
        titleBar.addAction(QtGui.QIcon(":/images/locked.png"),
                           "Lock Selected Clusters",
                           partial(self.__setNodesLocked, True))

        titleBar.addAction(QtGui.QIcon(":/images/unlocked.png"),
                           "Unlock Selected Clusters",
                           partial(self.__setNodesLocked, False))
Exemplo n.º 3
0
 def __showContextMenu(self, pos):
     menu = QtGui.QMenu()
     menu.addAction(QtGui.QIcon(":/images/retry.png"), "Retry",
                    self.retrySelected)
     menu.addAction(QtGui.QIcon(":/images/kill.png"), "Kill",
                    self.killSelected)
     menu.addAction(QtGui.QIcon(":/images/eat.png"), "Eat",
                    self.eatSelected)
     menu.exec_(self.mapToGlobal(pos))
Exemplo n.º 4
0
    def init(self):
        # TODO
        # comment button (multi-select)
        #
        self.titleBarWidget().addAction(QtGui.QIcon(":/images/load.png"),
                                        "Load", self.openLoadDialog)

        self.titleBarWidget().addAction(QtGui.QIcon(":/images/sweep.png"),
                                        "Remove Finished Jobs",
                                        self.removeFinishedJobs)
Exemplo n.º 5
0
    def init(self):
        titleBar = self.titleBarWidget() 
        titleBar.addAction(QtGui.QIcon(":/images/locked.png"), 
                                       "Lock Selected Nodes", 
                                       partial(self.__setNodesLocked, True))

        titleBar.addAction(QtGui.QIcon(":/images/unlocked.png"), 
                                       "Unlock Selected Nodes", 
                                       partial(self.__setNodesLocked, False))

        self.__cluster_filter = CheckableComboBox("Clusters", [], parent=self)
        titleBar.addWidget(self.__cluster_filter)
        self.__cluster_filter.optionSelected.connect(self.__clusterFilterChanged)
Exemplo n.º 6
0
    def __showContextMenu(self, pos):
        menu = QtGui.QMenu()

        total = self.__selectedCount()
        if 1 <= total <= 2:
            icon = QtGui.QIcon(":/images/depend.png")
            depend = menu.addAction(icon, "Add Dependencies",
                                    self.__addDepends)

        menu.addAction(QtGui.QIcon(":/images/depend.png"), "Drop Depends",
                       self.__dropDepends)

        menu.exec_(self.mapToGlobal(pos))
Exemplo n.º 7
0
    def __showContextMenu(self, pos):
        menu = QtGui.QMenu(self)

        cluster_menu = menu.addMenu("Set Cluster")
        for name, cluster in sorted(self.__clusters.iteritems()):
            action = cluster_menu.addAction(name)
            action.triggered.connect(partial(self.assignClusterToSelected, cluster))

        menu.addAction(QtGui.QIcon(":/images/locked.png"), 
                        "Lock Nodes", partial(self.lockSelected, True))
        menu.addAction(QtGui.QIcon(":/images/unlocked.png"), 
                        "Unlock Nodes", partial(self.lockSelected, False))

        self.__refreshEnabled = False
        menu.exec_(self.mapToGlobal(pos))
        self.__refreshEnabled = True
Exemplo n.º 8
0
    def __init__(self, name, ptype, parent=None):
        QtGui.QDockWidget.__init__(self, parent)

        # Add the standard dock action buttons in.
        # TODO: hook up signals
        self.__label = QtGui.QLabel(self)
        self.__label.setIndent(10)
        self.__name = None
        self.__ptype = ptype
        self.setName(name)

        self.attrs = {}

        self.__refreshTimer = None

        # Note: the widet in the panel adds more buttons
        # to this toolbar.
        titleBar = QtGui.QWidget(self)
        barLayout = QtGui.QHBoxLayout(titleBar)
        barLayout.setSpacing(0)
        barLayout.setContentsMargins(0, 0, 0, 0)

        self.__toolbar = toolbar = QtGui.QToolBar(self)
        toolbar.setIconSize(QtCore.QSize(18, 18))
        toolbar.addAction(QtGui.QIcon(":/images/close.png"), "Close",
                          self.__close)

        float_action = QtGui.QAction(QtGui.QIcon(":/images/float.png"),
                                     "Float", self)
        float_action.toggled.connect(self.__floatingChanged)
        float_action.setCheckable(True)
        toolbar.addAction(float_action)

        config_action = QtGui.QAction(QtGui.QIcon(":/images/config.png"),
                                      "Configure Panel", self)
        config_action.triggered.connect(self._openPanelSettingsDialog)
        toolbar.addAction(config_action)

        toolbar.addSeparator()

        barLayout.addWidget(toolbar)
        barLayout.addStretch()
        barLayout.addWidget(self.__label)
        barLayout.addSpacing(4)

        self.setTitleBarWidget(titleBar)
        self.init()
Exemplo n.º 9
0
    def __init__(self, parent=None):
        QtCore.QAbstractTableModel.__init__(self, parent)
        self.__items = plow.client.get_clusters()
        self.__index = dict([(item.id, i)
                             for i, item in enumerate(self.__items)])
        self.__lastUpdateTime = 0

        self.__iconLocked = QtGui.QIcon(":/images/locked.png")
Exemplo n.º 10
0
    def __showContextMenu(self, pos):
        menu = QtGui.QMenu()
        menu.addAction(QtGui.QIcon(":/images/retry.png"), "Retry",
                       self.retrySelected)
        menu.addAction(QtGui.QIcon(":/images/kill.png"), "Kill",
                       self.killSelected)
        menu.addAction(QtGui.QIcon(":/images/eat.png"), "Eat",
                       self.eatSelected)

        total = self.__selectedCount()
        if 1 <= total <= 2:
            icon = QtGui.QIcon(":/images/depend.png")
            depend = menu.addAction(icon, "Add Dependencies",
                                    self.__addDepends)

        menu.addAction(QtGui.QIcon(":/images/depend.png"), "Drop Depends",
                       self.__dropDepends)

        menu.exec_(self.mapToGlobal(pos))
Exemplo n.º 11
0
    def init(self):
        # TODO
        # sweep button (remove finished)
        # refresh button
        # seperator
        # kill button (multi-select)
        # comment button (multi-select)
        #
        titleBar = self.titleBarWidget()
        titleBar.addAction(QtGui.QIcon(":/images/settings.png"),
                           "Edit Selected Cluster Configuration",
                           self.openClusterPropertiesDialog)

        titleBar.addAction(QtGui.QIcon(":/images/locked.png"),
                           "Lock Selected Clusters",
                           partial(self.__setClusterLocked, True))

        titleBar.addAction(QtGui.QIcon(":/images/unlocked.png"),
                           "Unlock Selected Clusters",
                           partial(self.__setClusterLocked, False))
Exemplo n.º 12
0
    def __init__(self, text, help, parent=None):
        QtGui.QWidget.__init__(self, parent)
        QtGui.QHBoxLayout(self)
        self.__help = help

        self.__btn = QtGui.QToolButton(self)
        self.__btn.setIcon(QtGui.QIcon(":/images/help.png"))
        self.__btn.setFocusPolicy(QtCore.Qt.NoFocus)
        self.__btn.clicked.connect(self.__show_popup)
        self.__btn.setStyleSheet("QToolButton { border: 0px }")

        self.__label = QtGui.QLabel(text, self)

        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(0)

        self.layout().addWidget(self.__btn)
        self.layout().addSpacing(5)
        self.layout().addWidget(self.__label)
        self.layout().addStretch()
Exemplo n.º 13
0
    def __init__(self, jobs, refreshCallback=None, parent=None):
        super(JobContextMenu, self).__init__(parent)

        if not isinstance(jobs, (tuple, set, list, dict)):
            jobs = [jobs]

        self.__jobs = jobs
        self.__callback = refreshCallback

        total = len(jobs)
        plural = 's' if total > 1 else ''
        isPaused = jobs[0].paused

        pause = self.addAction(QtGui.QIcon(":/images/pause.png"),
                               "Un-Pause" if isPaused else "Pause")
        kill = self.addAction(QtGui.QIcon(":/images/kill.png"),
                              "Kill Job%s" % plural)

        if 1 <= total <= 2:
            depend = self.addAction(QtGui.QIcon(":/images/depend.png"),
                                    "Add Dependencies")
            depend.triggered.connect(
                partial(actions.launchDependsWizard, jobs, parent))

        drop = self.addAction(QtGui.QIcon(":/images/depend.png"),
                              "Drop Depends")

        self.addSeparator()

        kill_tasks = self.addAction(QtGui.QIcon(":/images/kill.png"),
                                    "Kill Tasks")
        eat_tasks = self.addAction(QtGui.QIcon(":/images/eat.png"),
                                   "Eat Dead Tasks")
        retry_tasks = self.addAction(QtGui.QIcon(":/images/retry.png"),
                                     "Retry Dead Tasks")

        #
        # Connections
        #
        cbk = partial(self._action_on_tasks,
                      plow.client.eat_tasks,
                      jobs,
                      dead=True)
        eat_tasks.triggered.connect(cbk)

        cbk = partial(self._action_on_tasks,
                      plow.client.retry_tasks,
                      jobs,
                      dead=True)
        retry_tasks.triggered.connect(cbk)

        cbk = partial(self._action_on_tasks,
                      plow.client.kill_tasks,
                      jobs,
                      dead=False)
        kill_tasks.triggered.connect(cbk)

        pause.triggered.connect(partial(self._pause, jobs, not isPaused))
        kill.triggered.connect(partial(self._kill, jobs))
        drop.triggered.connect(
            partial(actions.dropDepends, jobs, ask=True, parent=parent))
Exemplo n.º 14
0
    def __init__(self, filt=None, items=None, data=None, parent=None):
        super(FilterableListBox, self).__init__(parent)

        self.__data = {}

        height = 20

        self.__txt_label = QtGui.QLabel(self)
        self.__txt_filter = QtGui.QLineEdit(self)
        self.__txt_filter.setFixedHeight(height)
        self.__txt_filter.textChanged.connect(self.__filterChanged)

        self.__txt_clear = btn = QtGui.QPushButton(self)
        btn.setIcon(QtGui.QIcon(":/images/delete.png"))
        btn.setFlat(True)
        btn.setFixedSize(height, height)
        btn.setIconSize(QtCore.QSize(14, 14))
        btn.setVisible(False)

        self.__model = QtGui.QStringListModel(self)

        self.__proxyModel = proxy = QtGui.QSortFilterProxyModel(self)
        proxy.setSourceModel(self.__model)

        self.__list = view = QtGui.QListView(self)
        view.setSelectionMode(self.__list.ExtendedSelection)
        view.setModel(proxy)

        proxy.sort(0)
        proxy.setDynamicSortFilter(True)

        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(4)
        layout.setContentsMargins(0, 0, 0, 0)

        hlayout = QtGui.QHBoxLayout()
        hlayout.setSpacing(0)
        hlayout.setContentsMargins(0, 0, 0, 0)
        hlayout.addWidget(self.__txt_label)
        hlayout.addSpacing(2)
        hlayout.addWidget(self.__txt_filter)
        hlayout.addWidget(self.__txt_clear)

        layout.addLayout(hlayout)
        layout.addWidget(self.__list)

        # connections
        self.__list.doubleClicked.connect(self._itemDoubleClicked)
        self.__list.clicked.connect(self._itemClicked)

        self.__selModel = self.__list.selectionModel()
        self.__selModel.selectionChanged.connect(self._selectionChanged)

        self.__txt_filter.textChanged.connect(
            lambda v: self.__txt_clear.setVisible(bool(v)))
        self.__txt_clear.clicked.connect(lambda: self.setFilter(''))

        if items:
            self.setStringList(items)

        if filt:
            self.setFilter(filt)
Exemplo n.º 15
0
    def __init__(self, parent=None):
        super(ClusterModel, self).__init__(parent)

        self.__lastUpdateTime = 0
        self.__iconLocked = QtGui.QIcon(":/images/locked.png")
Exemplo n.º 16
0
def jobContextMenu(jobs, refreshCallback=None, parent=None):
    """
    Get a job context QMenu with common operations
    """
    menu = QtGui.QMenu(parent)

    if not isinstance(jobs, (tuple, set, list, dict)):
        jobs = [jobs]

    total = len(jobs)
    isPaused = jobs[0].paused

    pause = menu.addAction(QtGui.QIcon(":/images/pause.png"),
                           "Un-Pause" if isPaused else "Pause")
    kill = menu.addAction(QtGui.QIcon(":/images/kill.png"),
                          "Kill Job%s" % 's' if total else '')

    menu.addSeparator()

    kill_tasks = menu.addAction(QtGui.QIcon(":/images/kill.png"), "Kill Tasks")
    eat_tasks = menu.addAction(QtGui.QIcon(":/images/eat.png"),
                               "Eat Dead Tasks")
    retry_tasks = menu.addAction(QtGui.QIcon(":/images/retry.png"),
                                 "Retry Dead Tasks")

    def action_on_tasks(fn, job_list, dead=False):
        if dead:
            states = [plow.client.TaskState.DEAD]
        else:
            states = []

        tasks = list(
            chain.from_iterable(j.get_tasks(states=states) for j in job_list))

        if not tasks:
            return

        msg = "Run %r on %d jobs  (%d tasks) ?" % (fn.__name__, len(job_list),
                                                   len(tasks))
        if not ask(msg, parent=parent):
            return

        if tasks:
            fn(tasks=tasks)
            if refreshCallback:
                refreshCallback()

    eat_tasks.triggered.connect(
        partial(action_on_tasks, plow.client.eat_tasks, jobs, dead=True))

    retry_tasks.triggered.connect(
        partial(action_on_tasks, plow.client.retry_tasks, jobs, dead=True))

    kill_tasks.triggered.connect(
        partial(action_on_tasks, plow.client.kill_tasks, jobs, dead=False))

    def pause_fn(job_list, pause):
        for j in job_list:
            j.pause(pause)

        if refreshCallback:
            refreshCallback()

    pause.triggered.connect(partial(pause_fn, jobs, not isPaused))

    def kill_fn(job_list):
        if not ask("Kill %d job(s) ?" % len(job_list), parent=parent):
            return

        for j in job_list:
            j.kill('plow-wrangler')

        if refreshCallback:
            refreshCallback()

    kill.triggered.connect(partial(kill_fn, jobs))

    return menu
Exemplo n.º 17
0
    def __init__(self, job=None, task=None, attrs=None, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.__task = None
        self.__log_file = QtCore.QFile()
        self.__log_stream = QtCore.QTextStream()

        openAction = QtGui.QAction("Open Log File", self)
        openAction.setShortcut(QtGui.QKeySequence.Open)
        self.addAction(openAction)

        self.__searchLine = QtGui.QLineEdit(self)
        self.__chk_tail = QtGui.QAction("Tail log", self)
        self.__chk_tail.setCheckable(True)

        self.__findPrevBtn = prev = QtGui.QAction(self)
        prev.setToolTip("Find Previous Match")
        prev.setIcon(QtGui.QIcon(":/images/left_arrow.png"))

        self.__findNextBtn = nxt = QtGui.QAction(self)
        nxt.setToolTip("Find Next Match")
        nxt.setIcon(QtGui.QIcon(":/images/right_arrow.png"))

        self.__jobNameLabel = label = QtGui.QLabel(self)
        label.setIndent(10)
        # label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        label.hide()
        self.__jobNameSpacer = QtGui.QWidget(self)
        self.__jobNameSpacer.setFixedHeight(6)
        self.__jobNameSpacer.hide()

        def spacer(width):
            w = QtGui.QWidget()
            w.setFixedWidth(width)
            return w

        stretch = QtGui.QWidget()
        stretch.setSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Preferred)

        self.__toolbar = tb = QtGui.QToolBar(self)
        tb.addWidget(spacer(4))
        tb.addWidget(QtGui.QLabel("Find: ", self))
        tb.addWidget(self.__searchLine)
        tb.addAction(self.__findPrevBtn)
        tb.addAction(self.__findNextBtn)
        tb.addWidget(stretch)
        tb.addAction(self.__chk_tail)
        tb.addWidget(spacer(4))

        self.__view = view = QtGui.QPlainTextEdit(self)
        font = view.font()
        font.setPixelSize(DEFAULT_FONT_SIZE)
        view.setFont(font)
        view.setLineWrapMode(view.WidgetWidth)
        view.setReadOnly(True)
        view.setMaximumBlockCount(1000000)
        # self.__view.setFocusPolicy(QtCore.Qt.NoFocus)

        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.__toolbar)
        layout.addWidget(self.__jobNameLabel)
        layout.addWidget(self.__jobNameSpacer)
        layout.addWidget(self.__view)

        self.__highlighter = TextHighlighter(view.document())
        self.__logWatcher = FileWatcher(self)

        # Connections
        self.__logWatcher.fileChanged.connect(self.__logUpdated)
        self.__chk_tail.toggled.connect(self.__logTailToggled)
        self.__searchLine.textChanged.connect(self.findText)
        self.__searchLine.returnPressed.connect(self.findNext)
        self.__findPrevBtn.triggered.connect(self.findPrev)
        self.__findNextBtn.triggered.connect(self.findNext)
        openAction.triggered.connect(self.openLogFile)

        # Optional args
        if job:
            self.setJobName(job.name)

        if task:
            self.setCurrentTask(task)
Exemplo n.º 18
0
    def init(self):

        self.titleBarWidget().addAction(QtGui.QIcon(":/images/retry.png"),
                                        "Refresh", self.refresh)
Exemplo n.º 19
0
    def __init__(self, project, *args, **kwargs):
        super(FilterManager, self).__init__(*args, **kwargs)

        self._projectLabel = QtGui.QLabel(self)

        self._filtersList = filt = FiltersList(parent=self)
        self._matchersList = match = MatchersList(parent=self)
        self._actionsList = act = ActionsList(parent=self)

        self._toolbar = tb = QtGui.QToolBar(self)
        tb.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        tb.setMaximumHeight(32)
        tb.addAction(QtGui.QIcon(":/images/refresh.png"), "Refresh", self.refresh)

        self._status = QtGui.QStatusBar(self)

        h_splitter = QtGui.QSplitter(QtCore.Qt.Horizontal, self)
        h_splitter.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)

        v_splitter = QtGui.QSplitter(QtCore.Qt.Vertical, self)

        v_splitter.addWidget(self._matchersList)
        v_splitter.addWidget(self._actionsList)

        h_splitter.addWidget(self._filtersList)
        h_splitter.addWidget(v_splitter)

        tbLayout = QtGui.QHBoxLayout()
        tbLayout.setContentsMargins(0, 0, 4, 0)
        tbLayout.addWidget(self._toolbar)
        tbLayout.addWidget(self._projectLabel)

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(6, 0, 6, 4)
        layout.setSpacing(2)

        layout.addLayout(tbLayout)
        layout.addWidget(h_splitter)
        layout.addWidget(self._status)

        v_splitter.setSizes([100,100])
        h_splitter.setSizes([100,100])

        self.setStyleSheet("""
            DragDropItem {
                border: 1px solid black;
                border-radius: 4px;
                background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, 
                                                  stop: 0 rgb(40, 40, 40), 
                                                  stop: 1 rgb(27, 28, 30) );
            }
            DragDropItem:checked {
                border: 1px solid rgb(100,100,100);
                background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, 
                                                  stop: 1 rgb(40, 40, 40), 
                                                  stop: 0 rgb(27, 28, 30) );                
            }
            """)

        self.setProject(project)

        # Connnections
        filt.filterSelected.connect(match.setFilterObject)
        filt.filterSelected.connect(act.setFilterObject)