Beispiel #1
0
def check_upload_download_response(command_name, command_response):
    if command_response and command_response.get("existing_files"):
        # command was not performed because overwriting existing files need confirmation
        existing = sorted(command_response["existing_files"][:25])
        if len(command_response["existing_files"]) > 25:
            existing.append("...")

        user_response = messagebox.askokcancel(
            "Overwriting",
            "Some file(s) will be overwritten:\n\n" + "   " + "\n   ".join(existing),
            icon="info",
        )
        if not user_response:
            return

        else:
            get_runner().send_command(
                InlineCommand(
                    command_name,
                    allow_overwrite=True,
                    source_paths=command_response["source_paths"],
                    target_dir=command_response["target_dir"],
                    blocking=True,
                    description=command_response["description"],
                )
            )
Beispiel #2
0
    def write_remote_file(self, save_filename, content_bytes, save_copy):
        if get_runner().ready_for_remote_file_operations(show_message=True):
            target_filename = extract_target_path(save_filename)

            get_runner().send_command(
                InlineCommand(
                    "write_file",
                    path=target_filename,
                    content_bytes=content_bytes,
                    editor_id=id(self),
                    blocking=True,
                    description=_("Saving") + "...",
                ))

            if not save_copy:
                self._code_view.text.edit_modified(False)

            self.update_title()

            # NB! edit_modified is not falsed yet!
            get_workbench().event_generate("RemoteFileOperation",
                                           path=target_filename,
                                           operation="save")
            return True
        else:
            return False
Beispiel #3
0
        def upload():
            selection = self.get_selection_info(True)
            if not selection:
                return

            if "dir" in selection["kinds"] and not proxy.supports_remote_directories():
                messagebox.showerror(
                    "Can't upload directory",
                    "%s does not support directories.\n" % proxy.get_node_label()
                    + "You can only upload files.",
                )
            else:
                response = get_runner().send_command(
                    InlineCommand(
                        "upload",
                        allow_overwrite=False,
                        source_paths=selection["paths"],
                        target_dir=target_dir,
                        blocking=True,
                        description=_("Uploading %s to %s")
                        % (selection["description"], target_dir),
                    )
                )
                check_upload_download_response("upload", response)
                self.master.remote_files.refresh_tree()
    def _start_update_list(self, name_to_show=None):
        assert self._get_state() in [None, "idle"]
        self._set_state("listing")

        get_workbench().bind("get_active_distributions_response",
                             self._complete_update_list, True)
        self._last_name_to_show = name_to_show
        get_runner().send_command(InlineCommand("get_active_distributions"))
Beispiel #5
0
 def handle_frame_click(event,
                        frame_id=frame_id,
                        filename=filename,
                        lineno=lineno):
     get_runner().send_command(
         InlineCommand("get_frame_info", frame_id=frame_id))
     if os.path.exists(filename):
         get_workbench().get_editor_notebook().show_file(
             filename, lineno, set_focus=False)
Beispiel #6
0
 def handle_autocomplete_request(self):
     row, column = self._get_position()
     source = self.text.get("1.0", "end-1c")
     get_runner().send_command(
         InlineCommand(
             "editor_autocomplete",
             source=source,
             row=row,
             column=column,
             filename=self._get_filename(),
         ))
Beispiel #7
0
        def download():
            selection = self.get_selection_info(True)
            if not selection:
                return

            response = get_runner().send_command(
                InlineCommand(
                    "download",
                    allow_overwrite=False,
                    source_paths=selection["paths"],
                    target_dir=target_dir,
                    blocking=True,
                    description=_("Downloading %s to %s") % (selection["description"], target_dir),
                )
            )
            check_upload_download_response("download", response)
            self.master.local_files.refresh_tree()
Beispiel #8
0
    def _load_remote_file(self, filename):
        self._filename = filename
        self._code_view.set_content("")
        self._code_view.text.set_read_only(True)

        target_filename = extract_target_path(self._filename)

        self.update_title()
        response = get_runner().send_command(
            InlineCommand("read_file",
                          path=target_filename,
                          blocking=True,
                          description=_("Loading") + "..."))

        if response.get("error"):
            # TODO: make it softer
            raise RuntimeError(response["error"])

        content = response["content_bytes"]
        self._code_view.text.set_read_only(False)
        self._code_view.set_content_as_bytes(content)
        self.get_text_widget().edit_modified(False)
        self.update_title()
Beispiel #9
0
 def _request_heap_data(self, msg=None, even_when_hidden=False):
     if self.winfo_ismapped() or even_when_hidden:
         # TODO: update itself also when it becomes visible
         if get_runner() is not None:
             get_runner().send_command(InlineCommand("get_heap"))
 def perform_mkdir(self, parent_dir, name):
     get_runner().send_command(
         InlineCommand("mkdir", path=parent_dir + self.get_dir_separator() + name)
     )
 def perform_delete(self, paths, description):
     get_runner().send_command(
         InlineCommand("delete", paths=paths, blocking=True, description=description)
     )
 def request_fs_info(self, path):
     if get_runner():
         get_runner().send_command(InlineCommand("get_fs_info", path=path))
 def request_dirs_child_data(self, node_id, paths):
     if get_runner():
         get_runner().send_command(
             InlineCommand("get_dirs_child_data", node_id=node_id, paths=paths)
         )
Beispiel #14
0
    def handle_autocomplete_request(self):
        source = self._get_prefix()

        get_runner().send_command(
            InlineCommand("shell_autocomplete", source=source))