def start(self, config_path, dispatcher, non_block=False): self.status = ServerStatus.Starting self.context.load_settings(abspath(join(self.root_dir, config_path))) article_dir = os.path.join(self.root_dir, 'templates/web/article') sidebar_dir = os.path.join(self.root_dir, 'templates/web/sidebar') news_dir = os.path.join(self.root_dir, 'templates/web/news') self.context.load_article_files(article_dir) self.context.load_sidebar_files(sidebar_dir) self.context.load_news_files(news_dir) """ Init cogenda app logging """ log_dir = self.context.settings.cogenda_app.log_dir log_file = self.context.settings.cogenda_app.log_file is_debug = self.context.settings.cogenda_app.as_bool('debug') if is_debug: init_logging(log_dir, log_file, logging.DEBUG) logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) logging.getLogger('sqlalchemy.orm.unitofwork').setLevel(logging.DEBUG) else: init_logging(log_dir, log_file, logging.ERROR) if self.context.settings.cogenda_app.as_bool('daemon'): Daemonizer(cherrypy.engine).subscribe() if self.context.settings.cogenda_app.pid_file: PIDFile(cherrypy.engine, self.context.settings.cogenda_app.pid_file).subscribe() non_block = self.context.settings.cogenda_app.as_bool('non_block') self.run_server(dispatcher, non_block) self.status = ServerStatus.Started
def create_app(config_name): app = Flask(__name__) api = Api(app) app.config.from_object(config[config_name]) #app.config['imports'] = ['tasks.CeleryAnsibleCall.callansibleRun'] # app.config['CELERY_BROKER_URL'] = 'amqp://*****:*****@192.168.56.101:5672/myvhost' # app.config['CELERY_RESULT_BACKEND'] = 'amqp://*****:*****@192.168.56.101:5672/myvhost' # celery.conf.update(config[config_name]) init_logging(app.config['APP_LOG_DIR']) celery.conf.update(app.config) return app, api
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) from framework import Framework, reset_all from node import Node from history import History import history import logconfig import dynamomessages import dynamo1 import dynamo2 import dynamo3 import dynamo4 import dynamo as dynamo99 logconfig.init_logging() _logger = logging.getLogger('dynamo') class SimpleTestCase(unittest.TestCase): """Test simple Dynamo function""" def setUp(self): _logger.info("Reset for next test") reset_all() dynamo1.DynamoNode.reset() dynamo2.DynamoNode.reset() dynamo3.DynamoNode.reset() dynamo4.DynamoNode.reset() dynamo99.DynamoNode.reset() def tearDown(self):
from threading import Thread import logconfig from node import Node from timer import TimerManager from framework import Framework from hash_multiple import ConsistentHashTable from dynamomessages import ClientPut, ClientGet, ClientPutRsp, ClientGetRsp from dynamomessages import PutReq, GetReq, PutRsp, GetRsp from dynamomessages import DynamoRequestMessage from dynamomessages import PingReq, PingRsp from merkle import MerkleTree from vectorclock import VectorClock import gevent import leveldb logconfig.init_logging() _logger = logging.getLogger('dynamo') # PART dynamonode class DynamoNode(Node): timer_priority = 20 T = 10 # Number of repeats for nodes in consistent hash table N = 2 # Number of nodes to replicate at W = 1 # Number of nodes that need to reply to a write operation R = 1 # Number of nodes that need to reply to a read operation nodelist = [] chash = ConsistentHashTable(nodelist, T) def __init__(self, addr, config_file='server_config'): super(DynamoNode, self).__init__()
import anyio import asyncclick as click import logconfig import yaml import os import sys import mqtt import asyncio from TLScontext import TLScontext import ssl from asyncio_mqtt import MqttError import time LOG = logconfig.init_logging("obu") #using click to specify the configfile with all config details, using built in function in click to verify that file exist @click.command() @click.option("-config", help="Path to configfile", required=True, type=click.Path(exists=True)) async def main(config): try: with open(config, 'r') as f: cfg = yaml.safe_load(f) #Open file and load content to cfg except yaml.scanner.ScannerError as e: LOG.error("Error reading file: {}".format(config)) sys.exit(1) #create TLScontext, passing the paths to the files stated in the configfile
import click import logconfig import yaml import sys import time #from interchange import interchange from interchange2 import Recv from proton.reactor import Container LOG = logconfig.init_logging("root") from MQTT import NW3MQTT @click.command() @click.option("-config", help="Path to configfile for the application", required=True, type=click.Path(exists=True)) def main(config): LOG.info("Starting system") try: with open(config, 'r') as f: cfg = yaml.safe_load(f) #Open file and load content to cfg except yaml.scanner.ScannerError as e: LOG.error("Error reading file: {}".format(config)) sys.exit(1) # reciever = Recv( # cfg["AMQP_URL"], # 10, # cfg["AMQP_ca"],