def cli(ctx, access_token): """mapboxctl - manage your Mapbox assets""" ctx.obj = {} access_token = access_token or os.environ.get('MAPBOX_ACCESS_TOKEN') log.configure() click.echo('Test!')
from datetime import datetime, date from typing import Callable, List, Tuple import json import logging import os import re import sys import discord from discord.ext import commands import faq_list import log from cached_request import CachedRequest log.configure() LOG = logging.getLogger("FAQBot-CC") bot = commands.Bot(command_prefix='%') starttime = datetime.utcnow() faqs: List[Tuple[str, str, str]] = [] # Fetch from tweaked.cc at most once per minute. cc_methods = CachedRequest( 60, "https://tweaked.cc/index.json", lambda contents: {k.lower(): v for k, v in json.loads(contents).items()}) LOG.info("Starting discord Bot")
def _main(): """The main entry point of the server""" log.configure() control.stop() # Create an event loop. This effectively allows us to run multiple functions # at once (namely, the motor controller and server). loop = asyncio.get_event_loop() loop.set_exception_handler(exception_handler) # Motor control statements are pushed into this queue motor_queue = SingleValueQueue() # And we hold all currently connected computers here manager = ConnectionManager() # Grab our sensor data data = SensorData() if "-M" not in sys.argv: loop.create_task(motor_control(motor_queue, manager, data)) # Create the sensor thread thread_i2c_sensors = RotaryEncoderThread(1, 5, data) thread_i2c_sensors.setDaemon(5) thread_i2c_sensors.start() # Construct the server and run it forever server = None try: with data.front_dist_0, \ data.front_dist_1, \ data.front_ground_dist, \ data.back_ground_dist, \ data.front_ground_touch, \ data.middle_stair_touch, \ data.back_stair_touch, \ data.back_ground_touch, \ data.middle_ground_touch: # Reset the front and back to clear any residual data server = loop.run_until_complete( loop.create_server( lambda: SpencerServerConnection(motor_queue, manager), '0.0.0.0', 1050)) NETWORK_LOG.info('Serving on %s', server.sockets[0].getsockname()) # Wait for 2 seconds to ensure the server is ready loop.run_until_complete(check_sensors(data)) # Zero the motors loop.run_until_complete(control.zero(data, manager.send)) loop.run_forever() finally: if server is not None: server.close() loop.run_until_complete(server.wait_closed()) loop.run_until_complete(loop.shutdown_asyncgens()) loop.close() if "-M" not in sys.argv: motor.float_motors()
import httplib2 from datetime import datetime, timedelta from flask import Flask, jsonify, request from config import Config from log import configure from sms import send_sms from db import set_item, get_item, db from rq import Queue from job import schedule_the_job, cancel_the_job from apiclient import discovery from oauth2client import client configure(Config.ENV) app = Flask('minder') app.secret_key = str(uuid.uuid4()) logger = logging.getLogger('minder') @app.before_request def log_request(): logger.info('{} {}'.format(request.method, request.path)) def _get_echo_response(speech_output, card_output, reprompt_message, end_session=True): return {
def __init__(self, logging_config): log.configure(logging_config) self.log.debug('initializing') self.command_queue = CommandQueue(XenStore())