示例#1
0
    def run(self, command, application):
        """Open application's history buffer in an editor.

        :type command: list
        :param command: The dot command as a list split
            on whitespace, e.g ``['.foo', 'arg1', 'arg2']``

        :type application: AWSShell
        :param application: The application object.

        """
        all_commands = '\n'.join([
            'aws ' + h for h in list(application.history)
            if not h.startswith(('.', '!'))
        ])
        with temporary_file('w') as f:
            f.write(all_commands)
            f.flush()
            editor = self._get_editor_command()
            try:
                p = self._popen_cls([editor, f.name])
                p.communicate()
            except OSError:
                self._err.write(
                    "Unable to launch editor: %s\n"
                    "You can configure which editor to use by "
                    "exporting the EDITOR environment variable.\n" % editor)
示例#2
0
文件: app.py 项目: auready/aws-shell
    def run(self, command, application):
        """Open application's history buffer in an editor.

        :type command: list
        :param command: The dot command as a list split
            on whitespace, e.g ``['.foo', 'arg1', 'arg2']``

        :type application: AWSShell
        :param application: The application object.

        """
        all_commands = '\n'.join(
            ['aws ' + h for h in list(application.history)
             if not h.startswith(('.', '!'))])
        with temporary_file('w') as f:
            f.write(all_commands)
            f.flush()
            editor = self._get_editor_command()
            try:
                p = self._popen_cls([editor, f.name])
                p.communicate()
            except OSError:
                self._err.write("Unable to launch editor: %s\n"
                                "You can configure which editor to use by "
                                "exporting the EDITOR environment variable.\n"
                                % editor)
示例#3
0
 def test_can_open_in_read(self):
     with temporary_file('r') as f:
         filename = f.name
         assert f.read() == ''
         # Verify we can open the file again
         # in another file descriptor.
         with open(filename, 'w') as f2:
             f2.write("foobar")
         f.seek(0)
         assert f.read() == "foobar"
     self.assertFalse(os.path.isfile(filename))
示例#4
0
文件: app.py 项目: Yahpay/aws-shell
    def run(self, command, application):
        """Open application's history buffer in an editor.

        :type command: list
        :param command: The dot command as a list split
            on whitespace, e.g ``['.foo', 'arg1', 'arg2']``

        :type application: AWSShell
        :param application: The application object.

        """
        all_commands = "\n".join(["aws " + h for h in list(application.history) if not h.startswith((".", "!"))])
        with temporary_file("w") as f:
            f.write(all_commands)
            f.flush()
            editor = self._get_editor_command()
            p = self._popen_cls([editor, f.name])
            p.communicate()
示例#5
0
文件: app.py 项目: zkan/aws-shell
    def run(self, command, application):
        """Open application's history buffer in an editor.

        :type command: list
        :param command: The dot command as a list split
            on whitespace, e.g ``['.foo', 'arg1', 'arg2']``

        :type application: AWSShell
        :param application: The application object.

        """
        all_commands = '\n'.join(
            ['aws ' + h for h in list(application.history)
             if not h.startswith(('.', '!'))])
        with temporary_file('w') as f:
            f.write(all_commands)
            f.flush()
            editor = self._get_editor_command()
            p = self._popen_cls([editor, f.name])
            p.communicate()
示例#6
0
 def test_is_removed_after_exiting_context(self):
     with temporary_file('w') as f:
         filename = f.name
         f.write("foobar")
         f.flush()
     self.assertFalse(os.path.isfile(filename))
示例#7
0
 def test_can_use_as_context_manager(self):
     with temporary_file('w') as f:
         filename = f.name
         f.write("foobar")
         f.flush()
         self.assertEqual(open(filename).read(), "foobar")