Ejemplo n.º 1
0
def run(voc, config):

    # FIXME: Allow MQTT credentials in voc.conf

    client_id = 'voc_{hostname}_{time}'.format(hostname=hostname(),
                                               time=time())

    mqtt_config = read_mqtt_config()

    mqtt = paho.Client(client_id=client_id, clean_session=False)
    mqtt.username_pw_set(username=mqtt_config['username'],
                         password=mqtt_config['password'])
    mqtt.tls_set(certs.where())

    mqtt.on_connect = on_connect
    mqtt.on_disconnect = on_disconnect
    mqtt.on_publish = on_publish
    mqtt.on_message = on_message
    mqtt.on_subscribe = on_subscribe

    mqtt.event_connected = Event()

    mqtt.connect(host=mqtt_config['host'], port=int(mqtt_config['port']))
    mqtt.loop_start()

    interval = int(config['interval'])
    _LOGGER.info(f'Polling every {interval} seconds')

    entities = {}

    while True:

        if not mqtt.event_connected.is_set():
            _LOGGER.debug('Waiting for MQTT connection')
            mqtt.event_connected.wait()
            _LOGGER.debug('Connected')

        available = True
        for vehicle in voc.vehicles:
            if vehicle not in entities:
                _LOGGER.debug('creating vehicle %s', vehicle)

                dashboard = Dashboard(vehicle)
                dashboard.configurate(**config)

                entities[vehicle] = [
                    Entity(mqtt, instrument, config)
                    for instrument in dashboard.instruments
                ]

            for entity in entities[vehicle]:
                _LOGGER.debug('%s: %s', entity.instrument.full_name,
                              entity.state)
                entity.publish_discovery()
                entity.publish_availability(available)
                if available:
                    entity.publish_state()

        sleep(interval)
        available = voc.update()
Ejemplo n.º 2
0
def get_data():
	import accessible_output2
	import sound_lib
	import enchant
	return [
  ("", ["conf.defaults", "app-configuration.defaults", "icon.ico"]),
    ("", [certs.where()]),
  ("accessible_output2/lib", glob("accessible_output2/lib/*.dll")),
  ("keymaps", glob("keymaps/*.keymap")),
]+get_sounds()+get_locales()+get_documentation()+sound_lib.find_datafiles()+accessible_output2.find_datafiles()+enchant.utils.win32_data_files()+get_architecture_files()+wx_files()
Ejemplo n.º 3
0
 def init(self):
     """Init the connection to the MQTT server."""
     if not self.export_enable:
         return None
     try:
         client = paho.Client(client_id='glances_' + self.hostname,
                              clean_session=False)
         client.username_pw_set(username=self.user, password=self.password)
         client.tls_set(certs.where())
         client.connect(host=self.host, port=self.port)
         client.loop_start()
         return client
     except Exception as e:
         logger.critical("Connection to MQTT server failed : %s " % e)
         return None
Ejemplo n.º 4
0
 def __enter__(self):
     if not self.proxy:
         msg = 'You need to specify a proxy file when using voms auth'
         raise TypeError(msg)
     self.session.cert = self.proxy
     if self.verify:
         # Create a temporary CA bundle to make proxy verification work
         self.bundle = NamedTemporaryFile()
         src_bundle = self.verify
         if src_bundle is True:
             src_bundle = certs.where()
         with open(src_bundle, 'rb') as src:
             copyfileobj(src, self.bundle)
         with open(self.proxy, 'rb') as proxy_file:
             self.bundle.write(proxy_file.read())
         self.bundle.flush()
         self.session.verify = self.bundle.name
Ejemplo n.º 5
0
 def init(self):
     """Init the connection to the MQTT server."""
     if not self.export_enable:
         return None
     try:
         client = paho.Client(client_id='glances_' + self.hostname,
                              clean_session=False)
         client.username_pw_set(username=self.user,
                                password=self.password)
         client.tls_set(certs.where())
         client.connect(host=self.host,
                        port=self.port)
         client.loop_start()
         return client
     except Exception as e:
         logger.critical("Connection to MQTT server failed : %s " % e)
         return None
Ejemplo n.º 6
0
def main():
    """
    Create .exes with dynamic spec files.
    """
    outdir = bitsdir("pyinst-dist")
    builddir = bitsdir("pyinst-build")
    write_versions()
    generate_specs()
    call_specs(outdir, builddir)
    copy("version.txt", outdir)
    copy("longversion.txt", outdir)
    copy(CAP.location, outdir)
    copy_json(outdir)
    copy(certs.where(), join(outdir, "cacerts.pem"))
    sz_wrapper(outdir)
    clean_versions()
    clean_specs()
Ejemplo n.º 7
0
def run(voc, config):

    # FIXME: Allow MQTT credentials in voc.conf

    mqtt_config = read_mqtt_config()
    mqtt = paho.Client()
    mqtt.username_pw_set(username=mqtt_config['username'],
                         password=mqtt_config['password'])
    mqtt.tls_set(certs.where())

    mqtt.on_connect = on_connect
    mqtt.on_disconnect = on_disconnect
    mqtt.on_publish = on_publish
    mqtt.on_message = on_message
    mqtt.on_subscribe = on_subscribe

    mqtt.connect(host=mqtt_config['host'], port=int(mqtt_config['port']))
    mqtt.loop_start()

    interval = int(config['interval'])
    _LOGGER.info(f'Polling every {interval} seconds')

    entities = {}

    while True:
        available = voc.update()
        for vehicle in voc.vehicles:
            if vehicle not in entities:
                _LOGGER.debug('creating vehicle %s', vehicle)
                entities[vehicle] = create_entities(vehicle, config)

                for entity in entities[vehicle]:
                    entity.publish_discovery(mqtt)

            for entity in entities[vehicle]:
                entity.publish_availability(mqtt, available)
                if available:
                    entity.publish_state(mqtt)

        sleep(interval)
    def _AcceptConnection(self, client, addr):
        custom_ca_certs = properties.VALUES.core.custom_ca_certs_file.Get()
        if custom_ca_certs:
            ca_certs = custom_ca_certs
        else:
            ca_certs = certs.where()

        server = websocket.WebSocketApp(
            'wss://%s/_workstation/tcp/%d' % (self.host, self.port),
            header={'Authorization': 'Bearer %s' % self.access_token},
            on_open=lambda ws: self._ForwardClientToServer(client, ws),
            on_data=lambda ws, data, op, finished: client.send(data),
            on_error=lambda ws, e: self._OnWebsocketError(client, e),
        )

        def run():
            server.run_forever(sslopt={
                'cert_reqs': ssl.CERT_REQUIRED,
                'ca_certs': ca_certs,
            })

        t = threading.Thread(target=run)
        t.daemon = True
        t.start()
