Skip to content

Commit

Permalink
Added gscan.rc config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed May 12, 2016
1 parent 73b7209 commit ea6d17d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/cug.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7083,6 +7083,10 @@ \subsection{Inlined Task Scripting}

\pagebreak

\input{gscanrc.tex}

\pagebreak


\section{Command Reference}
\label{CommandReference}
Expand Down
37 changes: 37 additions & 0 deletions doc/gscanrc.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

\section{Cylc Gscan Config File Reference}
\label{GscanRCReference}

\lstset{language=bash}

This section defines all legal items and values for the gscan config
file which should be located in
\lstinline=$HOME/.cylc/gscan.rc=.

\subsection{Top Level Items}

\subsubsection{columns}
Set the data fields displayed initially when the
\lstinline=cylc gscan=
GUI starts. This
can be changed later using the right click context menu.

\begin{myitemize}
\item {\em type:} string (a list of one or more view names)
\item {\em legal values:} ``host'', ``status'', ``suite'', ``title'',
``updated''
\item {\em default:} ``status'', ``suite''
\item {\em example:} \lstinline@columns = suite, title, status@
\end{myitemize}

\subsubsection{activate on startup}
Set whether
\lstinline=cylc gpanel=
will activate automatically when the gui is loaded or not.

\begin{myitemize}
\item {\em type:} boolean (True or False)
\item {\em legal values:} ``True'', ``False''
\item {\em default:} ``False''
\item {\em example:} \lstinline@activate on startup = True@
\end{myitemize}
63 changes: 63 additions & 0 deletions lib/cylc/cfgspec/gscan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python

# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2016 NIWA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import sys

from parsec import ParsecError
from parsec.validate import validator as vdr
from parsec.config import config

"""gscan config file format."""

USER_FILE = os.path.join(os.environ['HOME'], '.cylc', 'gscan.rc')

SPEC = {
'columns': vdr(vtype='string_list', default=['suite', 'status']),
'activate on startup': vdr(vtype='boolean', default=False)
}


class gscanconfig(config):

def check(self):
cfg = self.get(sparse=True)
if 'columns' in cfg:
for column in cfg['columns']:
if column not in ['host', 'suite', 'title', 'updated',
'status']:
print >> sys.stderr, ("WARNING: illegal column name "
"'" + column + "'")
cfg['columns'].remove(column)
if len(cfg['columns']) < 1:
print >> sys.stderr, ('WARNING: at least one column must be '
'specified, defaulting to "suite, '
'status"')
cfg['columns'] = ['suite', 'status']


gsfg = None
if not gsfg:
gsfg = gscanconfig(SPEC)
if os.access(USER_FILE, os.F_OK | os.R_OK):
try:
gsfg.loadcfg(USER_FILE, 'user config')
except ParsecError as exc:
sys.stderr.write('ERROR: bad gscan config %s:\n' % USER_FILE)
raise
gsfg.check()
3 changes: 3 additions & 0 deletions lib/cylc/gui/gpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from cylc.gui.util import get_icon, setup_icons
from cylc.owner import USER
from cylc.network.suite_state import extract_group_state
from cylc.cfgspec.gscan import gsfg


class ScanPanelApplet(object):
Expand Down Expand Up @@ -81,6 +82,8 @@ def __init__(self, hosts=None, owner=None, poll_interval=None,
owner=owner,
poll_interval=poll_interval)
self.top_hbox.connect("destroy", self.stop)
if gsfg.get(["activate on startup"]):
self.updater.start()

def get_widget(self):
"""Return the topmost widget for embedding in the panel."""
Expand Down
10 changes: 7 additions & 3 deletions lib/cylc/gui/gscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from cylc.owner import USER
from cylc.version import CYLC_VERSION
from cylc.task_state import TaskState
from cylc.cfgspec.gscan import gsfg

PYRO_TIMEOUT = 2
KEY_NAME = "name"
Expand Down Expand Up @@ -437,7 +438,7 @@ def __init__(self, hosts=None, owner=None, poll_interval=None):
host_name_column.set_cell_data_func(
cell_text_host, self._set_cell_text_host)
host_name_column.set_sort_column_id(0)
host_name_column.set_visible(False)
host_name_column.set_visible("host" in gsfg.get(["columns"]))
host_name_column.set_resizable(True)

# Construct the suite name column.
Expand All @@ -447,6 +448,7 @@ def __init__(self, hosts=None, owner=None, poll_interval=None):
suite_name_column.set_cell_data_func(
cell_text_name, self._set_cell_text_name)
suite_name_column.set_sort_column_id(1)
suite_name_column.set_visible("suite" in gsfg.get(["columns"]))
suite_name_column.set_resizable(True)

# Construct the suite title column.
Expand All @@ -456,7 +458,8 @@ def __init__(self, hosts=None, owner=None, poll_interval=None):
suite_title_column.set_cell_data_func(
cell_text_title, self._set_cell_text_title)
suite_title_column.set_sort_column_id(3)
suite_title_column.set_visible(False)
suite_title_column.set_visible("title" in gsfg.get(
["columns"]))
suite_title_column.set_resizable(True)

# Construct the update time column.
Expand All @@ -466,7 +469,7 @@ def __init__(self, hosts=None, owner=None, poll_interval=None):
time_column.set_cell_data_func(
cell_text_time, self._set_cell_text_time)
time_column.set_sort_column_id(4)
time_column.set_visible(False)
time_column.set_visible("updated" in gsfg.get(["columns"]))
time_column.set_resizable(True)

self.suite_treeview.append_column(host_name_column)
Expand All @@ -477,6 +480,7 @@ def __init__(self, hosts=None, owner=None, poll_interval=None):
# Construct the status column.
status_column = gtk.TreeViewColumn("Status")
status_column.set_sort_column_id(5)
status_column.set_visible("status" in gsfg.get(["columns"]))
status_column.set_resizable(True)
status_column_info = 6
cycle_column_info = 5
Expand Down

0 comments on commit ea6d17d

Please sign in to comment.