Example #1
0
    def unregister_popup(self, w, reg, is_group=False):

        window = gtk.MessageDialog(parent=self.window,
                                   flags=0,
                                   type=gtk.MESSAGE_QUESTION,
                                   buttons=gtk.BUTTONS_NONE,
                                   message_format="Unregistering Suite " +
                                   reg + """
\nDelete suite definition directory too? (DANGEROUS!)""")

        window.add_button(gtk.STOCK_YES, gtk.RESPONSE_YES)
        window.add_button(gtk.STOCK_NO, gtk.RESPONSE_NO)
        window.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        response = window.run()
        window.destroy()

        if is_group:
            reg = '^' + reg + '\..*$'
        else:
            reg = '^' + reg + '$'

        if response == gtk.RESPONSE_YES:
            command = "cylc unregister -f -d " + reg
        elif response == gtk.RESPONSE_NO:
            command = "cylc unregister " + reg
        else:
            command = None
        if command:
            res, out = run_get_stdout(command)
            if not res:
                warning_dialog('\n'.join(out), self.window).warn()
Example #2
0
    def copy_popup(self, w, reg, is_group=False):

        window = EntryDialog(parent=self.window,
                             flags=0,
                             type=gtk.MESSAGE_QUESTION,
                             buttons=gtk.BUTTONS_OK_CANCEL,
                             message_format="Copy Suite " + reg + """To
NAME,TOP_DIRECTORY""")

        out = window.run()
        window.destroy()
        if out:
            try:
                name, topdir = re.split(' *, *', out)
            except Exception, e:
                warning_dialog(str(e), self.window).warn()
            else:
                print name, topdir
                topdir = os.path.expanduser(os.path.expandvars(topdir))
                print name, topdir
                command = "cylc cp " + reg + ' ' + name + ' ' + topdir
                print command
                res, out = run_get_stdout(command)
                if not res:
                    warning_dialog('\n'.join(out), self.window).warn()
                elif out:
                    info_dialog('\n'.join(out), self.window).inform()
Example #3
0
    def unregister_popup( self, w, reg, is_group=False ):

        window = gtk.MessageDialog( parent=self.window,
                flags=0,
                type=gtk.MESSAGE_QUESTION,
                buttons=gtk.BUTTONS_NONE,
                message_format="Unregistering Suite " + reg + """
\nDelete suite definition directory too? (DANGEROUS!)""")

        window.add_button( gtk.STOCK_YES, gtk.RESPONSE_YES )
        window.add_button( gtk.STOCK_NO, gtk.RESPONSE_NO )
        window.add_button( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL )
        response = window.run()
        window.destroy()

        if is_group:
            reg = '^' + reg + '\..*$'
        else:
            reg = '^' + reg + '$'

        if response == gtk.RESPONSE_YES:
            command = "cylc unregister -f -d " + reg
        elif response == gtk.RESPONSE_NO:
            command = "cylc unregister " + reg
        else:
            command = None
        if command:
            res, out = run_get_stdout( command )
            if not res:
                warning_dialog( '\n'.join(out), self.window ).warn()
Example #4
0
    def copy_popup( self, w, reg, is_group=False ):

        window = EntryDialog( parent=self.window,
                flags=0,
                type=gtk.MESSAGE_QUESTION,
                buttons=gtk.BUTTONS_OK_CANCEL,
                message_format="Copy Suite " + reg + """To
NAME,TOP_DIRECTORY""")

        out = window.run()
        window.destroy()
        if out:
            try:
                name, topdir = re.split(' *, *', out )
            except Exception, e:
                warning_dialog( str(e), self.window ).warn()
            else:
                print name, topdir
                topdir = os.path.expanduser( os.path.expandvars( topdir ))
                print name, topdir
                command = "cylc cp " + reg + ' ' + name + ' ' + topdir
                print command
                res, out = run_get_stdout( command )
                if not res:
                    warning_dialog( '\n'.join(out), self.window ).warn()
                elif out:
                    info_dialog( '\n'.join(out), self.window ).inform()
