Exemplo n.º 1
0
def get_elastic_client():
    return Elasticsearch([ELASTIC_HOST],
                         http_auth=(cred.elastic['user'],
                                    cred.elastic['password']),
                         scheme="https",
                         port=443,
                         ca_certs=certifi.where())
Exemplo n.º 2
0
    def run(self, options, args):
        # type: (Values, List[str]) -> int
        logger.warning(
            "This command is only meant for debugging. "
            "Do not use this with automation for parsing and getting these "
            "details, since the output and options of this command may "
            "change without notice."
        )
        show_value("pip version", get_pip_version())
        show_value("sys.version", sys.version)
        show_value("sys.executable", sys.executable)
        show_value("sys.getdefaultencoding", sys.getdefaultencoding())
        show_value("sys.getfilesystemencoding", sys.getfilesystemencoding())
        show_value(
            "locale.getpreferredencoding",
            locale.getpreferredencoding(),
        )
        show_value("sys.platform", sys.platform)
        show_sys_implementation()

        show_value("'cert' config value", ca_bundle_info(self.parser.config))
        show_value("REQUESTS_CA_BUNDLE", os.environ.get("REQUESTS_CA_BUNDLE"))
        show_value("CURL_CA_BUNDLE", os.environ.get("CURL_CA_BUNDLE"))
        show_value("pip._vendor.certifi.where()", where())
        show_value("pip._vendor.DEBUNDLED", pip._vendor.DEBUNDLED)

        show_vendor_versions()

        show_tags(options)

        return SUCCESS
Exemplo n.º 3
0
    def _install_requirements(
        pip_runnable: str,
        finder: "PackageFinder",
        requirements: Iterable[str],
        prefix: _Prefix,
        *,
        kind: str,
    ) -> None:
        args: List[str] = [
            sys.executable,
            pip_runnable,
            "install",
            "--ignore-installed",
            "--no-user",
            "--prefix",
            prefix.path,
            "--no-warn-script-location",
        ]
        if logger.getEffectiveLevel() <= logging.DEBUG:
            args.append("-v")
        for format_control in ("no_binary", "only_binary"):
            formats = getattr(finder.format_control, format_control)
            args.extend(
                (
                    "--" + format_control.replace("_", "-"),
                    ",".join(sorted(formats or {":none:"})),
                )
            )

        index_urls = finder.index_urls
        if index_urls:
            args.extend(["-i", index_urls[0]])
            for extra_index in index_urls[1:]:
                args.extend(["--extra-index-url", extra_index])
        else:
            args.append("--no-index")
        for link in finder.find_links:
            args.extend(["--find-links", link])

        for host in finder.trusted_hosts:
            args.extend(["--trusted-host", host])
        if finder.allow_all_prereleases:
            args.append("--pre")
        if finder.prefer_binary:
            args.append("--prefer-binary")
        args.append("--")
        args.extend(requirements)
        extra_environ = {"_PIP_STANDALONE_CERT": where()}
        with open_spinner(f"Installing {kind}") as spinner:
            call_subprocess(
                args,
                command_desc=f"pip subprocess to install {kind}",
                spinner=spinner,
                extra_environ=extra_environ,
            )
Exemplo n.º 4
0
def main():
    config = configparser.ConfigParser()

    config.read('tunnelcheck.cfg')
    try:
        deviceidstr = config['waninfo']['deviceid']
        wantable = config['waninfo']['wantable']
        awsregion = config['waninfo']['awsregion']
    except KeyError as e:
        print("No config file, so pulling info from my user's AWS tags.")
        iam = boto3.resource("iam")
        user = iam.CurrentUser()
        tagset = user.tags
        for tag in tagset:
            if tag['Key'] == 'DeviceName':
                devicename = tag['Value']
            if tag['Key'] == 'DeviceID':
                deviceidstr = tag['Value']
            if tag['Key'] == 'AWSRegion':
                awsregion = tag['Value']
            if tag['Key'] == 'WANTable':
                wantable = tag['Value']

    deviceid = int(deviceidstr)

    dynamodb = boto3.resource("dynamodb", region_name=awsregion)
    table = dynamodb.Table(wantable)
    myip = ""
    try:
        response = table.get_item(Key={'DeviceID': deviceid})
    except ClientError as e:
        print(e.response['Error']['Message'])
        exit(1)
    else:
        item = response['Item']
    myip = item["WANIP"]
    http = urllib3.PoolManager(ca_certs=certifi.where())
    req = http.request('GET', 'https://ident.me/')
    mywanip = req.data.decode('utf-8')
    if (myip == mywanip):
        print(f'My Public IP is {mywanip} and is correct in AWS')
    else:
        print(f'My IP should be {myip}, but it is {mywanip}')
    item["WANIP"] = mywanip
    if myip != mywanip:
        print("Updating IP:")
        table.put_item(TableName=wantable, Item=item)
        print(item)
