Example #1
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)
Example #2
0
    def run(self):
        s = sublime.load_settings("Package Syncing.sublime-settings")
        s.set("sync", True)
        sublime.save_settings("Package Syncing.sublime-settings")

        # Start watcher
        tools.start_watcher(tools.load_settings())

        # Run pkg_sync
        sublime.run_command("pkg_sync", {"mode": ["pull", "push"]})
Example #3
0
    def run(self):
        s = sublime.load_settings("Package Syncing.sublime-settings")
        s.set("sync", True)
        sublime.save_settings("Package Syncing.sublime-settings")

        # Start watcher
        tools.start_watcher(tools.load_settings())

        # Run pkg_sync
        sublime.run_command("pkg_sync", {"mode": ["pull", "push"]})
Example #4
0
def plugin_loaded():
    s = sublime.load_settings("Package Syncing.sublime-settings")
    s.clear_on_change("package_syncing")
    s.add_on_change("package_syncing", tools.restart_watcher)
    sublime.save_settings("Package Syncing.sublime-settings")

    # Start watcher
    sublime.set_timeout(lambda: tools.start_watcher(tools.load_settings()), 100)

    # Run pkg_sync
    sublime.set_timeout(lambda: sublime.run_command("pkg_sync", {"mode": ["pull", "push"]}), 1000)
Example #5
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)
Example #6
0
    def run(self, mode=["pull", "push"], override=False):
        log.debug("pkg_sync %s %s", mode, override)

        # Load settings
        settings = sublime.load_settings("Package Syncing.sublime-settings")

        # Check for valid sync_folder
        if not os.path.isdir(settings.get("sync_folder")):
            sublime.error_message("Invalid sync folder \"%s\", sync disabled! Please adjust your sync folder." % settings.get("sync_folder"))
            settings.set("sync", False)
            sublime.save_settings("Package Syncing.sublime-settings")
            return

        # Check if sync is already running
        if not q.has("sync"):
            t = thread.Sync(tools.load_settings(), mode, override)
            q.add(t, "sync")
        else:
            print("Package Syncing: Already running")
Example #7
0
    def run(self, item):
        log.debug("pkg_sync_push_item %s", item)

        # Start a thread to push the current item
        t = thread.Sync(tools.load_settings(), mode=["push"], item=item)
        q.add(t)
Example #8
0
 def is_enabled(self):
     s = tools.load_settings()
     return s.get("sync", False) and s.get(
         "sync_folder", False) and os.path.isdir(s.get("sync_folder"))
Example #9
0
 def is_enabled(self):
     s = tools.load_settings()
     return s.get("sync", False) and s.get("sync_folder", False) != False
Example #10
0
 def is_enabled(self):
     s = tools.load_settings()
     return s.get("sync", False)
Example #11
0
    def run(self, item):
        log.debug("pkg_sync_push_item %s", item)

        # Start a thread to push the current item
        t = thread.Sync(tools.load_settings(), mode=["push"], item=item)
        q.add(t)
Example #12
0
 def is_enabled(self):
     s = tools.load_settings()
     return s.get("sync", False) and s.get("sync_folder", False) and os.path.isdir(s.get("sync_folder"))
Example #13
0
 def is_enabled(self):
     s = tools.load_settings()
     return s.get("sync", False) and s.get("sync_folder", False) != False
Example #14
0
 def is_enabled(self):
     s = tools.load_settings()
     return s.get("sync", False)