Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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