Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Merge 18f7c83 into 71f3de7
Browse files Browse the repository at this point in the history
  • Loading branch information
Joelgranados committed Nov 24, 2014
2 parents 71f3de7 + 18f7c83 commit 72f2868
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 95 deletions.
112 changes: 88 additions & 24 deletions scripts/run-pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,84 @@ def __init__(self, opts):
# buttons
self._ui.bCancel.clicked.connect(self._cancelRunPipeline)
self._ui.bRunPipe.clicked.connect(self._runPipeline)
self._ui.bAddInput.clicked.connect(self._addInput)
self._ui.bAddOutput.clicked.connect(self._addOutput)
self._ui.bPipeConfig.clicked.connect(self._addPipeline)
self._ui.bTSConfig.clicked.connect(self._addTimeStream)

# pipeline thread
self._plthread = None
self._ui.show()

def _addDir(self):
D = QtGui.QFileDialog.getExistingDirectory(
self, "Select Directory", "",
QtGui.QFileDialog.ShowDirsOnly
| QtGui.QFileDialog.DontResolveSymlinks)
if D == "": # Handle the cancel
return ""

D = os.path.realpath(str(D))
if not os.path.isdir(D):
errmsg = QtGui.QErrorMessage(self)
errmsg.showMessage("Directory {} does not exist".format(D))
return ""
else:
return D

def _addFile(self):
F = QtGui.QFileDialog.getOpenFileName(
self, "Select YAML configuration", "", "CSV (*.yml *.yaml)")
if F == "":
return ""

if not os.path.isfile(F):
errmsg = QtGui.QErrorMessage(self)
errmsg.showMessage("{} is not a file".format(F))
return ""
else:
return F

def _addInput(self):
tsdir = self._addDir()
if tsdir != "":
self._opts["-i"] = str(tsdir)
self._ui.leInput.setText(str(tsdir))
else:
del(self._opts["-i"])
self._ui.leInput.setText("")
return tsdir

def _addOutput(self):
outdir = self._addDir()
if outdir != "":
self._opts["-o"] = str(outdir)
self._ui.leOutput.setText(str(outdir))
else:
del(self._opts["-o"])
self._ui.leOutput.setText("Default")
return outdir

def _addPipeline(self):
plfile = self._addFile()
if plfile != "":
self._opts["-p"] = str(plfile)
self._ui.lePipeConfig.setText(str(plfile))
else:
del(self._opts["-p"])
self._ui.lePipeConfig.setText("Default")
return plfile

def _addTimeStream(self):
tsfile = self._addFile()
if tsfile != "":
self._opts["-t"] = str(tsfile)
self._ui.leTSConfig.setText(str(tsfile))
else:
del(self._opts["-t"])
self._ui.leTSConfig.setText("Default")
return tsfile

def _cancelRunPipeline(self):
if self._plthread is not None:
self._plthread.setRunning(False)
Expand All @@ -413,35 +486,26 @@ def _updateProgress(self, i):
QtGui.qApp.processEvents()

def _runPipeline(self):
if self._plthread is not None and self._plthread.running:
if self._plthread is not None and self._plthread._running:
return

tsdir = QtGui.QFileDialog.getExistingDirectory(self, \
"Select Time Stream", "", \
QtGui.QFileDialog.ShowDirsOnly \
| QtGui.QFileDialog.DontResolveSymlinks)
if tsdir == "": # Handle the cancel
return
if "-i" not in self._opts.keys() or self._opts["-i"] is None:
retVal = self._addInput()
if retVal == "":
return

try:
tsdir = os.path.realpath(str(tsdir))
if not os.path.isdir(tsdir):
raise RuntimeError("Directory {} does not exist".format(tsdir))
self._opts["-i"] = tsdir

# log to QTextEdit
stream = PipelineRunnerGUI.TextEditStream(self.tesig.sig)
outlog = timestream.add_log_handler(stream=stream,
verbosity=timestream.LOGV.VV)
if outlog is os.devnull:
raise RuntimeError("Error setting up output to TextEdit")
LOG = logging.getLogger("timestreamlib")

plConf, ctx, pl, ts = initPipeline(LOG, self._opts)
except RuntimeError as re:
# log to QTextEdit
stream = PipelineRunnerGUI.TextEditStream(self.tesig.sig)
outlog = timestream.add_log_handler(
stream=stream,
verbosity=timestream.LOGV.VV)
if outlog is os.devnull:
errmsg = QtGui.QErrorMessage(self)
errmsg.showMessage(str(re))
errmsg.showMessage("Error setting up output to TextEdit")
return
LOG = logging.getLogger("timestreamlib")

plConf, ctx, pl, ts = initPipeline(LOG, self._opts)

self._ui.pbpl.setVisible(True)
self._ui.bCancel.setVisible(True)
Expand Down
90 changes: 87 additions & 3 deletions scripts/run-pipeline.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,91 @@
<widget class="QTextEdit" name="teOutput"/>
</item>
<item>
<layout class="QHBoxLayout" name="h1">
<layout class="QHBoxLayout" name="h3">
<item>
<widget class="QPushButton" name="bRunPipe">
<widget class="QPushButton" name="bAddInput">
<property name="text">
<string>Run Pipeline</string>
<string>Input Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leInput">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="h4">
<item>
<widget class="QPushButton" name="bAddOutput">
<property name="text">
<string>Output Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leOutput">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="h5">
<item>
<widget class="QPushButton" name="bPipeConfig">
<property name="text">
<string>Pipeline Config</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lePipeConfig">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="h6">
<item>
<widget class="QPushButton" name="bTSConfig">
<property name="text">
<string>Timestream Config</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leTSConfig">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="h1">
<item>
<spacer name="hs1">
<property name="orientation">
Expand All @@ -40,6 +117,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="bRunPipe">
<property name="text">
<string>Run Pipeline</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
2 changes: 1 addition & 1 deletion timestream/manipulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, cls, attrKey=None):
cls.actName, cls.info())
if attrKey is not None:
self.message = self.message + \
" Error: missing entry for '%s'" % attrKey
" Error: entry '%s'" % attrKey


class PCExBadConfig(PCException):
Expand Down
3 changes: 3 additions & 0 deletions timestream/manipulate/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ def createSection(cls, confElems, depth, name):
for i in range(len(confElems)):
retVal.addSubSec("_%d" % i, confElems[i])

elif confElems is None:
retVal = PCFGSection(name) # An empty node

else:
# We stop. Even depth == 0 has not been reached.
retVal = confElems
Expand Down
Loading

0 comments on commit 72f2868

Please sign in to comment.