コード例 #1
0
ファイル: transport.py プロジェクト: jplana/baboon
    def _on_rsync_stanza(self, iq):
        """ Called when a Rsync stanza is received. This handler creates a
        new RsyncTask if permissions are good.
        """

        self.logger.info('Received a rsync stanza.')

        # Get the useful data.
        node = iq['rsync']['node']
        sid = iq['rsync']['sid']
        rid = iq['rsync']['rid']
        files = iq['rsync']['files']
        sfrom = iq['from']
        project_path = join(self.working_dir, node, sfrom.bare)

        # Verify if the user is a subscriber/owner of the node.
        is_subscribed = self._verify_subscription(iq, sfrom.bare, node)
        if not is_subscribed:
            eventbus.fire('rsync-finished-failure', rid=rid)
            return

        # The future reply iq.
        reply = iq.reply()

        # Create the new RsyncTask.
        from task import RsyncTask
        rsync_task = RsyncTask(sid, rid, sfrom, node, project_path, files)
        dispatcher.put(node, rsync_task)

        # Register the current rsync_task in the pending_rsyncs dict.
        self.pending_rsyncs[rid] = rsync_task

        # Reply to the IQ
        reply['rsync']
        reply.send()
コード例 #2
0
ファイル: transport.py プロジェクト: jplana/baboon
    def _on_merge_stanza(self, iq):
        """ Called when a MergeVerification stanza is received. This handler
        creates a new MergeTask if permissions are good.
        """

        # Get the useful data.
        sfrom = iq['from'].bare
        node = iq['merge']['node']
        project_path = join(self.working_dir, node, sfrom)

        # Verify if the user is a subscriber/owner of the node.
        is_subscribed = self._verify_subscription(iq, sfrom, node)
        if not is_subscribed:
            eventbus.fire("rsync-finished-failure")
            return

        # Verify if the server-side project is a git repository.
        is_git_repo = self._verify_git_repository(iq, node, project_path)
        if not is_git_repo:
            return

        # The future reply iq.
        reply = iq.reply()

        # Prepare the merge verification with this data.
        from task import MergeTask
        dispatcher.put(node, MergeTask(node, sfrom))

        # Reply to the request.
        reply.send()
コード例 #3
0
ファイル: transport.py プロジェクト: jplana/baboon
    def _on_git_init_stanza(self, iq):
        """ Called when a GitInit stanza is received. This handler creates a
        new GitInitTask if permissions are good.
        """

        self.logger.info("Received a git init stanza.")

        # Get the useful data.
        node = iq['git-init']['node']
        url = iq['git-init']['url']
        sfrom = iq['from'].bare

        # Ensure permissions.
        is_subscribed = self._verify_subscription(iq, sfrom, node)
        if not is_subscribed:
            eventbus.fire("rsync-finished-failure")
            return

        # Create a new GitInitTask
        from baboon.baboond.task import GitInitTask
        git_init_task = GitInitTask(node, url, sfrom)

        # Register the BaboonId of this GitInitTask in the
        # self.pending_git_init_tasks dict.
        self.pending_git_init_tasks[git_init_task.bid] = iq

        # Add the GitInitTask to the list of tasks to execute.
        dispatcher.put(node, git_init_task)
コード例 #4
0
    def _on_merge_stanza(self, iq):
        """ Called when a MergeVerification stanza is received. This handler
        creates a new MergeTask if permissions are good.
        """

        # Get the useful data.
        sfrom = iq['from'].bare
        node = iq['merge']['node']
        project_path = join(self.working_dir, node, sfrom)

        # Verify if the user is a subscriber/owner of the node.
        is_subscribed = self._verify_subscription(iq, sfrom, node)
        if not is_subscribed:
            eventbus.fire("rsync-finished-failure")
            return

        # Verify if the server-side project is a git repository.
        is_git_repo = self._verify_git_repository(iq, node, project_path)
        if not is_git_repo:
            return

        # The future reply iq.
        reply = iq.reply()

        # Prepare the merge verification with this data.
        from task import MergeTask
        dispatcher.put(node, MergeTask(node, sfrom))

        # Reply to the request.
        reply.send()
コード例 #5
0
    def _on_rsync_stanza(self, iq):
        """ Called when a Rsync stanza is received. This handler creates a
        new RsyncTask if permissions are good.
        """

        self.logger.info('Received a rsync stanza.')

        # Get the useful data.
        node = iq['rsync']['node']
        sid = iq['rsync']['sid']
        rid = iq['rsync']['rid']
        files = iq['rsync']['files']
        sfrom = iq['from']
        project_path = join(self.working_dir, node, sfrom.bare)

        # Verify if the user is a subscriber/owner of the node.
        is_subscribed = self._verify_subscription(iq, sfrom.bare, node)
        if not is_subscribed:
            eventbus.fire('rsync-finished-failure', rid=rid)
            return

        # The future reply iq.
        reply = iq.reply()

        # Create the new RsyncTask.
        from task import RsyncTask
        rsync_task = RsyncTask(sid, rid, sfrom, node, project_path, files)
        dispatcher.put(node, rsync_task)

        # Register the current rsync_task in the pending_rsyncs dict.
        self.pending_rsyncs[rid] = rsync_task

        # Reply to the IQ
        reply['rsync']
        reply.send()
コード例 #6
0
    def _on_git_init_stanza(self, iq):
        """ Called when a GitInit stanza is received. This handler creates a
        new GitInitTask if permissions are good.
        """

        self.logger.info("Received a git init stanza.")

        # Get the useful data.
        node = iq['git-init']['node']
        url = iq['git-init']['url']
        sfrom = iq['from'].bare

        # Ensure permissions.
        is_subscribed = self._verify_subscription(iq, sfrom, node)
        if not is_subscribed:
            eventbus.fire("rsync-finished-failure")
            return

        # Create a new GitInitTask
        from baboon.baboond.task import GitInitTask
        git_init_task = GitInitTask(node, url, sfrom)

        # Register the BaboonId of this GitInitTask in the
        # self.pending_git_init_tasks dict.
        self.pending_git_init_tasks[git_init_task.bid] = iq

        # Add the GitInitTask to the list of tasks to execute.
        dispatcher.put(node, git_init_task)
コード例 #7
0
ファイル: task.py プロジェクト: pierrezurek/baboon
    def _alert(self, project_name, username, dest_username,
               merge_conflict=False, conflict_files=[]):
        """ Creates a alert task to warn to the user the state of the
        merge.
        """

        dispatcher.put(project_name, AlertTask(project_name, username,
                                               dest_username, merge_conflict,
                                               conflict_files=conflict_files))
コード例 #8
0
    def _alert(self,
               project_name,
               username,
               dest_username,
               merge_conflict=False,
               conflict_files=[]):
        """ Creates a alert task to warn to the user the state of the
        merge.
        """

        dispatcher.put(
            project_name,
            AlertTask(project_name,
                      username,
                      dest_username,
                      merge_conflict,
                      conflict_files=conflict_files))