Example #1
0
def init(dbs=[], services={}, templates=False):
	"""Initialise

	Starts up most of the modules needed to support REST and Services

	Arguments:
		dbs (str[]): List of DBs to start up
		services (dict): Dictionary of service name to instance being managed
			by the caller

	Returns:
		REST.Config
	"""

	# Load the config
	Conf.load('config.json')
	sConfOverride = 'config.%s.json' % platform.node()
	if os.path.isfile(sConfOverride):
		Conf.load_merge(sConfOverride)

	# Add the global prepend
	Record_Base.dbPrepend(Conf.get(("mysql", "prepend"), ''))

	# Go through the list of DBs requested
	for s in dbs:
		Record_MySQL.addHost(s, Conf.get(("mysql", "hosts", s)))

	# Init the Sesh module
	Sesh.init(Conf.get(("redis", "primary")))

	# Create the REST config instance
	oRestConf = REST.Config(Conf.get("rest"))

	# Set verbose mode if requested
	if 'VERBOSE' in os.environ and os.environ['VERBOSE'] == '1':
		Services.verbose()

	# Get all the services
	dServices = {k:None for k in Conf.get(('rest', 'services'))}

	# Overwrite those passed in
	for n,o in services.items():
		dServices[n] = o

	# Register all services
	Services.register(dServices, oRestConf, Conf.get(('services', 'salt')))

	# Init Templates
	if templates:
		Templates.init(templates)

	# Return the REST config
	return oRestConf
Example #2
0
sVer = sys.argv[1].replace('.', '_')

# Load the config
Conf.load('../config.json')
sConfOverride = '../config.%s.json' % platform.node()
if os.path.isfile(sConfOverride):
	Conf.load_merge(sConfOverride)

# Add the global prepend and primary host to rethinkdb
Record_Base.dbPrepend(Conf.get(("rethinkdb", "prepend"), ''))
Record_ReDB.addHost('primary', Conf.get(("rethinkdb", "hosts", "primary")))

# Register all services
Services.register(
	{k:None for k in Conf.get(('rest', 'services'))},
	REST.Config(Conf.get("rest")),
	Conf.get(('services', 'salt'))
)

# Try to import the version
try:
	oVer = importlib.import_module('upgrades.%s' % sVer)
except ImportError as e:
	print('The given version "%s" is invalid.' % sVer)
	print(e)
	sys.exit(1)

# Load or create the version file
oLogFile = UpgradeLog('upgrades/%s/_upgrade.log' % sVer)

# Run the version files
Example #3
0
REST.Server({

	# Clients
	"/client": {"methods": REST.ALL, "session": True},
	"/clients": {"methods": REST.READ, "session": True},

	# Companies
	"/company": {"methods": REST.READ | REST.UPDATE, "session": True},

	# Invoices
	"/invoice": {"methods": REST.CREATE | REST.READ, "session": True},
	"/invoice/pdf": {"methods": REST.READ, "session": True},
	"/invoices": {"methods": REST.READ, "session": True},

	# Projects
	"/project": {"methods": REST.ALL, "session": True},
	"/projects": {"methods": REST.READ, "session": True},

	# Tasks
	"/task/start": {"methods": REST.CREATE, "session": True},
	"/task/end": {"methods": REST.UPDATE, "session": True},
	"/task": {"methods": REST.UPDATE | REST.DELETE, "session": True},
	"/tasks": {"methods": REST.READ, "session": True},

	# Users
	"/user": {"methods": REST.ALL, "session": True},
	"/user/passwd": {"methods": REST.UPDATE, "session": True},
	"/user/access": {"methods": REST.CREATE | REST.DELETE | REST.READ, "session": True},
	"/users": {"methods": REST.READ, "session": True},

	# Session
	"/signin": {"methods": REST.POST},
	"/signout": {"methods": REST.POST, "session": True},

	# User Access
	"/account/clients": {"methods": REST.READ, "session": True},
	"/account/forgot": {"methods": REST.CREATE | REST.UPDATE},
	"/account/setup": {"methods": REST.READ | REST.UPDATE},
	"/account/task": {"methods": REST.READ, "session": True},
	"/account/tasks": {"methods": REST.READ, "session": True},
	"/account/verify": {"methods": REST.UPDATE}

}, 'primary', "https?://(.*\\.)?%s" % Conf.get(("rest","allowed")).replace('.', '\\.')).run(
	host=oRestConf['primary']['host'],
	port=oRestConf['primary']['port'],
	workers=oRestConf['primary']['workers'],
	timeout='timeout' in oRestConf['primary'] and oRestConf['primary']['timeout'] or 30
)
Example #4
0
from RestOC import Conf, REST, Services, Sesh

