예제 #1
0
 def test_payload(self, payload_filepath):
     headers = {
         "User-Agent": "SendGrid-Test",
         "Content-Type": "multipart/form-data; boundary=xYzZY"
     }
     client = Client(host=self.url, request_headers=headers)
     f = open(payload_filepath, 'r')
     data = f.read()
     return client.post(request_body=data)
예제 #2
0
    def test_payload(self, payload_filepath):
        """Send a test payload.

        Load a payload from payload_filepath, apply headers, and POST self.url.
        Return the response object.
        """
        headers = {
            "User-Agent": "SendGrid-Test",
            "Content-Type": "multipart/form-data; boundary=xYzZY"
        }
        client = Client(host=self.url, request_headers=headers)
        f = open(payload_filepath, 'r', encoding='utf-8')
        data = f.read()
        return client.post(request_body=data)
예제 #3
0
파일: send.py 프로젝트: KevinSJ/KindleEar
    def test_payload(self, payload_filepath):
        """Send a test payload.

        Load a payload from payload_filepath, apply headers, and POST self.url.
        Return the response object.
        """
        headers = {
            "User-Agent": "SendGrid-Test",
            "Content-Type": "multipart/form-data; boundary=xYzZY"
        }
        client = Client(host=self.url, request_headers=headers)
        f = open(payload_filepath, 'r', encoding='utf-8')
        data = f.read()
        return client.post(request_body=data)
예제 #4
0
def get_issues(repo):
    client = Client(host="http://{}".format(
        os.environ.get('GITHUB_MANAGER_MICROSERVICES_IP')))
    repo_user, repo_name = repo.split("/")
    query_params = {"repo_user": repo_user, "repo_name": repo_name}
    response = client.github.issues.get(query_params=query_params)
    return json.loads(response.body)
def get_issues(repo):
    client = Client(host="http://{}".format(os.environ.get('GITHUB_MANAGER_IP')))
    query_params = {
        "repo":repo
    }
    response = client.github.issues.get(query_params=query_params)
    return json.loads(response.body)
def send_sms(from_number, to_number, body):
    client = Client(host="http://{}".format(os.environ.get('GITHUB_MANAGER_MICROSERVICES_IP')))
    data = {
        "from_number": from_number,
        "to_number": to_number,
        "body": body
    }
    response = client.sms.post(request_body=data)
예제 #7
0
def send_email(from_email, to_email, subject, content):
    client = Client(
        host="http://{}".format(os.environ.get('GITHUB_MANAGER_IP')))
    data = {
        "from_email": from_email,
        "to_email": to_email,
        "subject": subject,
        "content": content
    }
    response = client.email.post(request_body=data)
예제 #8
0
def get_items(org, repo, item_type):
    client = Client(host=current_app.config['LOCALHOST'])
    query_params = {
        "repo": repo,
        "item_type": item_type,
        "org": org,
        "states[]": ['OPEN'],
        "limit[]": ['first', '100']
    }
    response = client.github.items.get(query_params=query_params)
    items = json.loads(response.body)
    return items
예제 #9
0
from os import getenv

from python_http_client import Client
from ruuvitag_sensor.ruuvi import RuuviTagSensor

client = Client(host=getenv('SENSOR_REGISTRY_HOST'))


def handle_ruuvi_data(found_data):
    data = found_data[1]

    if data.get('data_format') != 5:
        return

    mac = data.get('mac')

    post_sensor_data('Ruuvi {}'.format(mac), data)


def post_sensor_data(sensor_id, value):
    data = [
        {
            'name': 'temperature',
            'value': value.get('temperature')
        },
        {
            'name': 'humidity',
            'value': value.get('humidity')
        },
        {
            'name': 'pressure',
예제 #10
0
파일: send.py 프로젝트: mtrencseni/webfeed
 def test_payload(self, payload_filepath):
     headers = {"User-Agent": "SendGrid-Test", "Content-Type": "multipart/form-data; boundary=xYzZY"}
     client = Client(host=self.url, request_headers=headers)
     f = open(payload_filepath, "r")
     data = f.read()
     return client.post(request_body=data)
예제 #11
0
파일: api.py 프로젝트: juanpagfe/cash
def create_api_client():
    return Client(host=URL_BASE)
예제 #12
0
import os

from python_http_client import Client


def get_automator_ip():
    if 'DX_IP' in os.environ:
        return os.environ['DX_IP']

    return os.popen('docker-machine ip dx-automator-dev').read().strip()


client = Client(host="http://{}".format(get_automator_ip()))
예제 #13
0
import requests, json
from python_http_client import Client
from uts.settings import UMLS_SETTINGS, AVAILABLE_QUERY_PARAMS
from uts.authentication import Authenticator
from collections import abc

BASE_URL = 'https://uts-ws.nlm.nih.gov/rest/'
SERVICE = 'umls'

authenticator = Authenticator()
client = Client(host=BASE_URL)


class Content:
    def __init__(self,
                 resource_url,
                 sabs=None,
                 language=None,
                 page_number=None,
                 page_size=None,
                 ttys=None,
                 include_obsolete=None,
                 include_suppressible=None):
        self.resource_url = resource_url
        self.response = handle_request(
            self.resource_url,
            params=build_query_params(
                sabs=sabs,
                language=language,
                pageNumber=page_number,
                pageSize=page_size,
예제 #14
0
#!flask/bin/python

import json
from flask import Flask, jsonify
from python_http_client import Client

from response import str_http_response
from json_tk import dict_to_obj, convert_to_dict
from human import Moyenne

client = Client(host='http://*****:*****@app.route('/recall', methods=['GET'])
def get_recall():
    response = client.get()

    str_http_response(response)

    json_response = json.loads(response.body)
    humans = [dict_to_obj(human) for human in json_response]
    print("HUMANS" + str(humans))
    return jsonify([convert_to_dict(human) for human in humans])


@app.route('/moy', methods=['GET'])
def get_moy():
    response = client.get()
    str_http_response(response)
예제 #15
0
 def _get_client(cls):
     """Method for create a client http"""
     return Client(host=BASE_URL, append_slash=False)