コード例 #1
0
 def __init__(self, subdomain, token):
     super(Emitter, self).__init__()
     logger.info('Making Campfire...')
     self.camp = Campfire(subdomain, token)
     logger.info('Rooms...')
     self.rooms = {}
     logger.info('Room...')
     self.camp.find_room_by_name('Testing').join()
     self.results = {}
     try:
         threading.Thread(target=reactor.run).start()
     except Exception:
         pass
コード例 #2
0
def campfire_notify(deployed=False):
    """Hop in Campfire and notify your developers of the time and commit SHA of
    an app deploy.

    Requires the pinder Python package and the env keys:

        deployment_type - app environment
        release - the commit SHA or git tag of the deployed version
        scm_http_url - path to an HTTP view of the remote git repository
        campfire_subdomain - subdomain of your Campfire account
        campfire_token - API token for Campfire
        campfire_room - the room to join and notify (the string name, e.g.
                        "Developers")
    """
    require('deployment_type')
    require('release')

    if (deployed and env.campfire_subdomain and env.campfire_token
            and env.campfire_room):
        from pinder import Campfire
        deploying = local('git rev-list --abbrev-commit %s | head -n 1' %
                          env.release,
                          capture=True)
        branch = utils.branch(env.release)

        if env.tagged:
            require('release')
            branch = env.release

        name = env.unit
        deployer = os.getlogin()
        deployed = env.deployed_version
        target = env.deployment_type.lower()
        source_repo_url = env.scm_http_url
        compare_url = ('%s/compare/%s...%s' %
                       (source_repo_url, deployed, deploying))

        campfire = Campfire(env.campfire_subdomain,
                            env.campfire_token,
                            ssl=True)
        room = campfire.find_room_by_name(env.campfire_room)
        room.join()
        if deployed:
            message = ('%s is deploying %s %s (%s..%s) to %s %s' %
                       (deployer, name, branch, deployed, deploying, target,
                        compare_url))
        else:
            message = ('%s is deploying %s %s to %s' %
                       (deployer, name, branch, target))
        room.speak(message)
        print 'Campfire notified that %s' % message
コード例 #3
0
ファイル: pewbot.py プロジェクト: luchux/pewbot
    def __init__(self, *kwargs, **args):
        self.campfire = Campfire(CAMPFIRE_DOMAIN, API_KEY)
        self.ignore_users.append(self.pewbot_userid)

        for room in CAMPFIRE_ROOMS:
            croom = self.campfire.room(room)
            croom.join()
            self.rooms.append(croom)

        self.commands = self._discover_commands()

        if 'test' in args:
            _handle_message('melbourne', None)
        else:
            while len(self.rooms) > 0:
                try:
                    self._fetch_messages()
                    sleep(2)  # have a rest, pewbot
                except Exception as e:
                    print e
コード例 #4
0
ファイル: fabfile.py プロジェクト: cash2one/source
 def decorated(*args, **kwargs):
     from pinder import Campfire
     if not 'campfire_domain' in env:
         return
     if not 'current_release' in env:
         releases()
     if 'git_branch' not in env:
         env.git_branch = "master"
     deployed = run("cd %(current_release)s; git rev-parse HEAD" % env)[:7]
     deploying = run(
         "cd %(current_release)s; git fetch deploy; git rev-parse deploy/%(git_branch)s"
         % env)[:7]
     return_value = func(*args, **kwargs)
     c = Campfire(env.campfire_domain, env.campfire_token, ssl=True)
     room = c.find_room_by_name(env.campfire_room)
     compare_url = "%(repo_url)s/compare/%(deployed)s...%(deploying)s" % {
         'repo_url': env.github_url,
         'deployed': deployed,
         'deploying': deploying
     }
     room.speak("%s has deployed new code on %s : %s" %
                (env.user, env.name, compare_url))
     return return_value
コード例 #5
0
    def send(self, payload):
        campfire = Campfire(self.options['subdomain'], self.options['token'])
        room = campfire.find_room_by_name(self.options['room'])
        if room is None:
            logger.error("Could not join the room %s to send payload %r Options: %r",
                         self.options['room'], payload, self.options)
            return

        if payload['model'] == 'Comment':
            message = '%s %s. commented "%s" on %s "%s" (#%s) %s' % (
                payload['attributes']['created_by']['first_name'],
                payload['attributes']['created_by']['last_name'][0],
                '%s...' % payload['attributes']['body'][0:50], 
                payload['attributes']['item']['type'],
                payload['attributes']['item']['title'],
                payload['attributes']['item']['number'],
                payload['attributes']['item']['short_url'])
        elif payload['model'] == 'Item':
            message = '%s %s. created the %s "%s" (#%s) %s' % (
                payload['attributes']['created_by']['first_name'],
                payload['attributes']['created_by']['last_name'][0],
                payload['attributes']['type'],
                payload['attributes']['title'],
                payload['attributes']['number'],
                payload['attributes']['short_url'])

            if payload['attributes']['assigned_to'] and \
                payload['attributes']['assigned_to']['id'] != \
                payload['attributes']['created_by']['id']:
                message += ' and assigned it to %s %s.' % (
                    payload['attributes']['assigned_to']['first_name'],
                    payload['attributes']['assigned_to']['last_name'][0])
        elif payload['model'] == 'Block':
            message = '%s %s. indicated the %s "%s" (#%s) %s is blocked on the %s "%s" (#%s) %s' % (
                payload['attributes']['user']['first_name'],
                payload['attributes']['user']['last_name'][0],
                payload['attributes']['blocked']['type'],
                payload['attributes']['blocked']['title'],
                payload['attributes']['blocked']['number'],
                payload['attributes']['blocked']['short_url'],
                payload['attributes']['item']['type'],
                payload['attributes']['item']['title'],
                payload['attributes']['item']['number'],
                payload['attributes']['item']['short_url'])

            if payload['attributes']['item']['assigned_to']:
                message += ', which is owned by %s %s.' % (
                    payload['attributes']['item']['assigned_to']['first_name'],
                    payload['attributes']['item']['assigned_to']['last_name'][0])
        elif payload['model'] == 'Favorite':
            message = '%s %s. favorited the %s "%s" (#%s) %s' % (
                payload['attributes']['user']['first_name'],
                payload['attributes']['user']['last_name'][0],
                payload['attributes']['item']['type'],
                payload['attributes']['item']['title'],
                payload['attributes']['item']['number'],
                payload['attributes']['item']['short_url'])
        elif payload['model'] == 'Deploy':
            message = '%s %s. deployed %s items to %s.' % (
                payload['attributes']['user']['first_name'],
                payload['attributes']['user']['last_name'][0],
                len(payload['attributes']['items']),
                payload['attributes']['environment'])
        else:
            message = None

        if not message:
            return

        room.join()
        result = room.speak(message)