Esempio n. 1
0
    def start_services(self):
        # HTTPS server
        sockets = tornado.netutil.bind_sockets(
            self.port, address=Settings['main_app']['servername'])
        redir_sockets = tornado.netutil.bind_sockets(
            self.redir_port, address=Settings['main_app']['servername'])
        tornado.process.fork_processes(Settings['tornado']['num_workers'])

        server = tornado.httpserver.HTTPServer(
            self.main_app,
            ssl_options={
                'certfile': Settings['main_app']['ssl_certfile'],
                # This really should be read into a string so we can drop privileges
                # after reading the key but before starting the server, but Python
                # doesn't let us use strings for keys until Python 3.2 :(
                'keyfile': Settings['main_app']['ssl_keyfile'],
            })
        server.add_sockets(sockets)

        # HTTP server (to redirect to HTTPS)
        redir_server = tornado.httpserver.HTTPServer(self.redir_app)
        redir_server.add_sockets(redir_sockets)

        # Start the mail, git, reviewboard and XMPP queue handlers
        MailQueue.start_worker()
        GitQueue.start_worker()
        RBQueue.start_worker()
        XMPPQueue.start_worker()
Esempio n. 2
0
def send_notifications(people, pushtype, pushurl):
    pushmanager_servername = Settings['main_app']['servername']
    pushmanager_servername = pushmanager_servername.rstrip('/')
    pushmanager_port = ':%d' % Settings['main_app']['port'] if Settings[
        'main_app']['port'] != 443 else ''

    pushurl = pushurl.lstrip('/')
    pushmanager_url = "https://%s/%s" % (pushmanager_servername +
                                         pushmanager_port, pushurl)

    if people:
        msg = '%s: %s push starting! %s' % (', '.join(people), pushtype,
                                            pushmanager_url)
        XMPPQueue.enqueue_user_xmpp(people,
                                    'Push starting! %s' % pushmanager_url)
    elif pushtype == 'morning':
        msg = 'Morning push opened. %s' % pushmanager_servername
    else:
        msg = 'push starting. %s' % pushmanager_url

    subprocess.call([
        '/nail/sys/bin/nodebot', '-i', Settings['irc']['nickname'],
        Settings['irc']['channel'], msg
    ])

    subject = "New push notification"
    MailQueue.enqueue_user_email(Settings['mail']['notifyall'], msg, subject)
Esempio n. 3
0
def send_notifications(people, pushtype, pushurl):
    pushmanager_servername = Settings['main_app']['servername']
    pushmanager_servername = pushmanager_servername.rstrip('/')
    pushmanager_port = ':%d' % Settings['main_app']['port'] if Settings['main_app']['port'] != 443 else ''

    pushurl = pushurl.lstrip('/')
    pushmanager_url = "https://%s/%s" % (pushmanager_servername + pushmanager_port, pushurl)

    if people:
        msg = '%s: %s push starting! %s' % (', '.join(people), pushtype, pushmanager_url)
        XMPPQueue.enqueue_user_xmpp(people, 'Push starting! %s' % pushmanager_url)
    elif pushtype == 'morning':
        msg = 'Morning push opened. %s' % pushmanager_servername
    else:
        msg = 'push starting. %s' % pushmanager_url

    subprocess.call([
        '/nail/sys/bin/nodebot',
        '-i',
        Settings['irc']['nickname'],
        Settings['irc']['channel'],
        msg
    ])

    subject = "New push notification"
    MailQueue.enqueue_user_email(Settings['mail']['notifyall'], msg, subject)