Example #5
0
def _get_cylc_version():
    """Determine and return cylc version string."""

    cylc_dir = os.environ['CYLC_DIR']

    if os.path.exists(os.path.join(cylc_dir, ".git")):
        # We're running in a cylc git repository, so dynamically determine
        # the cylc version string.  Enclose the path in quotes to handle
        # avoid failure when cylc_dir contains spaces.
        is_ok, outlines = run_get_stdout(
            '"%s"' % os.path.join(cylc_dir, "admin", "get-repo-version"))
        if is_ok and outlines:
            return outlines[0]
        else:
            raise SystemExit("Failed to get version number!")

    else:
        # We're running in a raw cylc source tree, so read the version
        # file created by 'make' after unpacking the tarball.
        try:
            for line in open(os.path.join(cylc_dir, 'VERSION')):
                return line.rstrip()
        except IOError:
            raise SystemExit(
                "*** ERROR, failed to read the cylc VERSION file.***\n" +
                "Please inform your cylc admin user.\n" +
                "This file should have been created by running 'make' or\n" +
                "'make version' after unpacking the cylc release tarball.\n" +
                "ABORTING")
Example #6
0
def _get_cylc_version():
    """Determine and return cylc version string."""

    cylc_dir = os.environ['CYLC_DIR']

    if os.path.exists(os.path.join(cylc_dir, ".git")):
        # We're running in a cylc git repository, so dynamically determine
        # the cylc version string.  Enclose the path in quotes to handle
        # avoid failure when cylc_dir contains spaces.
        is_ok, outlines = run_get_stdout(
            '"%s"' %
            os.path.join(cylc_dir, "etc", "dev-bin", "get-repo-version"))
        if is_ok and outlines:
            return outlines[0]
        else:
            return UNKNOWN

    else:
        # We're running in a raw cylc source tree, so read the version
        # file created by 'make' after unpacking the tarball.
        try:
            for line in open(os.path.join(cylc_dir, 'VERSION')):
                return line.rstrip()
        except IOError:
            return UNKNOWN
Example #7
0
def _get_cylc_version():
    """Determine and return cylc version string."""

    cylc_dir = os.environ['CYLC_DIR']

    if os.path.exists(os.path.join(cylc_dir, ".git")):
        # We're running in a cylc git repository, so dynamically determine
        # the cylc version string.  Enclose the path in quotes to handle
        # avoid failure when cylc_dir contains spaces.
        is_ok, outlines = run_get_stdout(
            '"%s"' % os.path.join(cylc_dir, "admin", "get-repo-version"))
        if is_ok and outlines:
            return outlines[0]
        else:
            raise SystemExit("Failed to get version number!")

    else:
        # We're running in a raw cylc source tree, so read the version
        # file created by 'make' after unpacking the tarball.
        try:
            for line in open(os.path.join(cylc_dir, 'VERSION')):
                return line.rstrip()
        except IOError:
            raise SystemExit(
                "*** ERROR, failed to read the cylc VERSION file.***\n" +
                "Please inform your cylc admin user.\n" +
                "This file should have been created by running 'make' or\n" +
                "'make version' after unpacking the cylc release tarball.\n" +
                "ABORTING")
Example #8
0
    def reregister_popup(self, w, reg, is_group=False):

        window = EntryDialog(parent=self.window,
                             flags=0,
                             type=gtk.MESSAGE_QUESTION,
                             buttons=gtk.BUTTONS_OK_CANCEL,
                             message_format="Reregister Suite " + reg + " As")

        rereg = window.run()
        window.destroy()
        if rereg:
            command = "cylc reregister " + reg + ' ' + rereg
            res, out = run_get_stdout(command)
            if not res:
                warning_dialog('\n'.join(out), self.window).warn()
Example #9
0
    def reregister_popup( self, w, reg, is_group=False ):

        window = EntryDialog( parent=self.window,
                flags=0,
                type=gtk.MESSAGE_QUESTION,
                buttons=gtk.BUTTONS_OK_CANCEL,
                message_format="Reregister Suite " + reg + " As")

        rereg = window.run()
        window.destroy()
        if rereg:
            command = "cylc reregister " + reg + ' ' + rereg
            res, out = run_get_stdout( command )
            if not res:
                warning_dialog( '\n'.join(out), self.window ).warn()
Example #10
0
    def alias_popup( self, w, reg ):

        window = EntryDialog( parent=self.window,
                flags=0,
                type=gtk.MESSAGE_QUESTION,
                buttons=gtk.BUTTONS_OK_CANCEL,
                message_format="Alias Suite Name " + reg )

        alias = window.run()
        window.destroy()
        if alias:
            command = "cylc alias " + reg + ' ' + alias
            res, out = run_get_stdout( command )
            if not res:
                warning_dialog( '\n'.join(out), self.window ).warn()
