Example #1
0
    def __run__(self, time):
        info = self.get_build_info()
        issues = []
        curr = self.getReportedIssues()
        for i in info:
            if safe_read_dictionary(i, 'pull_request') is None:
                if str(i['id']) not in curr:
                    urls = re.findall(
                        'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
                        i['body'])

                    img = ''
                    bodyText = i['body']
                    if len(urls) > 0:
                        img = urls[0]
                        bodyText = bodyText.replace(img, '')

                    Timeline.add_item_from_bot(
                        i['user']['login'] + ' reported an issue',
                        i['title'] + '. ' + bodyText,
                        img,
                        Icons.Github,
                        IconBackgrounds.Yellow,
                    )
                issues.append(i['id'])
        self.writeReportedIssues(issues)
        print(self.getReportedIssues())
Example #2
0
    def __run__(self, time):
        if time['hour'] == '13' and time['min'] == '15':
            result = urlopen(
                "http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=spc1").read()
            result = result.decode('utf-8').strip().split(',')

            direction = 'down'

            if float(result[2]) > 0:
                direction = 'up'

            msg = template.format(
                result[1].replace('.', ' point '), direction,
                result[2].replace('.', ' point ').replace('-', ''), '')
            Bot.speak(msg)

            if direction == 'up':
                icon_back = IconBackgrounds.Green
                speak = random.choice(praise)
                Bot.speak(speak)
            else:
                icon_back = IconBackgrounds.Red
                speak = random.choice(motivate)
                Bot.speak(speak)

            Timeline.add_item_from_bot(
                'Stock update',
                template.format(result[1], direction,
                                result[2].replace('-', ''), speak), '',
                Icons.LineChart, icon_back)
Example #3
0
    def __run__(self, time):
        if time['hour'] == '12' and time['min'] == '00':
            w = Weather.get_weather('98052')

            message = 'The weather right now at {0} is {1}, and the temperature is around {2} degrees fahrenheit.' \
                .format(w['name'], w['weather'][0]['main'], w['main']['temp'])

            Timeline.add_item_from_bot('Weather Report', message, '',
                                       Icons.Cloud, IconBackgrounds.Blue)
Example #4
0
 def __run__(self, time):
     if time['hour'] == '12' and time['min'] == '39':
         pictures = os.listdir(UPLOAD_FOLDER_PATH + '/redbull')
         d0 = datetime.datetime.now().date()
         d1 = datetime.date(2015, 7, 24)
         delta = d1 - d0
         print('{0} days to GA'.format(delta.days))
         Timeline.add_item_from_bot('{0} days to GA :)'.format(delta.days),
                                    '',
                                    pictures[delta.days % len(pictures)],
                                    Icons.Announcement,
                                    IconBackgrounds.Blue)
Example #5
0
    def __run__(self, time):
        # 7 == PR Build & 1 == master
        if time['simulate'] is not True:
            BuildNotifier.notify_pr_build_results(
                self.get_latest_pr_build_results(self.get_build_info(
                    '7', '50')))
            brokenMasterBuilds = self.get_broken_master_builds(
                self.get_build_info('1', '5'))
        else:
            brokenMasterBuilds = dummyBreak

        if len(brokenMasterBuilds) == 0:
            if BuildNotifier.build_was_broken():
                BuildNotifier.set_build_broken(False)
                BuildNotifier.notify_all_clear()
                Timeline.add_item_from_bot('BUILD BREAK FIXED',
                                           'Thank you for taking care of it',
                                           '', Icons.Wrench,
                                           IconBackgrounds.Green)
                print('Sent all clear notification')
            else:
                print('Was not broken previously too, so do nothing new')
        else:
            if not BuildNotifier.build_was_broken():
                culprits = []
                for b in brokenMasterBuilds:
                    culprits.append(self.get_user_info_from_build(b))
                BuildNotifier.notify_build_break(culprits)
                BuildNotifier.set_build_broken(True)
                Timeline.add_item_from_bot(
                    'BUILD BREAK',
                    '{0} broke the build. Change was requested by {1}'.format(
                        brokenMasterBuilds[len(brokenMasterBuilds) -
                                           1]['buildNumber'],
                        brokenMasterBuilds[len(brokenMasterBuilds) -
                                           1]['requestedFor']['displayName']),
                    '', Icons.Ambulance, IconBackgrounds.Red)
                print('Sent build break notification')
            else:
                print('Was broken previously too, so do nothing')
Example #6
0
File: vso.py Project: 0x27/redalert
    def __run__(self, time):
        # 7 == PR Build & 1 == master
        if time["simulate"] is not True:
            BuildNotifier.notify_pr_build_results(self.get_latest_pr_build_results(self.get_build_info("7", "50")))
            brokenMasterBuilds = self.get_broken_master_builds(self.get_build_info("1", "5"))
        else:
            brokenMasterBuilds = dummyBreak

        if len(brokenMasterBuilds) == 0:
            if BuildNotifier.build_was_broken():
                BuildNotifier.set_build_broken(False)
                BuildNotifier.notify_all_clear()
                Timeline.add_item_from_bot(
                    "BUILD BREAK FIXED", "Thank you for taking care of it", "", Icons.Wrench, IconBackgrounds.Green
                )
                print("Sent all clear notification")
            else:
                print("Was not broken previously too, so do nothing new")
        else:
            if not BuildNotifier.build_was_broken():
                culprits = []
                for b in brokenMasterBuilds:
                    culprits.append(self.get_user_info_from_build(b))
                BuildNotifier.notify_build_break(culprits)
                BuildNotifier.set_build_broken(True)
                Timeline.add_item_from_bot(
                    "BUILD BREAK",
                    "{0} broke the build. Change was requested by {1}".format(
                        brokenMasterBuilds[len(brokenMasterBuilds) - 1]["buildNumber"],
                        brokenMasterBuilds[len(brokenMasterBuilds) - 1]["requestedFor"]["displayName"],
                    ),
                    "",
                    Icons.Ambulance,
                    IconBackgrounds.Red,
                )
                print("Sent build break notification")
            else:
                print("Was broken previously too, so do nothing")
Example #7
0
    def __run__(self, time):
        info = self.get_build_info()
        issues = []
        curr = self.getReportedIssues()
        for i in info:
            if safe_read_dictionary(i, 'pull_request') is None:
                if str(i['id']) not in curr:
                    urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
                                      i['body'])

                    img = ''
                    bodyText = i['body']
                    if len(urls) > 0:
                        img = urls[0]
                        bodyText = bodyText.replace(img, '')

                    Timeline.add_item_from_bot(i['user']['login'] + ' reported an issue',
                                               i['title'] + '. ' + bodyText,
                                               img,
                                               Icons.Github,
                                               IconBackgrounds.Yellow,)
                issues.append(i['id'])
        self.writeReportedIssues(issues)
        print(self.getReportedIssues())
Example #8
0
__author__ = 'sachinpatney'


import sys

sys.path.append('/var/www/git/redalert/tasks')

from common import Timeline

name = sys.argv[1]
title = sys.argv[2]
content = sys.argv[3]
icon = sys.argv[4]
iconBack = sys.argv[5]
img = ''

if len(sys.argv) > 6:
    img = sys.argv[6]

Timeline.add_item(name, title, content, img, icon, iconBack)