Esempio n. 4
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        _, staged_requests, push_result = db_results
        push = push_result.fetchone()

        for req in staged_requests:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = (
                """
                <p>
                    %(pushmaster)s has deployed request for %(user)s to %(pushstage)s:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Once you've checked that it works, mark it as verified here:
                    <a href="https://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s">
                        https://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s
                    </a>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
                ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'pushmanager_servername': Settings['main_app']['servername'],
                    'pushmanager_port' : ':%d' % Settings['main_app']['port'] if Settings['main_app']['port'] != 443 else '',
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                    'pushid': self.pushid,
                    'pushstage': push['stageenv'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)

            msg = '%(pushmaster)s has deployed request "%(title)s" for %(user)s to %(pushstage)s.\nPlease verify it at https://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s' % {
                    'pushmaster': self.current_user,
                    'pushmanager_servername': Settings['main_app']['servername'],
                    'pushmanager_port': ':%d' % Settings['main_app']['port'] if Settings['main_app']['port'] != 443 else '',
                    'title': req['title'],
                    'pushid': self.pushid,
                    'user': user_string,
                    'pushstage': push['stageenv'],
                }
            XMPPQueue.enqueue_user_xmpp(users, msg)

        if push['extra_pings']:
            for user in push['extra_pings'].split(','):
                XMPPQueue.enqueue_user_xmpp([user], '%s has deployed a push to stage.' % self.current_user)
Esempio n. 5
0
def send_notifications(people, pushtype, pushmanager_url):
    pushmanager_servername = Settings['main_app']['servername']

    if people:
        msg = '%s: %s push starting! %s' % (', '.join(people), pushtype, pushmanager_url)
        XMPPQueue.enqueue_user_xmpp(people, 'Push starting! %s' % pushmanager_url)
    elif pushtype == 'morning':
        msg = 'Morning push opened. %s' % pushmanager_servername
    else:
        msg = 'push starting. %s' % pushmanager_url

    if people:
        send_people_msg_in_groups(
            people, "%s push starting! %s" % (pushtype, pushmanager_url),
            Settings['irc']['nickname'], Settings['irc']['channel'],
            person_per_group=5, prefix_msg=''
        )
    else:
        subprocess.call([
            '/nail/sys/bin/nodebot',
            '-i',
            Settings['irc']['nickname'],
            Settings['irc']['channel'],
            msg
        ])

    subject = "New push notification"
    MailQueue.enqueue_user_email(Settings['mail']['notifyall'], msg, subject)
Esempio n. 6
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        _, staged_requests, push_result = db_results
        push = push_result.fetchone()

        for req in staged_requests:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = ("""
                <p>
                    %(pushmaster)s has deployed request for %(user)s to %(pushstage)s:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Once you've checked that it works, mark it as verified here:
                    <a href="%(pushmanager_base_url)s/push?id=%(pushid)s">
                        %(pushmanager_base_url)s/push?id=%(pushid)s
                    </a>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>""") % pushmanager.core.util.EscapedDict(
                {
                    'pushmaster': self.current_user,
                    'pushmanager_base_url': self.get_base_url(),
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                    'pushid': self.pushid,
                    'pushstage': push['stageenv'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)

            msg = '{0} has deployed request "{1}" for {2} to {3}.\nPlease verify it at {4}/push?id={5}'.format(
                self.current_user,
                req['title'],
                user_string,
                push['stageenv'],
                self.get_base_url(),
                self.pushid,
            )
            XMPPQueue.enqueue_user_xmpp(users, msg)

        if push['extra_pings']:
            for user in push['extra_pings'].split(','):
                XMPPQueue.enqueue_user_xmpp(
                    [user],
                    '%s has deployed a push to stage.' % self.current_user)
Esempio n. 7
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        _, staged_requests, push_result = db_results
        push = push_result.fetchone()

        for req in staged_requests:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = (
                """
                <p>
                    %(pushmaster)s has deployed request for %(user)s to %(pushstage)s:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Once you've checked that it works, mark it as verified here:
                    <a href="%(pushmanager_base_url)s/push?id=%(pushid)s">
                        %(pushmanager_base_url)s/push?id=%(pushid)s
                    </a>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
                ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'pushmanager_base_url': self.get_base_url(),
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                    'pushid': self.pushid,
                    'pushstage': push['stageenv'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)

            msg = '{0} has deployed request "{1}" for {2} to {3}.\nPlease verify it at {4}/push?id={5}'.format(
                self.current_user,
                req['title'],
                user_string,
                push['stageenv'],
                self.get_base_url(),
                self.pushid,
            )
            XMPPQueue.enqueue_user_xmpp(users, msg)

        if push['extra_pings']:
            for user in push['extra_pings'].split(','):
                XMPPQueue.enqueue_user_xmpp([user], '%s has deployed a push to stage.' % self.current_user)
Esempio n. 8
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        push = db_results[0].first()
        unfinished_requests = db_results[2].first()
        pushmanager_base_url = self.get_base_url()
        if not unfinished_requests:
            msg = "All currently staged requests in %s/push?id=%s have been marked as verified." % \
                (pushmanager_base_url, self.pushid)
            XMPPQueue.enqueue_user_xmpp([push['user']], msg)
Esempio n. 9
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        push = db_results[0].first()
        unfinished_requests = db_results[2].first()
        pushmanager_base_url = self.get_base_url()
        if not unfinished_requests:
            msg = "All currently staged requests in %s/push?id=%s have been marked as verified." % \
                (pushmanager_base_url, self.pushid)
            XMPPQueue.enqueue_user_xmpp([push['user']], msg)
Esempio n. 10
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        push = db_results[0].first()
        unfinished_requests = db_results[2].first()
        pushmanager_servername = Settings['main_app']['servername']
        pushmanager_port = ':%d' % Settings['main_app']['port'] if Settings['main_app']['port'] != 443 else ''
        if not unfinished_requests:
            msg = "All currently staged requests in https://%s/push?id=%s have been marked as verified." % \
                (pushmanager_servername + pushmanager_port, self.pushid)
            XMPPQueue.enqueue_user_xmpp([push['user']], msg)
Esempio n. 11
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        push = db_results[0].first()
        unfinished_requests = db_results[2].first()
        pushmanager_servername = Settings['main_app']['servername']
        pushmanager_port = ':%d' % Settings['main_app']['port'] if Settings[
            'main_app']['port'] != 443 else ''
        if not unfinished_requests:
            msg = "All currently staged requests in https://%s/push?id=%s have been marked as verified." % \
                (pushmanager_servername + pushmanager_port, self.pushid)
            XMPPQueue.enqueue_user_xmpp([push['user']], msg)
Esempio n. 12
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        reqs, _, _ = db_results
        removal_dicts = []
        for req in reqs:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = ("""
                <p>
                    %(pushmaster)s has removed request for %(user)s from a push:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>""") % pushmanager.core.util.EscapedDict(
                {
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '%(pushmaster)s has removed request "%(title)s" for %(user)s from a push' % {
                'pushmaster': self.current_user,
                'title': req['title'],
                'pushid': self.pushid,
                'user': user_string,
            }
            XMPPQueue.enqueue_user_xmpp(users, msg)
            removal_dicts.append({
                'request': req['id'],
                'push': self.pushid,
                'reason': 'removal after %s' % req['state'],
                'pushmaster': self._current_user,
                'timestamp': int(time.time()),
            })

        removal_queries = [
            db.push_removals.insert(removal) for removal in removal_dicts
        ]
        db.execute_transaction_cb(removal_queries, self.on_db_insert_complete)
Esempio n. 13
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        reqs, _, _ = db_results
        removal_dicts = []
        for req in reqs:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = (
                """
                <p>
                    %(pushmaster)s has removed request for %(user)s from a push:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
                ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '%(pushmaster)s has removed request "%(title)s" for %(user)s from a push' % {
                    'pushmaster': self.current_user,
                    'title': req['title'],
                    'pushid': self.pushid,
                    'user': user_string,
                }
            XMPPQueue.enqueue_user_xmpp(users, msg)
            removal_dicts.append({
                'request': req['id'],
                'push': self.pushid,
                'reason': 'removal after %s' % req['state'],
                'pushmaster': self._current_user,
                'timestamp': int(time.time()),
            })

        removal_queries = [db.push_removals.insert(removal) for removal in removal_dicts]
        db.execute_transaction_cb(removal_queries, self.on_db_insert_complete)
Esempio n. 14
0
    def start_services(self):
        # HTTPS server
        sockets = tornado.netutil.bind_sockets(self.port, address=Settings['main_app']['servername'])
        redir_sockets = tornado.netutil.bind_sockets(self.redir_port, address=Settings['main_app']['servername'])

        # Start the mail, git, reviewboard and XMPP queue handlers
        worker_pids = []
        worker_pids.extend(MailQueue.start_worker())
        worker_pids.extend(RBQueue.start_worker())
        worker_pids.extend(XMPPQueue.start_worker())
        worker_pids.extend(GitQueue.start_worker())
        for worker_pid in worker_pids:
            pid.write(self.pid_file, append=True, pid=worker_pid)
        self.queue_worker_pids.extend(worker_pids)

        tornado.process.fork_processes(Settings['tornado']['num_workers'])

        server = tornado.httpserver.HTTPServer(self.main_app, ssl_options={
                'certfile': Settings['main_app']['ssl_certfile'],
                # This really should be read into a string so we can drop privileges
                # after reading the key but before starting the server, but Python
                # doesn't let us use strings for keys until Python 3.2 :(
                'keyfile': Settings['main_app']['ssl_keyfile'],
                })
        server.add_sockets(sockets)

        # HTTP server (to redirect to HTTPS)
        redir_server = tornado.httpserver.HTTPServer(self.redir_app)
        redir_server.add_sockets(redir_sockets)
Esempio n. 15
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        _, blessed_requests, push_results = db_results
        for req in blessed_requests:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = ("""
                <p>
                    %(pushmaster)s has deployed request for %(user)s to production:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>""") % pushmanager.core.util.EscapedDict(
                {
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '%(pushmaster)s has deployed request "%(title)s" for %(user)s to production.' % {
                'pushmaster': self.current_user,
                'title': req['title'],
                'user': user_string,
            }
            XMPPQueue.enqueue_user_xmpp(users, msg)

        push = push_results.fetchone()
        if push['extra_pings']:
            for user in push['extra_pings'].split(','):
                XMPPQueue.enqueue_user_xmpp(
                    [user], '%s has deployed a push to production.' %
                    self.current_user)

        self.finish()
Esempio n. 16
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        for req in db_results[-1]:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = ("""
                <p>
                    %(pushmaster)s has accepted request for %(user)s into a push:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>""") % pushmanager.core.util.EscapedDict(
                {
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '%(pushmaster)s has accepted request "%(title)s" for %(user)s into a push:\nhttps://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s' % {
                'pushmanager_servername':
                Settings['main_app']['servername'],
                'pushmanager_port':
                ':%d' % Settings['main_app']['port']
                if Settings['main_app']['port'] != 443 else '',
                'pushmaster':
                self.current_user,
                'title':
                req['title'],
                'pushid':
                self.pushid,
                'user':
                user_string,
            }
            XMPPQueue.enqueue_user_xmpp(users, msg)
Esempio n. 17
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        _, blessed_requests, push_results = db_results
        for req in blessed_requests:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = (
                """
                <p>
                    %(pushmaster)s has deployed request for %(user)s to production:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
                ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '%(pushmaster)s has deployed request "%(title)s" for %(user)s to production.' % {
                    'pushmaster': self.current_user,
                    'title': req['title'],
                    'user': user_string,
                }
            XMPPQueue.enqueue_user_xmpp(users, msg)

        push = push_results.fetchone()
        if push['extra_pings']:
            for user in push['extra_pings'].split(','):
                XMPPQueue.enqueue_user_xmpp([user], '%s has deployed a push to production.' % self.current_user)

        self.finish()
Esempio n. 18
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        for req in db_results[-1]:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = (
                """
                <p>
                    %(pushmaster)s has accepted request for %(user)s into a push:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
                ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '%(pushmaster)s has accepted request "%(title)s" for %(user)s into a push:\nhttps://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s' % {
                'pushmanager_servername': Settings['main_app']['servername'],
                'pushmanager_port': ':%d' % Settings['main_app']['port'] if Settings['main_app']['port'] != 443 else '',
                'pushmaster': self.current_user,
                'title': req['title'],
                'pushid': self.pushid,
                'user': user_string,
            }
            XMPPQueue.enqueue_user_xmpp(users, msg)
Esempio n. 19
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        for req in db_results[-1]:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = (
                """
                <p>
                    %(pushmaster)s has accepted request for %(user)s into a push:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
                ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '{0} has accepted request "{1}" for {2} into a push:\n{3}/push?id={4}'.format(
                self.current_user,
                req['title'],
                user_string,
                self.get_base_url(),
                self.pushid,
            )
            XMPPQueue.enqueue_user_xmpp(users, msg)
Esempio n. 20
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        if db_results:
            req = db_results[1].first()
            msg = (
                """
                <p>
                    %(pushmaster)s has commented on your request:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <pre>
%(comment)s
                </pre>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
            ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'user': req['user'],
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                    'comment': self.comment,
                })
            subject = "[push comment] %s - %s" % (req['user'], req['title'])
            MailQueue.enqueue_user_email([req['user']], msg, subject)
            msg = '%(pushmaster)s has commented on your request "%(title)s":\n%(comment)s' % {
                    'pushmaster': self.current_user,
                    'title': req['title'],
                    'comment': self.comment,
                }
            XMPPQueue.enqueue_user_xmpp([req['user']], msg)
            newcomments = req[db.push_requests.c.comments]
            self.write(xhtml_escape(newcomments))
Esempio n. 21
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        for req in db_results[-1]:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = ("""
                <p>
                    %(pushmaster)s has accepted request for %(user)s into a push:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>""") % pushmanager.core.util.EscapedDict(
                {
                    'pushmaster': self.current_user,
                    'user': user_string,
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)
            msg = '{0} has accepted request "{1}" for {2} into a push:\n{3}/push?id={4}'.format(
                self.current_user,
                req['title'],
                user_string,
                self.get_base_url(),
                self.pushid,
            )
            XMPPQueue.enqueue_user_xmpp(users, msg)
Esempio n. 22
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        if db_results:
            req = db_results[1].first()
            msg = (
                """
                <p>
                    %(pushmaster)s has commented on your request:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <pre>
%(comment)s
                </pre>
                <p>
                    Regards,<br />
                    PushManager
                </p>"""
            ) % pushmanager.core.util.EscapedDict({
                    'pushmaster': self.current_user,
                    'user': req['user'],
                    'title': req['title'],
                    'repo': req['repo'],
                    'branch': req['branch'],
                    'comment': self.comment,
                })
            subject = "[push comment] %s - %s" % (req['user'], req['title'])
            MailQueue.enqueue_user_email([req['user']], msg, subject)
            msg = '%(pushmaster)s has commented on your request "%(title)s":\n%(comment)s' % {
                    'pushmaster': self.current_user,
                    'title': req['title'],
                    'comment': self.comment,
                }
            XMPPQueue.enqueue_user_xmpp([req['user']], msg)
            newcomments = req[db.push_requests.c.comments]
            self.write(xhtml_escape(newcomments))
Esempio n. 23
0
    def on_db_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        _, staged_requests, push_result = db_results
        push = push_result.fetchone()

        for req in staged_requests:
            if req['watchers']:
                user_string = '%s (%s)' % (req['user'], req['watchers'])
                users = [req['user']] + req['watchers'].split(',')
            else:
                user_string = req['user']
                users = [req['user']]
            msg = ("""
                <p>
                    %(pushmaster)s has deployed request for %(user)s to %(pushstage)s:
                </p>
                <p>
                    <strong>%(user)s - %(title)s</strong><br />
                    <em>%(repo)s/%(branch)s</em>
                </p>
                <p>
                    Once you've checked that it works, mark it as verified here:
                    <a href="https://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s">
                        https://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s
                    </a>
                </p>
                <p>
                    Regards,<br />
                    PushManager
                </p>""") % pushmanager.core.util.EscapedDict({
                'pushmaster':
                self.current_user,
                'pushmanager_servername':
                Settings['main_app']['servername'],
                'pushmanager_port':
                ':%d' % Settings['main_app']['port']
                if Settings['main_app']['port'] != 443 else '',
                'user':
                user_string,
                'title':
                req['title'],
                'repo':
                req['repo'],
                'branch':
                req['branch'],
                'pushid':
                self.pushid,
                'pushstage':
                push['stageenv'],
            })
            subject = "[push] %s - %s" % (user_string, req['title'])
            MailQueue.enqueue_user_email(users, msg, subject)

            msg = '%(pushmaster)s has deployed request "%(title)s" for %(user)s to %(pushstage)s.\nPlease verify it at https://%(pushmanager_servername)s%(pushmanager_port)s/push?id=%(pushid)s' % {
                'pushmaster':
                self.current_user,
                'pushmanager_servername':
                Settings['main_app']['servername'],
                'pushmanager_port':
                ':%d' % Settings['main_app']['port']
                if Settings['main_app']['port'] != 443 else '',
                'title':
                req['title'],
                'pushid':
                self.pushid,
                'user':
                user_string,
                'pushstage':
                push['stageenv'],
            }
            XMPPQueue.enqueue_user_xmpp(users, msg)

        if push['extra_pings']:
            for user in push['extra_pings'].split(','):
                XMPPQueue.enqueue_user_xmpp(
                    [user],
                    '%s has deployed a push to stage.' % self.current_user)
Esempio n. 24
0
    def pickme_conflict_detected(cls, updated_request, send_notifications, pushmanager_url):
        msg = (
            """
            <p>
                PushManager has detected that your pickme contains conflicts with %(conflicts_with)s.
            </p>
            <p>
                <strong>%(user)s - %(title)s</strong><br />
                <em>%(repo)s/%(branch)s</em><br />
                <a href="%(pushmanager_url)s/request?id=%(id)s">%(pushmanager_url)s/request?id=%(id)s</a>
            </p>
            <p>
                Review # (if specified): <a href="https://%(reviewboard_servername)s/r/%(reviewid)s">%(reviewid)s</a>
            </p>
            <p>
                <code>%(revision)s</code><br/>
                <em>(If this is <strong>not</strong> the revision you expected,
                make sure you've pushed your latest version to the correct repo!)</em>
            </p>
            <p>
                %(conflicts)s
            </p>
            <p>
                Regards,<br/>
                PushManager
            </p>
            """
        )
        updated_request.update(
            {
                'conflicts_with': (
                    "master"
                    if 'conflict-master' in updated_request['tags']
                    else "another pickme"
                ),
                'conflicts': updated_request['conflicts'].replace('\n', '<br/>'),
                'reviewboard_servername': Settings['reviewboard']['servername'],
                'pushmanager_url' : pushmanager_url
            }
        )
        escaped_request = EscapedDict(updated_request)
        escaped_request.unescape_key('conflicts')
        msg %= escaped_request
        subject = (
            '[push conflict] %s - %s'
            % (updated_request['user'], updated_request['title'])
        )
        user_to_notify = updated_request['user']
        MailQueue.enqueue_user_email([user_to_notify], msg, subject)

        msg = """PushManager has detected that your pickme for %(pickme_name)s contains conflicts with %(conflicts_with)s
            %(pushmanager_url)s/request?id=%(pickme_id)s""" % {
                'conflicts_with': (
                    "master"
                    if 'conflict-master' in updated_request['tags']
                    else "another pickme"
                ),
                'pickme_name': updated_request['branch'],
                'pickme_id': updated_request['id'],
                'pushmanager_url' : pushmanager_url
            }
        XMPPQueue.enqueue_user_xmpp([user_to_notify], msg)