master,gui: show Git commit messages in schedule

This commit is contained in:
Sebastien Bourdeauducq 2015-08-08 11:08:04 +08:00
parent be55487d2d
commit 54d85efc2a
4 changed files with 48 additions and 22 deletions

View File

@ -5,7 +5,7 @@ from quamash import QtGui, QtCore
from pyqtgraph import dockarea from pyqtgraph import dockarea
from artiq.protocols.sync_struct import Subscriber from artiq.protocols.sync_struct import Subscriber
from artiq.gui.tools import DictSyncModel from artiq.gui.tools import elide, DictSyncModel
class _ScheduleModel(DictSyncModel): class _ScheduleModel(DictSyncModel):
@ -37,7 +37,10 @@ class _ScheduleModel(DictSyncModel):
elif column == 5: elif column == 5:
expid = v["expid"] expid = v["expid"]
if "repo_rev" in expid: if "repo_rev" in expid:
return expid["repo_rev"] r = expid["repo_rev"]
if v["repo_msg"]:
r += "\n" + elide(v["repo_msg"], 40)
return r
else: else:
return "Outside repo." return "Outside repo."
elif column == 6: elif column == 6:
@ -63,6 +66,8 @@ class ScheduleDock(dockarea.Dock):
self.table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.table.horizontalHeader().setResizeMode( self.table.horizontalHeader().setResizeMode(
QtGui.QHeaderView.ResizeToContents) QtGui.QHeaderView.ResizeToContents)
self.table.verticalHeader().setResizeMode(
QtGui.QHeaderView.ResizeToContents)
self.addWidget(self.table) self.addWidget(self.table)
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

View File

@ -1,12 +1,24 @@
from quamash import QtCore from quamash import QtCore
def force_spinbox_value(spinbox, value): def elide(s, maxlen):
if spinbox.minimum() > value: elided = False
spinbox.setMinimum(value) if len(s) > maxlen:
if spinbox.maximum() < value: s = s[:maxlen]
spinbox.setMaximum(value) elided = True
spinbox.setValue(value) try:
idx = s.index("\n")
except ValueError:
pass
else:
s = s[:idx]
elided = True
if elided:
maxlen -= 3
if len(s) > maxlen:
s = s[:maxlen]
s += "..."
return s
def short_format(v): def short_format(v):
@ -16,10 +28,7 @@ def short_format(v):
if t is int or t is float: if t is int or t is float:
return str(v) return str(v)
elif t is str: elif t is str:
if len(v) < 15: return "\"" + elide(v, 15) + "\""
return "\"" + v + "\""
else:
return "\"" + v[:12] + "\"..."
else: else:
r = t.__name__ r = t.__name__
if t is list or t is dict or t is set: if t is list or t is dict or t is set:
@ -27,6 +36,14 @@ def short_format(v):
return r return r
def force_spinbox_value(spinbox, value):
if spinbox.minimum() > value:
spinbox.setMinimum(value)
if spinbox.maximum() < value:
spinbox.setMaximum(value)
spinbox.setValue(value)
class _SyncSubstruct: class _SyncSubstruct:
def __init__(self, update_cb, ref): def __init__(self, update_cb, ref):
self.update_cb = update_cb self.update_cb = update_cb

View File

@ -70,7 +70,7 @@ class Repository:
self._scanning = True self._scanning = True
new_head_rev = self.backend.get_head_rev() new_head_rev = self.backend.get_head_rev()
wd = self.backend.request_rev(new_head_rev) wd, _ = self.backend.request_rev(new_head_rev)
self.backend.release_rev(self.head_rev) self.backend.release_rev(self.head_rev)
self.head_rev = new_head_rev self.head_rev = new_head_rev
new_explist = yield from _scan_experiments(wd, self.log_fn) new_explist = yield from _scan_experiments(wd, self.log_fn)
@ -90,7 +90,7 @@ class FilesystemBackend:
return "N/A" return "N/A"
def request_rev(self, rev): def request_rev(self, rev):
return self.root return self.root, None
def release_rev(self, rev): def release_rev(self, rev):
pass pass
@ -99,7 +99,9 @@ class FilesystemBackend:
class _GitCheckout: class _GitCheckout:
def __init__(self, git, rev): def __init__(self, git, rev):
self.path = tempfile.mkdtemp() self.path = tempfile.mkdtemp()
git.checkout_tree(git.get(rev), directory=self.path) commit = git.get(rev)
git.checkout_tree(commit, directory=self.path)
self.message = commit.message.strip()
self.ref_count = 1 self.ref_count = 1
logger.info("checked out revision %s into %s", rev, self.path) logger.info("checked out revision %s into %s", rev, self.path)
@ -126,7 +128,7 @@ class GitBackend:
else: else:
co = _GitCheckout(self.git, rev) co = _GitCheckout(self.git, rev)
self.checkouts[rev] = co self.checkouts[rev] = co
return co.path return co.path, co.message
def release_rev(self, rev): def release_rev(self, rev):
co = self.checkouts[rev] co = self.checkouts[rev]

View File

@ -48,7 +48,7 @@ def _mk_worker_method(name):
class Run: class Run:
def __init__(self, rid, pipeline_name, def __init__(self, rid, pipeline_name,
wd, expid, priority, due_date, flush, wd, expid, priority, due_date, flush,
worker_handlers, notifier): worker_handlers, notifier, **kwargs):
# called through pool # called through pool
self.rid = rid self.rid = rid
self.pipeline_name = pipeline_name self.pipeline_name = pipeline_name
@ -62,8 +62,7 @@ class Run:
self._status = RunStatus.pending self._status = RunStatus.pending
self._notifier = notifier notification = {
self._notifier[self.rid] = {
"pipeline": self.pipeline_name, "pipeline": self.pipeline_name,
"expid": self.expid, "expid": self.expid,
"priority": self.priority, "priority": self.priority,
@ -71,6 +70,9 @@ class Run:
"flush": self.flush, "flush": self.flush,
"status": self._status.name "status": self._status.name
} }
notification.update(kwargs)
self._notifier = notifier
self._notifier[self.rid] = notification
@property @property
def status(self): def status(self):
@ -142,11 +144,11 @@ class RunPool:
if "repo_rev" in expid: if "repo_rev" in expid:
if expid["repo_rev"] is None: if expid["repo_rev"] is None:
expid["repo_rev"] = self._repo_backend.get_head_rev() expid["repo_rev"] = self._repo_backend.get_head_rev()
wd = self._repo_backend.request_rev(expid["repo_rev"]) wd, repo_msg = self._repo_backend.request_rev(expid["repo_rev"])
else: else:
wd = None wd, repo_msg = None, None
run = Run(rid, pipeline_name, wd, expid, priority, due_date, flush, run = Run(rid, pipeline_name, wd, expid, priority, due_date, flush,
self._worker_handlers, self._notifier) self._worker_handlers, self._notifier, repo_msg=repo_msg)
self.runs[rid] = run self.runs[rid] = run
if self.submitted_cb is not None: if self.submitted_cb is not None:
self.submitted_cb() self.submitted_cb()