def check_pulse(self):
        '''
        Read the pulse of this task.
        '''

        # increment pid counter
        self.pid_counter = self.pid_counter + 1

        if self.pid_counter > 10:
            self.pid_counter = 0

            # if no pid, stop running
            if not nexus_utils.get_pid(PID_NAME):
                print('No pid exists, stopping!')
                self.stop()

                # send slack message to channel
                slack_server.send_message(
                    contents='Epoch\'s Pulse has stopped! It died!?',
                    channel='#work-progress',
                    username='******',
                    icon_emoji=':boom:')

                # close db connection
                settings.getSettings().close()
                return
    def __init__(self):
        super(Pulse, self).__init__()
        self.stop_flag = threading.Event()

        # settings for this module
        self.box_settings = settings.getSettings()

        # counter for checking the .pid file
        self.pid_counter = 0

        # the timestamp of the last time the credit for user sessions happened
        self.credit_event = time.time()
        self.users = {}

        # create pid file
        nexus_utils.create_pid(PID_NAME)
Beispiel #3
0
#!/usr/bin/python

# local imports
from component import user
from component import user_session
from component import repo
from settings import settings
from util import slack_api

# python modules
import sys
import datetime
import time

# the icon's url used in the bot that sends the response
ICON_URL = settings.getSettings().company_icon

# configure a Slack server in order to send messages TO Slack
slack_api_url = settings.getSettings().slack_api_url
slack_headers = {'content-type': 'application/json'}
slack_server = slack_api.SlackAPI(api_url=slack_api_url, headers=slack_headers)


def handle_help_command():
    '''
	Handles the parsing of the help command.
	'''
    print('This module is invoked in the following ways: \n')
    print('python track.py help')
    print('- Display this message.\n')
    print('python track.py add')
#!/usr/bin/python

# local imports
from component import user
from component import user_session
from component import team
from settings import settings

# python modules
import requests
import json
import sys

# API Token for Slack, your app's xoxp- token (available on the Install App page)
TOKEN = settings.getSettings().slack_api_token

# the possible version control software we support
SUPPORTED_VCS = ['GitHub', 'BitBucket', 'GitLab']


def get_all_possible_users():
    '''
	Get a list of all possible users on this Slack.

	Returns:
		A list of users in the form of (user_id, user_name) for this Slack.
	'''

    result = []

    payload = {'token': TOKEN}
# local modules
from component import user
from component import user_session
from component import repo
from util import slack_api
from settings import settings

# python modules
from flask import Response
import time
import datetime
import json

# the icon's url used in the bot that sends the response
ICON_URL = settings.getSettings().company_icon
COMPANY_NAME = settings.getSettings().company_name
COMPANY_URL = settings.getSettings().company_url

# configure a Slack server in order to send messages TO Slack
slack_server = settings.getSlack()


def parse_request(data_form):
    '''
	Parses the request using the specified data_form.

	Args:
		data_form: The data form from the request

	Returns:
import logging, logging.handlers
import hmac
import hashlib

# File that the results of this script writes to
LOG_FILENAME = 'server_applet.log'
# construct logger
LOG = logging.getLogger('server_applet_log')
LOG.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, backupCount=5)
LOG.addHandler(handler)

app = Flask('Epoch')

# outgoing webhook key specified by Slack
SLACK_WEBHOOK_OUTGOING = settings.getSettings().slack_webhook
# outgoing webhook key specified by Github
GITHUB_WEBHOOK_OUTGOING = settings.getSettings().github_webhook
# outgoing webhook key specified by GitLab
GITLAB_WEBHOOK_OUTGOING = settings.getSettings().gitlab_webhook


@app.route('/services/slack', methods=['POST'])
def handle_slack_post():
    '''
    Serves Slack's POST requests to this applet.
    '''
    # TODO add try/catch here
    # TODO add access log

    # get the post request form