# App imports
from apps.webpoll import WebPoll

# Load the config
Conf.load('../config.json')
sConfOverride = '../config.%s.json' % platform.node()
if os.path.isfile(sConfOverride):
    Conf.load_merge(sConfOverride)

# Init the Sesh module
Sesh.init(Conf.get(("redis", "session")))

# Create the REST config instance
oRestConf = REST.Config(Conf.get("rest"))

# Set verbose mode if requested
if 'AXE_VERBOSE' in os.environ and os.environ['AXE_VERBOSE'] == '1':
    Services.verbose()

# Register all necessary services
Services.register({
    "auth": None,
    "webpoll": WebPoll()
}, oRestConf, Conf.get(('services', 'salt')))

# Create the HTTP server and map requests to service
REST.Server(
    {
        "/clear": {
Example #5
0
# Load the config
Conf.load('../config.json')
sConfOverride = '../config.%s.json' % platform.node()
if os.path.isfile(sConfOverride):
	Conf.load_merge(sConfOverride)

# Add the global prepend and primary host to rethinkdb
Record_Base.dbPrepend(Conf.get(("rethinkdb", "prepend"), ''))
Record_ReDB.addHost('primary', Conf.get(("rethinkdb", "hosts", "primary")))

# Init the Sesh module
Sesh.init(Conf.get(("redis", "session")))

# Create the REST config instance
oRestConf = REST.Config(Conf.get("rest"))

# Set verbose mode if requested
if 'AXE_VERBOSE' in os.environ and os.environ['AXE_VERBOSE'] == '1':
	Services.verbose()

# Register all necessary services
Services.register({
	"auth": None,
	"watl": Watl()
}, oRestConf, Conf.get(('services', 'salt')))

# Create the HTTP server and map requests to service
REST.Server({
	"/match": {"methods": REST.CREATE | REST.DELETE | REST.READ, "session": True},
	"/match/overtime": {"methods": REST.UPDATE, "session": True},
Example #6
0
# Python imports
import os, platform

# Pip imports
import bottle
from RestOC import Conf, REST, Services

# Load the config
Conf.load('../config.json')
sConfOverride = '../config.%s.json' % platform.node()
if os.path.isfile(sConfOverride):
	Conf.load_merge(sConfOverride)

# Create the REST config instance
oRestConf = REST.Config(Conf.get("rest"))

# Set verbose mode if requested
_bVerbose = False
if 'AXE_VERBOSE' in os.environ and os.environ['AXE_VERBOSE'] == '1':
	_bVerbose = True

# Register the Services that will be accessible
Services.register({
	"auth": None,
	"communications": None
}, oRestConf, Conf.get(('services', 'salt')))

def emailEffect(effect, info):
	"""Email Effect
Example #7
0
from RestOC import Conf, REST, Services, SMTP

# App imports
from apps.communications import Service as Communications

# Load the config
Conf.load('../config.json')
sConfOverride = '../config.%s.json' % platform.node()
if os.path.isfile(sConfOverride):
	Conf.load_merge(sConfOverride)

# Init the SMTP module
SMTP.init(**Conf.get(('email', 'smtp')))

# Create the REST config instance
oRestConf = REST.Config(Conf.get("rest"))

# Set verbose mode if requested
if 'AXE_VERBOSE' in os.environ and os.environ['AXE_VERBOSE'] == '1':
	Services.verbose()

# Register the Services that will be accessible
Services.register({
	"communications": Communications()
}, oRestConf, Conf.get(('services', 'salt')))

# Create the HTTP server and map requests to service
REST.Server({
	"/email": {"methods": REST.POST},
	"/sms": {"methods": REST.POST},
}, 'communications').run(
Example #8
0
# Load the config
Conf.load('../config.json')
sConfOverride = '../config.%s.json' % platform.node()
if os.path.isfile(sConfOverride):
    Conf.load_merge(sConfOverride)

# Add the global prepend and primary host to rethinkdb
Record_Base.dbPrepend(Conf.get(("rethinkdb", "prepend"), ''))
Record_ReDB.addHost('primary', Conf.get(("rethinkdb", "hosts", "primary")))

# Init the Sesh module
Sesh.init(Conf.get(("redis", "session")))

# Create the REST config instance
oRestConf = REST.Config(Conf.get("rest"))

# Set verbose mode if requested
if 'AXE_VERBOSE' in os.environ and os.environ['AXE_VERBOSE'] == '1':
    Services.verbose()

# Get all the services
dServices = {k: None for k in Conf.get(('rest', 'services'))}
dServices['auth'] = Auth()

# Register all services
Services.register(dServices, oRestConf, Conf.get(('services', 'salt')))

# Init Templates
Templates.init('../templates')