Example #11
0
def get_task_host(cfg_item):
    """Evaluate a task host string.

    E.g.:

    [runtime]
        [[NAME]]
            [[[remote]]]
                host = cfg_item

    cfg_item -- An explicit host name, a command in back-tick or $(command)
                format, or an environment variable holding a hostname.

    Return "localhost" if cfg_item is not defined or if the evaluated host name
    is equivalent to "localhost". Otherwise, return the evaluated host name on
    success.

    """

    host = cfg_item

    if not host:
        return "localhost"

    # 1) host selection command: $(command) or `command`
    m = re.match('(`|\$\()\s*(.*)\s*(`|\))$', host)
    if m:
        # extract the command and execute it
        hs_command = m.groups()[1]
        res = run_get_stdout(hs_command)  # (T/F,[lines])
        if res[0]:
            # host selection command succeeded
            host = res[1][0]
        else:
            # host selection command failed
            raise Exception("Host selection by " + host + " failed\n  " +
                            '\n'.join(res[1]))

    # 2) environment variable: ${VAR} or $VAR
    # (any quotes are stripped by file parsing)
    n = re.match('^\$\{{0,1}(\w+)\}{0,1}$', host)
    if n:
        var = n.groups()[0]
        try:
            host = os.environ[var]
        except KeyError, x:
            raise Exception("Host selection by " + host +
                            " failed:\n  Variable not defined: " + str(x))
Example #12
0
def get_task_host(cfg_item):
    """Evaluate a task host string.

    E.g.:

    [runtime]
        [[NAME]]
            [[[remote]]]
                host = cfg_item

    cfg_item -- An explicit host name, a command in back-tick or $(command)
                format, or an environment variable holding a hostname.

    Return "localhost" if cfg_item is not defined or if the evaluated host name
    is equivalent to "localhost". Otherwise, return the evaluated host name on
    success.

    """

    host = cfg_item

    if not host:
        return "localhost"

    # 1) host selection command: $(command) or `command`
    match = REC_COMMAND.match(host)
    if match:
        # extract the command and execute it
        hs_command = match.groups()[1]
        timeout = GLOBAL_CFG.get(["task host select command timeout"])
        is_ok, outlines = run_get_stdout(hs_command, timeout)
        if is_ok:
            # host selection command succeeded
            host = outlines[0]
        else:
            # host selection command failed
            raise HostSelectError(host, "\n".join(outlines))

    # 2) environment variable: ${VAR} or $VAR
    # (any quotes are stripped by file parsing)
    match = REC_ENVIRON.match(host)
    if match:
        name = match.groups()[0]
        try:
            host = os.environ[name]
        except KeyError, exc:
            raise HostSelectError(host, "Variable not defined: " + str(exc))
Example #13
0
def get_task_host(cfg_item):
    """Evaluate a task host string.

    E.g.:

    [runtime]
        [[NAME]]
            [[[remote]]]
                host = cfg_item

    cfg_item -- An explicit host name, a command in back-tick or $(command)
                format, or an environment variable holding a hostname.

    Return "localhost" if cfg_item is not defined or if the evaluated host name
    is equivalent to "localhost". Otherwise, return the evaluated host name on
    success.

    """

    host = cfg_item

    if not host:
        return "localhost"

    # 1) host selection command: $(command) or `command`
    match = REC_COMMAND.match(host)
    if match:
        # extract the command and execute it
        hs_command = match.groups()[1]
        timeout = GLOBAL_CFG.get(["task host select command timeout"])
        is_ok, outlines = run_get_stdout(hs_command, timeout)
        if is_ok:
            # host selection command succeeded
            host = outlines[0]
        else:
            # host selection command failed
            raise HostSelectError(host, "\n".join(outlines))

    # 2) environment variable: ${VAR} or $VAR
    # (any quotes are stripped by file parsing)
    match = REC_ENVIRON.match(host)
    if match:
        name = match.groups()[0]
        try:
            host = os.environ[name]
        except KeyError, exc:
            raise HostSelectError(host, "Variable not defined: " + str(exc))
