Пример #1
0
 def __init__(self, username=None, password=None, access_interval=settings.ACCESS_INTERVAL):
     self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(),
                                        IntervalHandler(interval=access_interval))
     self.opener.addheaders = [('User-Agent', settings.USER_AGENT)]
     self.logger = logging.getLogger('program_api')
     if username is not None and password is not None:
         if not self.login(username, password):
             raise ValueError('invalid username or password')
Пример #2
0
from wsgicors import CORS
from molten import App, Include, Route, ResponseRendererMiddleware
from molten.openapi import Metadata, OpenAPIHandler, OpenAPIUIHandler
from molten.contrib.prometheus import expose_metrics, prometheus_middleware

from settings import logging

from api.v1 import room, meeting

log = logging.getLogger(__name__)
"""
Open API
"""

get_schema = OpenAPIHandler(metadata=Metadata(
    title="Emeeting API",
    description="An API for managing your room meetings.",
    version="0.0.1",
))

get_docs = OpenAPIUIHandler()
"""
Add middlewares
"""

middlewares = [prometheus_middleware, ResponseRendererMiddleware()]
"""
Include or add routes
"""

routes = [
Пример #3
0
#!/usr/bin/env python3

import os
from defs import load_data, ssh_run
from settings import logging
import urllib.request
import xmltodict

logging.getLogger("paramiko").setLevel(logging.WARNING)

dirpath = os.path.dirname(os.path.realpath(__file__))
filepath = os.path.join(dirpath, 'Connection.json')
CONNECTIONS = load_data(filepath, [])


def get_data(enc_fqdn):
    url = 'http://'+enc_fqdn.rstrip()+'/xmldata?item=all'
    page = urllib.request.urlopen(url)
    content = page.read().decode('utf8')
    data = xmltodict.parse(content)
    return data


def main():
    for connection in CONNECTIONS:
        try:
            data = get_data(connection['address'])
            Name = data['RIMP']['INFRA2']['ENCL'],
            SN = data['RIMP']['INFRA2']['ENCL_SN'],
            Location = data['RIMP']['INFRA2']['RACK']
            logging.info('{} test success ({} {} {})'.format(connection['name'], Name, SN, Location))
Пример #4
0
# coding=utf-8
import json
import os
import re
from io import BytesIO

from tornado.web import RequestHandler, stream_request_body

from parser.char_counter_parser import CharCounterParser
from settings import logging, UPLOAD_DIR

logger = logging.getLogger(__package__)


class IndexHandler(RequestHandler):
    def get(self):
        self.render('index.html')


@stream_request_body
class UploadHandler(RequestHandler):
    FILE_DATA_PARSER = CharCounterParser
    UPLOAD_PARSE_READY = 0
    UPLOAD_PARSE_PENDING = 1

    def prepare(self):
        self.parser = self.FILE_DATA_PARSER("utf-8")
        boundary = self.request.headers.get("Content-Type").split(
            "boundary=")[-1]
        self.boundary = bytes("--%s" % boundary, encoding="utf-8")
        self.state = self.UPLOAD_PARSE_READY
Пример #5
0
import python_ducksboard_tools.remote.proxy as remote
import sys
sys.path.append(".")
import settings

from python_ducksboard_tools.remote.proxy import gevent
from settings import logging

logger = logging.getLogger('ducksboard.publisher')

class DucksboardPublisher(object):

    def __init__(self, settings):
        self.settings = settings
        self.proxys = {}

    def _build_proxys(self):
        logger.info("Building proxy list from settings.")
        widget_proxys = self.settings.widget_proxys
        token = self.settings.API_TOKEN

        for proxy in widget_proxys:             
            widget_id = proxy["id"]
            collectors = proxy["collectors"]
            #replace by factory method
            proxy = remote.DashboardWidgetProxy(token, collectors)
            proxy.remote = widget_id
            self.proxys[widget_id] = proxy
            logger.debug("{proxy} created.".format(proxy=proxy))
    
    def run(self):
Пример #6
0
 def __init__(self):
     self.program_api = ProgramAPI()
     self.sess = get_session()
     self.logger = logging.getLogger('storeshell')
Пример #7
0
 def __init__(self, access_interval=settings.ACCESS_INTERVAL):
     self.opener = urllib2.build_opener(IntervalHandler(interval=access_interval))
     self.opener.addheaders = [('User-Agent', settings.USER_AGENT)]
     self.logger = logging.getLogger('program_api')