def do_source(self, fname=None): """\ Usage : source <filename> use <filename> as standard input execute commands stored in. Runs command(s) from a file. """ keepstate = Statekeeper(self, ('stdin', 'use_rawinput', )) try: self.stdin = open(fname, 'r') except IOError as error: try: self.stdin = open('%s.%s' % (fname, self.default_extension), 'r') except IOError: print('Problem opening file %s: \n%s' % (fname, error)) keepstate.restore() return self.use_rawinput = False self.prompt = self.continuation_prompt = '' SETTINGS.set_script(1) self.cmdloop() SETTINGS.set_script(0) self.stdin.close() keepstate.restore() self.lastcmd = '' return
def do_source(self, fname=None): """\ Usage : source <filename> use <filename> as standard input execute commands stored in. Runs command(s) from a file. """ keepstate = Statekeeper(self, ('stdin','use_rawinput',)) try: self.stdin = open(fname, 'r') except IOError, e: try: self.stdin = open('%s.%s' % (fname, self.default_extension), 'r') except IOError: print 'Problem opening file %s: \n%s' % (fname, e) keepstate.restore() return
def do_source(self, fname=None): """\ Usage : source <filename> use <filename> as standard input execute commands stored in. Runs command(s) from a file. """ keepstate = Statekeeper(self, ( 'stdin', 'use_rawinput', )) try: self.stdin = open(fname, 'r') except IOError as error: try: self.stdin = open('%s.%s' % (fname, self.default_extension), 'r') except IOError: print('Problem opening file %s: \n%s' % (fname, error)) keepstate.restore() return self.use_rawinput = False self.prompt = self.continuation_prompt = '' SETTINGS.set_script(1) self.cmdloop() SETTINGS.set_script(0) self.stdin.close() keepstate.restore() self.lastcmd = '' return