Пример #1
0
 def connect(self):
     client = Client(self.USR_KEY)
     client.ping().raise_for_status()
     return client
Пример #2
0
import random
from threading import Timer
from datetime import datetime

# Sevabot & Orchestratre
from sevabot.bot.stateful import StatefulSkypeHandler
from sevabot.utils import ensure_unicode, get_chat_id
from porc import Client

# Load settings
import settings

# Init logger
logger = logging.getLogger('Duarte')
# Init orchestrate.io
client = Client(settings.API_KEY, settings.API_URL)

# Set to debug only during dev
logger.debug('[Duarte] Loading class')


class Duarte(StatefulSkypeHandler):
    """
    Duarte
    Handle Duarte's bans
    """

    def __init__(self):
        """
        Use `init` method to initialize a handler.
        """
Пример #3
0
from porc import Client
import utils, time
from agency import Agency

client = Client("your api key")
agency = Agency("rutgers")

relevantTags = ['a', 'b', 'f', 'lx']

relevantRoutes = []
for relevantTag in relevantTags:
    route = agency.getRoute(relevantTag)
    if route != None:
        relevantRoutes.append(route)

while True:
    print("start")
    predictions = []
    for route in relevantRoutes:
        predictions = predictions + route.getPredictions()

    # asynchronously post items
    with client. async () as c:
        futures = [
            c.post('predictions', prediction) for prediction in predictions
        ]
        responses = [future.result() for future in futures]
        [response.raise_for_status() for response in responses]
    print("end")
    time.sleep(10)
Пример #4
0
from flask import Flask, request
from porc import Client

import braintree

braintree.Configuration.configure(braintree.Environment.Sandbox,
                                  merchant_id="MERCHANT_ID",
                                  public_key="PUBLIC_KEY",
                                  private_key="PRIVATE_KEY")

API_KEY = 'API_KEY'
client = Client(API_KEY)

app = Flask(__name__)


@app.route('/price', methods=['GET', 'POST'])
def price():
    store = request.args.get('store')
    upc_code = request.args.get('upc')
    result = 'No Product In Database'
    response = client.get('stores', store)
    if (upc_code in response['upc']):
        result = str(response['upc'][upc_code]['price'])
    return result


@app.route('/name', methods=['GET', 'POST'])
def name():
    store = request.args.get('store')
    upc_code = request.args.get('upc')
# Using .netrc keeps keys and other private data out of repositories.  Read up on .netrc for the details
# Get authentication secrets
secrets = netrc.netrc()

# Set the right datacenter for the Orchestrate data
orcHost = 'api.ctl-uc1-a.orchestrate.io'
orcURI = 'https://' + orcHost + '/v0'
# Set Orchestrate Credentials
orcUser, orcAcct, orcKey = secrets.authenticators(orcHost)

if DEBUG == 1:
    sys.stdout.write("Connecting to Orchestrate with key = " + orcKey + "\n")

# Connect to Orchestrate and validate key/connection
oClient = Client(orcKey, orcURI)
oClient.ping().raise_for_status()
# Set the mongo endpoint.
mongoEndpoint = '192.168.0.1'
mongoPort = '27017'
mongoURI = "mongodb://" + mongoEndpoint + ":" + mongoPort

# Set Mongo Credentials
mongoUser, mongoAcct, mongoBasePass = secrets.authenticators(mongoEndpoint)
mongoPass = mongoBasePass.decode('base64').rstrip('\n')

if DEBUG == 1:
    sys.stdout.write("Connecting to " + mongoURI + " with user: "******"\n")
client = MongoClient(mongoURI)
Пример #6
0
from porc import Client
from collections import defaultdict
import time

client = Client('f61515c7-8df9-4003-ab45-2f3e259610ff')


def displayNumUsers():
    numbers = client.list('numbers').all()
    return str(len(numbers))


def mostPopularSong():
    songs = client.list('songs').all()
    max = 0
    songName = ''
    for i in range(0, len(songs)):
        if (songs[i]['value']['playCount'] > max):
            max = songs[i]['value']['playCount']
            songName = songs[i]['path']['key']
            song = songs[i]
    return songName


def displayNumSongs():
    songs = client.list('songs').all()
    return str(len(songs))


if __name__ == '__main__':
    print displayNumUsers() + ',' + displayNumSongs() + ',' + mostPopularSong(
Пример #7
0
from porc import Client

from porc import Patch

from dejavu.database import Database

client = Client("7e23e64c-f1a8-4072-90c7-6c00c804c0e5")
# tables
FINGERPRINTS_TABLENAME = "fingerprints"
SONGS_TABLENAME = "songs"

# fields
FIELD_FINGERPRINTED = "fingerprinted"
    
class OrchestrateDatabase(Database):
    type = "orchestrate"

    def __init__(self, **options):
            super(OrchestrateDatabase, self).__init__()
            self._options = options
        
    def insert(self, hash, sid, offset):
        """
        Insert a (sha1, song_id, offset) row into database.
        """
       

    def insert_song(self, songname, file_hash):
        """
        Inserts song in the database and returns the ID of the inserted record.
Пример #8
0
# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html

from porc import Client
import rethinkdb as r

conn = r.connect("localhost", 28015)

host = "https://api.aws-eu-west-1.orchestrate.io/"
client = Client("5d754f98-857a-4aed-8dc6-0e397c8d1816", host)


class ThemisbotPipeline(object):
    def process_item(self, item, spider):
        return item


class CleanUpPipeline(object):
    def process_item(self, item, spider):

        item['content'].remove('Advertisement')

        return item


class OrchestratePipeline(object):
    def process_item(self, item, spider):
Пример #9
0
"""
Roadmap's main flask app.


"""

import os
from porc import Client
from flask import Flask
from flask.ext.appconfig import AppConfig


def create_app(configfile=None):
    app = Flask(__name__)
    AppConfig(app, configfile)
    return app


app = create_app()

# mail = Mail(app)
# db = SQLAlchemy(app)

client = Client(app.config['ORCHESTRATE_KEY'])
client.ping().raise_for_status()

import roadmap.views

if __name__ == '__main__':
    app.run()