Exemple #1
0
#!/usr/bin/env python

import logging, urllib
import simplejson as json
from pprint import pprint

import mysql_layer as mysql
import twilio_layer as twilio
import user_layer as User
import alert_layer as Alert
import util_layer as Util

conf = Util.load_conf()
Util.init_logging("api")


class Api():
    '''
	This API class is designed to return json via http request
	Not even close to being done (obviously)
	'''
    def __init__(self, **data):
        '''
		Initialize the api class
		'''
        # set some default attribute values
        self.count = 20
        self.status_message = None
        self.name = None
        self.state = None
        self.phone = None
Exemple #2
0
# add this file location to sys.path
cmd_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if cmd_folder not in sys.path:
    sys.path.insert(-1, cmd_folder)
    sys.path.insert(-1, cmd_folder + "/classes")

import mysql_layer as mysql
import twilio_layer as twilio
import oncall
import user_layer as User
import alert_layer as Alert
import util_layer as Util

conf = Util.load_conf()
Util.init_logging("server")

# set port and IP to listen for alerts
# these are inhereited from the conf file
sys.argv = [conf['listen_ip'], conf['port']]

# debug mode
web.config.debug = conf['server_debug']

#load valid urls to listen to for http calls
urls = (
    #   '/alert/(.+)', 'alert',
    '/sms/(.+)',
    'sms',
    '/call/(.+)',
    'call',
Exemple #3
0
# add this file location to sys.path
cmd_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if cmd_folder not in sys.path:
     sys.path.insert(-1, cmd_folder)
     sys.path.insert(-1, cmd_folder + "/classes")

import mysql_layer as mysql
import twilio_layer as twilio
import oncall
import user_layer as User
import alert_layer as Alert
import api_layer as API
import util_layer as Util

conf = Util.load_conf()
Util.init_logging("api")

# set port and IP to listen for alerts
# these are inhereited from the conf file
sys.argv = [conf['api_listen_ip'],conf['api_port']]

# debug mode
web.config.debug = conf['server_debug']

#load valid urls to listen to for http calls
urls = (
    '/api/(.+)', 'api'
)
app = web.application(urls, globals())

class api:
Exemple #4
0
# add this file location to sys.path
cmd_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if cmd_folder not in sys.path:
     sys.path.insert(-1, cmd_folder)
     sys.path.insert(-1, cmd_folder + "/classes")

import mysql_layer as mysql
import twilio_layer as twilio
import user_layer as User
import alert_layer as Alert
import util_layer as Util

conf = Util.load_conf()

Util.init_logging("client")

def user():
	'''
	This function handles the rest of the command as it pertains to a user(s).
	'''
	# Parse the command line
	parser = OptionParser()
	parser.add_option('-i', '--id', dest='id', help='User id', type='int', default=0)
	parser.add_option('-n', '--name', dest='name', help='User name', type='string', default='')
	parser.add_option('-p', '--phone', dest='phone', help='Phone number', type='string', default='')
	parser.add_option('-e', '--email', dest='email', help='Email address', type='string', default='')
	parser.add_option('-t', '--team', dest='team', help='Team', type='string', default='')
	# default is set to 100 as an easy means of figuring out if an state is inputted by user
	parser.add_option('-s', '--state', dest='state', help='State (0 = in rotation, 3 = off rotation, 9 = global entity)', type='int', default=100)
	parser.add_option('-d', '--delete', dest='delete', help='Delete result of user list query', action="store_true", default=False)