Esempio n. 1
0
def get_database(filename=None):
    if not filename:
        import basicconfig
        cf = basicconfig.get_config("storage.conf")
        filename = cf.get("dbfile")
        del cf
    return DBFile(os.path.expandvars(os.path.expanduser(filename)))
Esempio n. 2
0
def get_messages(filt="NEW"):
    cf = basicconfig.get_config(CONFIGFILE)
    if not cf.user:
        user = termtools.getuser()
    else:
        user = cf.user

    if not cf.password:
        password = termtools.getpass()
    else:
        password = cf.password

    M = imaplib.IMAP4(cf.server)
    resp, data = M.login(user, password)
    if resp != "OK":
        print "Unable to log in."
        return

    M.select(cf.folder)
    resp, data = M.search(None, filt)
    if resp == "OK":
        for num in data[0].split():
            resp, data = M.fetch(num, "(RFC822)")
            handle_message(data[0][1])
    M.close()
    M.logout()
Esempio n. 3
0
def get_client():
    import basicconfig
    cf = basicconfig.get_config("storage.conf")
    host = cf.get("host", DEFAULT_HOST)
    port = cf.get("port", DEFAULT_PORT)
    del cf
    return DBClient(host, port)
Esempio n. 4
0
def main(argv):
	global CF
	CF = basicconfig.get_config("/etc/mgetty+sendfax/voicemail.conf")
	if CF.get("LOGFILE"):
    	lf = logfile.open(CF.LOGFILE)
	else:
		lf = None

	rv = 1
Esempio n. 5
0
def storaged(argv):
    """The NMS storage server.
    storaged [-h <serverhost>] [-p <serverport>] [-d <databasefile>] [-l <logfile>]
           [-n] [-?]

    where:

        -h is the server hostname to bind to.
        -p is the TCP port to use (other than the default)
        -d specifies the Durus file to use for the database.
        -l Log file name to use for logging.
        -n Do NOT become a daemon, stay in foreground (for debugging)
        -? This help screen.

    """

    import daemonize
    import getopt

    import basicconfig
    cf = basicconfig.get_config("storage.conf")
    host = cf.get("host", DEFAULT_HOST)
    port = cf.get("port", DEFAULT_PORT)
    DBFILE = os.path.expandvars(cf.get("dbfile"))
    LOGFILE = os.path.expandvars(cf.get("dblog"))
    del cf
    do_daemon = True

    try:
        optlist, args = getopt.getopt(argv[1:], "d:l:h:p:n?")
    except getopt.GetoptError:
        print storaged.__doc__
        sys.exit(2)

    for opt, optarg in optlist:
        if opt == "-d":
            DBFILE = optarg
        elif opt == "-l":
            LOGFILE = optarg
        elif  opt == "-h":
            host = optarg
        elif opt == "-p":
            port = int(optarg)
        elif opt == "-n":
            do_daemon = False
        elif opt == "-?":
            print storaged.__doc__
            return 2

    if do_daemon:
        daemonize.daemonize()
    try:
        start_durus(host, port, LOGFILE, DBFILE)
    except KeyboardInterrupt:
        return
Esempio n. 6
0
def storaged(argv):
    import getopt

    import basicconfig
    cf = basicconfig.get_config(os.path.join(os.environ["STRATATEST_HOME"], "etc", "storage.conf"))
    host = cf.get("serverhost", DEFAULT_HOST)
    port = cf.get("port", DEFAULT_PORT)
    DBFILE = os.path.expandvars(cf.get("dbfile"))
    LOGFILE = os.path.expandvars(cf.get("dblog"))
    del cf
    do_daemon = True

    try:
        optlist, args = getopt.getopt(argv[1:], "d:l:h:p:nk?")
    except getopt.GetoptError:
        print DOC
        sys.exit(2)

    for opt, optarg in optlist:
        if opt == "-d":
            DBFILE = optarg
        elif opt == "-k":
            import signal
            pid = int(file(PIDFILE).read())
            os.kill(pid, signal.SIGINT)
            return 0
        elif opt == "-l":
            LOGFILE = optarg
        elif  opt == "-h":
            host = optarg
        elif opt == "-p":
            port = int(optarg)
        elif opt == "-n":
            do_daemon = False
        elif opt == "-?":
            print DOC
            return 2

    if do_daemon:
        import daemonize
        daemonize.daemonize(pidfile=PIDFILE)
    try:
        start_durus(host, port, LOGFILE, DBFILE)
    except KeyboardInterrupt:
        return