Example #14
0
def get_task_host(cfg_item):
    """Evaluate a task host string.

    E.g.:

    [runtime]
        [[NAME]]
            [[[remote]]]
                host = cfg_item

    cfg_item -- An explicit host name, a command in back-tick or $(command)
                format, or an environment variable holding a hostname.

    Return "localhost" if cfg_item is not defined or if the evaluated host name
    is equivalent to "localhost". Otherwise, return the evaluated host name on
    success.

    """

    host = cfg_item

    if not host:
        return "localhost"

    # 1) host selection command: $(command) or `command`
    m = re.match("(`|\$\()\s*(.*)\s*(`|\))$", host)
    if m:
        # extract the command and execute it
        hs_command = m.groups()[1]
        res = run_get_stdout(hs_command)  # (T/F,[lines])
        if res[0]:
            # host selection command succeeded
            host = res[1][0]
        else:
            # host selection command failed
            raise Exception("Host selection by " + host + " failed\n  " + "\n".join(res[1]))

    # 2) environment variable: ${VAR} or $VAR
    # (any quotes are stripped by file parsing)
    n = re.match("^\$\{{0,1}(\w+)\}{0,1}$", host)
    if n:
        var = n.groups()[0]
        try:
            host = os.environ[var]
        except KeyError, x:
            raise Exception("Host selection by " + host + " failed:\n  Variable not defined: " + str(x))
Example #15
0
    def compare_popup(self, w, reg):

        window = EntryDialog(parent=self.window,
                             flags=0,
                             type=gtk.MESSAGE_QUESTION,
                             buttons=gtk.BUTTONS_OK_CANCEL,
                             message_format="Compare Suite " + reg + " With")

        compare = window.run()
        window.destroy()
        if compare:
            command = "cylc diff " + reg + ' ' + compare
            res, out = run_get_stdout(command)
            if not res:
                warning_dialog('\n'.join(out), self.window).warn()
            else:
                # TODO: need a bigger scrollable window here!
                info_dialog('\n'.join(out), self.window).inform()
Example #16
0
    def compare_popup( self, w, reg ):

        window = EntryDialog( parent=self.window,
                flags=0,
                type=gtk.MESSAGE_QUESTION,
                buttons=gtk.BUTTONS_OK_CANCEL,
                message_format="Compare Suite " + reg + " With")

        compare = window.run()
        window.destroy()
        if compare:
            command = "cylc diff " + reg + ' ' + compare
            res, out = run_get_stdout( command )
            if not res:
                warning_dialog( '\n'.join(out), self.window ).warn()
            else:
                # TODO: need a bigger scrollable window here!
                info_dialog( '\n'.join(out), self.window ).inform()
Example #17
0
def _get_cylc_version():
    """Determine and return cylc version string."""

    cylc_dir = os.environ['CYLC_DIR']

    if os.path.exists(os.path.join(cylc_dir, ".git")):
        # We're running in a cylc git repository, so dynamically determine
        # the cylc version string.  Enclose the path in quotes to handle
        # avoid failure when cylc_dir contains spaces.
        is_ok, outlines = run_get_stdout(
            '"%s"' % os.path.join(cylc_dir, "admin", "get-repo-version"))
        if is_ok and outlines:
            return outlines[0]
        else:
            return UNKNOWN

    else:
        # We're running in a raw cylc source tree, so read the version
        # file created by 'make' after unpacking the tarball.
        try:
            for line in open(os.path.join(cylc_dir, 'VERSION')):
                return line.rstrip()
        except IOError:
            return UNKNOWN
Example #18
0
        # Determine task host settings now, just before job submission,
        # because dynamic host selection may be used.

        # host may be None (= run task on suite host)
        host = rtconfig['remote']['host']
        
        if host:
            # dynamic host section:
            #   host = $( host-select-command )
            #   host =  ` host-select-command `
            m = re.match( '(`|\$\()\s*(.*)\s*(`|\))$', host )
            if m:
                # extract the command and execute it
                hs_command = m.groups()[1]
                res = run_get_stdout( hs_command ) # (T/F,[lines])
                if res[0]:
                    # host selection command succeeded
                    host = res[1][0]
                    self.log( "NORMAL", "Host selected for " + self.id + ": " + host )
                else:
                    # host selection command failed
                    self.log( 'CRITICAL', "Dynamic host selection failed for task " + self.id )
                    self.incoming( 'CRITICAL', self.id + " failed" )
                    print >> sys.stderr, '\n'.join(res[1])
                    # must still assign a name now or abort the suite?
                    host = "NO-HOST-SELECTED"
                self.hostname = host

            if host not in gcfg.cfg['task hosts']:
                # there's no specific config for this host