Ejemplo n.º 9
0
 def wrapped():
     return func(certs.where())
Ejemplo n.º 10
0
def data_requests_certs():
    from requests import certs
    certfile_contents = open(certs.where()).read()
    write_multiline("REQUESTS_CERTS_FILE", certfile_contents)
Ejemplo n.º 11
0
 def __init__(self):
  log.error(certs.where())
Ejemplo n.º 12
0
from . import __version__
from requests import certs
from .compat import parse_http_list as _parse_list_header
from .compat import (quote, urlparse, bytes, str, OrderedDict, unquote, is_py2,
                     builtin_str, getproxies, proxy_bypass, urlunparse,
                     basestring)
from .cookies import RequestsCookieJar, cookiejar_from_dict
from .structures import CaseInsensitiveDict
from .exceptions import InvalidURL

_hush_pyflakes = (RequestsCookieJar, )

NETRC_FILES = ('.netrc', '_netrc')

DEFAULT_CA_BUNDLE_PATH = certs.where()


def dict_to_sequence(d):
    """Returns an internal sequence dictionary update."""

    if hasattr(d, 'items'):
        d = d.items()

    return d


def super_len(o):
    if hasattr(o, '__len__'):
        return len(o)
Ejemplo n.º 13
0
def get_iot_root_ca():
    if AWS_IOT_ROOTCA:
        return _cert_dir_path + AWS_IOT_ROOTCA
    return certs.where()
Ejemplo n.º 14
0
def get_data():
    return [
        ("", ["libvlccore.dll", "libvlc.dll", "cacerts.txt"]),
        ("", [certs.where()]),
    ] + get_locales()
Ejemplo n.º 15
0
            'script':
            'win32\gui.py',
            'dest_base':
            "agent-manager",
            'uac_info':
            "requireAdministrator",  # The manager needs to be administrator to stop/start the service
            'icon_resources':
            [(1,
              r"packaging\datadog-agent\win32\install_files\dd_agent_win_256.ico"
              )],
        }],
        'data_files': [
            ("Microsoft.VC90.CRT", glob(r'C:\Python27\redist\*.*')),
            ('jmxfetch', [r'checks\libs\%s' % JMX_FETCH_JAR_NAME]),
            ('gohai', [r'gohai\gohai.exe']),
            ('', [where()]),  # CA certificates bundled with `requests`
        ],
    }

elif sys.platform == 'darwin':
    app_name = 'Datadog Agent'

    from plistlib import Plist
    plist = Plist.fromFile(
        os.path.dirname(os.path.realpath(__file__)) + '/packaging/Info.plist')
    plist.update(
        dict(CFBundleGetInfoString="{0}, Copyright (c) 2009-{1}, Datadog Inc.".
             format(get_version(),
                    date.today().year),
             CFBundleVersion=get_version()))
Ejemplo n.º 16
0
def get_data():
	return [
	("", ["app-configuration.defaults", "libvlccore.dll", "libvlc.dll", "cacerts.txt"]),
	("", [certs.where()]),
	("plugins", glob("plugins/*/*.dll")),
	]+get_locales()
Ejemplo n.º 17
0
 def __init__(self):
     log.error(certs.where())
Ejemplo n.º 18
0
                'dll_excludes': ["IPHLPAPI.DLL", "NSI.dll",  "WINNSI.DLL",  "WTSAPI32.dll"],
                'ascii':False,
            },
        },
        'console': ['win32\shell.py'],
        'service': [agent_svc],
        'windows': [{'script': 'win32\gui.py',
                     'dest_base': "agent-manager",
                     'uac_info': "requireAdministrator", # The manager needs to be administrator to stop/start the service
                     'icon_resources': [(1, r"packaging\datadog-agent\win32\install_files\dd_agent_win_256.ico")],
                     }],
        'data_files': [
            ("Microsoft.VC90.CRT", glob(r'C:\Python27\redist\*.*')),
            ('jmxfetch', [r'checks\libs\%s' % JMX_FETCH_JAR_NAME]),
            ('gohai', [r'gohai\gohai.exe']),
            ('', [where()]),  # CA certificates bundled with `requests`
        ],
    }

elif sys.platform == 'darwin':
    app_name = 'Datadog Agent'

    from plistlib import Plist
    plist = Plist.fromFile(os.path.dirname(os.path.realpath(__file__)) + '/packaging/Info.plist')
    plist.update(dict(
        CFBundleGetInfoString="{0}, Copyright (c) 2009-{1}, Datadog Inc.".format(
            get_version(), date.today().year),
        CFBundleVersion=get_version()
    ))

    extra_args = {
Ejemplo n.º 19
0
from requests import certs

datas = [(certs.where(), 'requests')]