Esempio n. 7
0
import logging
from concurrent.futures import ThreadPoolExecutor
import time
from uuid import uuid4
from peewee import MySQLDatabase, Model, CharField

import grpc

from basicconfig import get_config

conf = get_config("config.conf")

from protos import shadowfax_pb2 as user_account_pb2
from protos import shadowfax_pb2_grpc as user_account_pb2_grpc

logging.basicConfig(format=conf.LOG_FORMAT,
                    level=conf.LOG_LEVEL,
                    datefmt=conf.LOG_DATE_FORMAT)
logger = logging.getLogger(__name__)


def is_validated_signup(phone, name,
                        validation_code):  # FIXME TODO: put these into Gondor
    # TODO: 1. phone <=> name
    # TODO: 2. phone <=> validation_code
    return True


def is_validated_signin(phone,
                        validation_code):  # FIXME TODO: put these into Gondor
    # TODO: phone <=> validation_code
Esempio n. 8
0
def get_storageconfig():
    import basicconfig
    return basicconfig.get_config(os.path.join(os.environ["STRATATEST_HOME"], "etc", "storage.conf"))
Esempio n. 9
0
from flask import Flask
from protos import shadowfax_pb2 as valinor_pb2
from protos import shadowfax_pb2_grpc as valinor_pb2_grpc

from basicconfig import get_config
conf = get_config()

app = Flask(__name__)
app.config.from_object(__name__)


@app.route('/add_robot')
def add_robot():
    pass


@app.route('/del_robot')
def del_robot():
    pass


@app.route('/robot_on/')
def turn_robot_on():
    pass


@app.route('/robot_off')
def turn_robot_off():
    pass

Esempio n. 10
0
import logging
from concurrent.futures import ThreadPoolExecutor, as_completed
import time
from uuid import uuid4, uuid5, NAMESPACE_URL
from redis import StrictRedis

import grpc

from py_protos import user_account_pb2, user_account_pb2_grpc, shadowfax_pb2, shadowfax_pb2_grpc, imladris_pb2, \
    imladris_pb2_grpc

from basicconfig import get_config

conf = get_config('config.conf')

logging.basicConfig(format=conf.LOG_FORMAT,
                    level=conf.LOG_LEVEL,
                    datefmt=conf.LOG_DATE_FORMAT)
logger = logging.getLogger(__name__)


def get_trusted_crts(server_name):
    with open('./keys/{0}.crt'.format(server_name), 'rb') as f:
        trusted_certs = f.read()
    return trusted_certs


user_account_credentials = grpc.ssl_channel_credentials(
    root_certificates=get_trusted_crts("user_account"))
user_account_channel = grpc.secure_channel(
    conf.LOCAL_HOST + ':' + conf.USERACCOUNT_PORT, user_account_credentials)
Esempio n. 11
0
def get_config():
	import basicconfig
	return basicconfig.get_config("ezmail.conf")
Esempio n. 12
0
# 
# $Id: //Branches/Stratatest/NextGen/Titan-1.0.0/external/pyNMS/lib/remote/Client.py#1 $
#
"""
The Client for Remote controllers.

"""
__all__ = ["get_remote", "remote_copy"]

import sys, os

import Pyro.util
import Pyro.core

import basicconfig
cf = basicconfig.get_config("remote.conf")
Pyro.config.PYRO_NS_HOSTNAME = cf.nameserver
del cf, basicconfig

# some platform specific stuff. Should be minimal
if sys.platform == "linux2":
    from PosixClient import *

elif sys.platform == "cygwin":
    from PosixClient import *

elif sys.platform == "win32":
    from WindowsClient import *
del sys