Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gscan: new -a and -o OWNER-PATTERN options #2096

Merged
merged 1 commit into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 60 additions & 22 deletions bin/cylc-gscan
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,70 @@ hosts.
To customize themes copy $CYLC_DIR/conf/gcylcrc/gcylc.rc.eg to
$HOME/.cylc/gcylc.rc and follow the instructions in the file."""

from cylc.option_parsers import CylcOptionParser as COP

parser = COP(__doc__, argdoc=[])

parser.add_option("--host",
help="Host names to monitor (override site default).",
metavar="HOST", action="append",
dest="hosts")
parser.add_option("--poll-interval",
help="Polling interval (time between updates) in seconds",
type="int", metavar="SECONDS", dest="interval")
parser.add_option(
"-n", "--name",
metavar="PATTERN",
help="List suites with name matching PATTERN (regular expression). "
"Defaults to any name. Can be used multiple times.",
action="append", dest="patterns_name", default=[])

options, args = parser.parse_args()
import sys
if "--use-ssh" in sys.argv[1:]:
sys.argv.remove("--use-ssh")
from cylc.remote import remrun
if remrun().execute():
sys.exit(0)

import gtk
import warnings
warnings.filterwarnings('ignore', 'use the new', Warning)

from cylc.gui.gscan import ScanApp
from cylc.option_parsers import CylcOptionParser as COP
from cylc.owner import USER


def main():
"""Implement "cylc gscan"."""
parser = COP(
__doc__,
comms=True,
noforce=True,
argdoc=[(
"[HOSTS ...]", "Hosts to scan instead of the configured hosts.")])
parser.add_option(
"-a", "--all", "--all-suites",
help="List all suites found on all scanned hosts (the default is "
"just your own suites).",
action="store_true", default=False, dest="all_suites")
parser.add_option(
"-n", "--name",
metavar="PATTERN",
help="List suites with name matching PATTERN (regular expression). "
"Defaults to any name. Can be used multiple times.",
action="append", dest="patterns_name", default=[])
parser.add_option(
"-o", "--suite-owner",
metavar="PATTERN",
help="List suites with owner matching PATTERN (regular expression). "
"Defaults to just your own suites. Can be used multiple times.",
action="append", dest="patterns_owner", default=[])
parser.add_option(
"--comms-timeout", metavar="SEC",
help="Set a timeout for network connections "
"to each running suite. The default is 5 seconds.",
action="store", default=None, dest="comms_timeout")
parser.add_option(
"--poll-interval",
help="Polling interval (time between updates) in seconds",
type="int", metavar="SECONDS", dest="interval")
options, args = parser.parse_args()

if options.all_suites:
options.patterns_owner = [r".*"]
elif not options.patterns_owner:
options.patterns_owner = [USER]
ScanApp(
hosts=args,
patterns_name=options.patterns_name,
patterns_owner=options.patterns_owner,
comms_timeout=options.comms_timeout,
poll_interval=options.interval)
gtk.main()


ScanApp(hosts=options.hosts, owner=options.owner,
poll_interval=options.interval, name=options.patterns_name)
gtk.main()
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion bin/cylc-scan
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def main():
action="store_true", default=False, dest="print_ports")

parser.add_option(
"--comms-timeout", "--pyro-timeout", metavar="SEC",
"--comms-timeout", metavar="SEC",
help="Set a timeout for network connections "
"to each running suite. The default is 5 seconds.",
action="store", default=None, dest="comms_timeout")
Expand Down
2 changes: 1 addition & 1 deletion doc/gscanrc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ \subsubsection{columns}

\begin{myitemize}
\item {\em type:} string (a list of one or more view names)
\item {\em legal values:} ``host'', ``status'', ``suite'', ``title'',
\item {\em legal values:} ``host'', ``owner'', ``status'', ``suite'', ``title'',
``updated''
\item {\em default:} ``status'', ``suite''
\item {\em example:} \lstinline@columns = suite, title, status@
Expand Down
35 changes: 24 additions & 11 deletions lib/cylc/cfgspec/gscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,40 @@
}


class gscanconfig(config):
class GScanConfig(config):
"""Configuration for "gscan"."""

COL_GROUP = "Group"
COL_HOST = "Host"
COL_OWNER = "Owner"
COL_SUITE = "Suite"
COL_TITLE = "Title"
COL_UPDATED = "Updated"
COL_STATUS = "Status"
COLS_DEFAULT = (COL_SUITE.lower(), COL_STATUS.lower())
COLS = [col.lower() for col in (
COL_GROUP, COL_HOST, COL_OWNER, COL_SUITE, COL_TITLE, COL_UPDATED,
COL_STATUS)]

def check(self):
"""Custom configuration check."""
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 + "'")
if column not in self.COLS:
print >> sys.stderr, (
"WARNING: illegal column name '%s'" % 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']
if not cfg['columns']:
print >> sys.stderr, (
'WARNING: at least one column must be specified,' +
' defaulting to "%s, %s"' % self.COLS_DEFAULT)
cfg['columns'] = list(self.COLS_DEFAULT)


gsfg = None
if not gsfg:
gsfg = gscanconfig(SPEC)
gsfg = GScanConfig(SPEC)
if os.access(USER_FILE, os.F_OK | os.R_OK):
try:
gsfg.loadcfg(USER_FILE, 'user config')
Expand Down
Loading