def run(self):
        sync_interval = self.settings.get("sync_interval", 1)

        # Stop watcher and wait for the poll
        tools.pause_watcher(local="pull" in self.mode, remote="push" in self.mode)

        # If no item pull and push all
        if not self.item:
            print("Package Syncing: Start Complete Sync")

            # Fetch all items from the remote location
            if "pull" in self.mode:
                self.pull_all()

            # Push all items to the remote location
            if "push" in self.mode:
                self.push_all()

            print("Package Syncing: End Complete Sync")
        else:
            # Pull the selected item
            if "pull" in self.mode:
                self.pull(self.item)

            # Push the selected item
            if "push" in self.mode:
                self.push(self.item)

        # Restart watcher again
        tools.pause_watcher(False, local="pull" in self.mode, remote="push" in self.mode)
Exemple #2
0
    def run(self):
        sync_interval = self.settings.get("sync_interval", 1)

        # Stop watcher and wait for the poll
        tools.pause_watcher(local="pull" in self.mode,
                            remote="push" in self.mode)

        # If no item pull and push all
        if not self.item:
            print("Package Syncing: Start Complete Sync")

            # Fetch all items from the remote location
            if "pull" in self.mode:
                self.pull_all()

            # Push all items to the remote location
            if "push" in self.mode:
                self.push_all()

            print("Package Syncing: End Complete Sync")
        else:
            # Pull the selected item
            if "pull" in self.mode:
                self.pull(self.item)

            # Push the selected item
            if "push" in self.mode:
                self.push(self.item)

        # Restart watcher again
        tools.pause_watcher(False,
                            local="pull" in self.mode,
                            remote="push" in self.mode)
Exemple #3
0
        def on_done(path):
            if not os.path.isdir(path):
                os.makedirs(path)

            if os.path.isdir(path):
                if os.listdir(path):
                    if sublime.ok_cancel_dialog(
                            "The selected folder is not empty, would you like to continue and override your local settings?",
                            "Continue"):
                        override = True
                    else:
                        self.window.show_input_panel("Sync Folder", path,
                                                     on_done, None, None)
                        return
                else:
                    override = False

                # Adjust settings
                settings.set("sync", True)
                settings.set("sync_folder", path)

                # Reset last-run file
                file_path = os.path.join(sublime.packages_path(), "User",
                                         "Package Control.last-run")
                if os.path.isfile(file_path):
                    os.remove(file_path)

                # Reset last-run file
                file_path = os.path.join(sublime.packages_path(), "User",
                                         "Package Syncing.last-run")
                if os.path.isfile(file_path):
                    os.remove(file_path)

                sublime.save_settings("Package Syncing.sublime-settings")
                sublime.status_message(
                    "sync_folder successfully set to \"%s\"" % path)

                # Restart watcher
                tools.pause_watcher(local=False)
                tools.stop_watcher(local=False)
                tools.start_watcher(tools.load_settings(), local=False)

                # Run pkg_sync
                sublime.set_timeout(
                    lambda: sublime.run_command("pkg_sync", {
                        "mode": ["pull", "push"],
                        "override": override
                    }), 1000)

            else:
                sublime.error_message("Invalid Path %s" % path)

            # Add on on_change listener
            sublime.set_timeout(
                lambda: settings.add_on_change("package_syncing", tools.
                                               restart_watcher), 500)
Exemple #4
0
        def on_done(path):
            if not os.path.isdir(path):
                os.makedirs(path)

            if os.path.isdir(path):
                if os.listdir(path):
                    if sublime.ok_cancel_dialog("The selected folder is not empty, would you like to continue and override your local settings?", "Continue"):
                        override = True
                    else:
                        self.window.show_input_panel("Sync Folder", path, on_done, None, None)
                        return
                else:
                    override = False

                # Adjust settings
                settings.set("sync", True)
                settings.set("sync_folder", path)

                # Reset last-run file
                file_path = os.path.join(sublime.packages_path(), "User", "Package Control.last-run")
                if os.path.isfile(file_path):
                    os.remove(file_path)

                # Reset last-run file
                file_path = os.path.join(sublime.packages_path(), "User", "Package Syncing.last-run")
                if os.path.isfile(file_path):
                    os.remove(file_path)

                sublime.save_settings("Package Syncing.sublime-settings")
                sublime.status_message("sync_folder successfully set to \"%s\"" % path)

                # Restart watcher
                tools.pause_watcher(local=False)
                tools.stop_watcher(local=False)
                tools.start_watcher(tools.load_settings(), local=False)

                # Run pkg_sync
                sublime.set_timeout(lambda: sublime.run_command("pkg_sync", {"mode": ["pull", "push"], "override": override}), 1000)

            else:
                sublime.error_message("Invalid Path %s" % path)

            # Add on on_change listener
            sublime.set_timeout(lambda: settings.add_on_change("package_syncing", tools.restart_watcher), 500)