def __init__(self, site): cmd.Cmd.__init__(self) self.suffix = "=>> " self.intro = "Welcome to gsh! " self.prompt = site + " " + self.suffix self.keywords = ["!", "hist", "exit", "help", "setsite", "getsite", "EOF", "vdt_location", "version"] self.home = os.environ["HOME"] self.history = "%s/.gsh_history" % self.home self.workfile = "%s/gsh_workfile" % self.home call(["/bin/touch", self.workfile]) call(["/bin/touch", self.history]) # site specific variables self.site_env = {} self.site = site self.site_name = getSiteNameFromFQDN(self.site) # register command handler self.commandHandler = CommandHandler(self) pwd = self.commandHandler.get_pwd(empty_cwd=True) self.cwd = pwd.split("/") self.old_cwd = None
def do_setsite(self, args): """ Sytnax: =>> setsite fqdn Description: Sets the fully qualified domain name (fqdn) of a desired site. All entered commands will be run on this site. There can only be one... """ try: old_site = self.site self.site = args globus_ping = buildGlobusPing(self.site) ping_results = self.commandHandler.run(globus_ping) try: # if the next line succeeds, then the ping failed so restore # the old site ping_results.index("fail") print "You are not authorized to run at %s restoring the old" \ " site setting." % self.site self.site = old_site except: # the ping result shows a success so, set everything up for the # new site self.prompt = self.site + " " + self.suffix self.site_env = {} self.site_name = getSiteNameFromFQDN(self.site) except: print "setsite must follow the folowing format: setsite <fqdn>"
def do_setsite(self, args): """ Sytnax: =>> setsite fqdn Description: Sets the fully qualified domain name (fqdn) of a desired site. All entered commands will be run on this site. There can only be one... """ if len(args) == 0: print "setsite must follow the folowing format: setsite <fqdn>" else: old_site = self.site self.site = args globus_ping = buildGlobusPing(self.site) try: _ = self.commandHandler.run(globus_ping) # the ping result succeeded so, set everything up for the new site self.prompt = self.site + " " + self.suffix self.site_env = {} self.site_name = getSiteNameFromFQDN(self.site) except OSError, oe: print "ERROR. The globus client is not in the path." except CalledProcessError, cpe: # the ping failed so restore the old site print "You are not authorized to run at %s restoring the old" " site setting." % self.site print cpe.output self.site = old_site
def __init__(self, site, gsh_location): cmd.Cmd.__init__(self) self.suffix = "=>> " self.intro = "Welcome to gsh! " self.prompt = site + " " + self.suffix self.keywords = ["!", "hist", "exit", "help", "setsite", "getsite", "EOF", "vdt_location", "version"] self.home = os.environ['HOME'] self.history = "%s/.gsh_history" % self.home self.workfile = "%s/gsh_workfile" % self.home call(["/bin/touch", self.workfile]) call(["/bin/touch", self.history]) # site specific variables self.site_env = {} self.site_env["PWD"] = "" self.site = site self.site_name = getSiteNameFromFQDN(self.site) # register command handler self.commandHandler = CommandHandler(self)