Exemplo n.º 5
0
    def _install_requirements(
        standalone_pip: str,
        finder: "PackageFinder",
        requirements: Iterable[str],
        prefix: _Prefix,
        message: str,
    ) -> None:
        args = [
            sys.executable,
            standalone_pip,
            'install',
            '--ignore-installed',
            '--no-user',
            '--prefix',
            prefix.path,
            '--no-warn-script-location',
        ]  # type: List[str]
        if logger.getEffectiveLevel() <= logging.DEBUG:
            args.append('-v')
        for format_control in ('no_binary', 'only_binary'):
            formats = getattr(finder.format_control, format_control)
            args.extend(('--' + format_control.replace('_', '-'),
                         ','.join(sorted(formats or {':none:'}))))

        index_urls = finder.index_urls
        if index_urls:
            args.extend(['-i', index_urls[0]])
            for extra_index in index_urls[1:]:
                args.extend(['--extra-index-url', extra_index])
        else:
            args.append('--no-index')
        for link in finder.find_links:
            args.extend(['--find-links', link])

        for host in finder.trusted_hosts:
            args.extend(['--trusted-host', host])
        if finder.allow_all_prereleases:
            args.append('--pre')
        if finder.prefer_binary:
            args.append('--prefer-binary')
        args.append('--')
        args.extend(requirements)
        extra_environ = {"_PIP_STANDALONE_CERT": where()}
        with open_spinner(message) as spinner:
            call_subprocess(args, spinner=spinner, extra_environ=extra_environ)
Exemplo n.º 6
0
#!/usr/bin/env templates
# -*- coding: utf-8 -*-
"""
requests.certs
~~~~~~~~~~~~~~

This module returns the preferred default CA certificate bundle. There is
only one — the one from the certifi package.

If you are packaging Requests, e.g., for a Linux distribution or a managed
environment, you can change the definition of where() to return a separately
packaged CA bundle.
"""
from pip._vendor.certifi import where

if __name__ == '__main__':
    print(where())
Exemplo n.º 7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
certs.py
~~~~~~~~

This module returns the preferred default CA certificate bundle.

If you are packaging Requests, e.g., for a Linux distribution or a managed
environment, you can change the definition of where() to return a separately
packaged CA bundle.
"""
import os.path

try:
    from pip._vendor.certifi import where
except ImportError:
    def where():
        """Return the preferred certificate bundle."""
        # vendored bundle inside Requests
        return os.path.join(os.path.dirname(__file__), 'cacert.pem')

if __name__ == '__main__':
    print(where())
 def __init__(self, server_address: str, index_name: str) -> None:
     self.__client = Elasticsearch([server_address],
                                   ca_certs=certifi.where())
     self.__index = index_name
     self.__serializer = json_serializer()
Exemplo n.º 9
0
 def uo(args, **kwargs):
     return urllib.request.urlopen(args, cafile=certifi.where(), **kwargs)
Exemplo n.º 10
0
from pip._vendor.certifi import where
print((where()))
Exemplo n.º 11
0
import scrapy
import os
import uuid

from elasticsearch import Elasticsearch
from pip._vendor import certifi

# Establish connection to Elastic Cloud
ELASTIC_API_URL = os.environ['ELASTIC_API_URL']
ELASTIC_API_USERNAME = os.environ['ELASTIC_API_USERNAME']
ELASTIC_API_PASSWORD = os.environ['ELASTIC_API_PASSWORD']

es = Elasticsearch([ELASTIC_API_URL],
                   http_auth=(ELASTIC_API_USERNAME, ELASTIC_API_PASSWORD),
                   ca_certs=certifi.where())


class ImdbSpider(scrapy.Spider):
    name = 'imdb'
    allowed_domains = ['www.imdb.com']
    start_urls = ['http://www.imdb.com/title/tt0111161/fullcredits/']

    def parse(self, response):
        #get the movie_id from the url
        id = response.url.split("/")[-3]

        #get the movie details
        movie_title = response.css(
            'h3[itemprop~=name] a::text').extract_first()
        year = response.css('h3[itemprop~=name] span::text').extract_first()
        movie_year = year.split()[0].replace("\u2013", "-")