def consumer(): if len(sys.argv) < 4: print('Invalid argument list. use python main.py <storage strategy> <resources> <bucket name> [bucket 2 name]') exit(-1) strategy = sys.argv[1] resources = sys.argv[2] bucket_name = sys.argv[3] s3 = boto3.resource('s3') bucket = s3.Bucket(bucket_name) dynamo_service = Dynamo() s3_service = S3() if strategy.upper() == "CREATE": if resources.upper() == "DYNAMO": contents = s3_service.get_all_bucket_contents(bucket) print(dynamo_service.create(contents)) s3_service.delete_all_bucket_contents(bucket, contents) if resources.upper() == "S3": if len(sys.argv) < 5: print('Invalid argument list. s3 resource requires two buckets use python main.py <storage strategy> ' 's3 <bucket name> <bucket 2 name>') exit(-1) bucket2 = sys.argv[4] contents = s3_service.get_all_bucket_contents(bucket) print(s3_service.create(contents, bucket, bucket2)) s3_service.delete_all_bucket_contents(bucket, contents)
def main(): parametros = validacao_parametros() global dynamodb global mqtt mqtt = Mqtt(parametros['broker'], parametros['user'], parametros['password'], parametros['topic'], on_connect) dynamodb = Dynamo(parametros['dynamodb']) subscriber()
def main(): parametros = validacao_parametros() # if os.path.exists('dump/' + parametros['publisher']): # pub_items=pickle.load(open('dump/' + parametros['publisher'], 'rb')) # else: # pub_table = Dynamo(parametros['publisher']) # pub_items = pub_table.scan_messages() # with open('dump/' + parametros['publisher'], 'wb') as fp: # pickle.dump(pub_items, fp) if os.path.exists('dump/' + parametros['subscriber']): sub_items=pickle.load(open('dump/' + parametros['subscriber'], 'rb')) else: sub_table = Dynamo(parametros['subscriber']) sub_items = sub_table.scan_messages() with open('dump/' + parametros['subscriber'], 'wb') as fp: pickle.dump(sub_items, fp) diferenca, mensagens= validacao_mensagens( sub_items) #inter_arrival_times(mensagens) inter_arrival_rate(mensagens) # inter_sending_rate(pub_items) grafico_atraso( mensagens) #impressão dos resultados optidos print("Foi recebido "+ str(len(sub_items)) + " mensagens") # print("Foram recebidos " + str(porcentagem) + "% das mensagens!") print('A média aritmética dos atrasos foram ' + str(statistics.mean(diferenca)) +' segundos') print('A mediana dos atrasos foram ' + str(statistics.median(diferenca)) +' segundos') print('A variância populacional dos atrasos foram ' + str(statistics.pvariance(diferenca)) +' segundos') print('O desvio padrão populacional dos atrasos foram ' + str(statistics.pstdev(diferenca)) +' segundos') min_index = diferenca.index(min(diferenca)) max_index = diferenca.index(max(diferenca)) print('O maior atraso foi da mensagem id: ' + str(mensagens[max_index]['id']) + ' que teve uma diferença de ' + str(diferenca[max_index]) + ' segundos') print('O menor atraso foi da mensagem id: ' + str(mensagens[min_index]['id']) + ' que teve uma diferença de ' + str(diferenca[min_index]) + ' segundos')
def handler(event, context): config = KMS() db = Dynamo(config) foursquare = Fs(config) twitter = Twitter(config) client = RemoteCKAN('https://data.boston.gov') viols = get_viols(client) client.close() for viol in viols: if not db.query(viol['_id']): count = db.count(viol['LICENSENO']) url = format_url(viol) text = format_msg(viol, count, url) (lat, lon) = extract_geo(viol) place = foursquare.place_search(name=viol['businessName'], lat=lat, lon=lon) photo_url = None if place: photo_url = foursquare.random_photo_url(place) twitter.tweet(text, photo_url, lat, lon) db.save(viol['_id'], viol['LICENSENO']) break else: print('Violation already known to Dynamo')
import os import socket import boto3 import sys from channel import Channel from dynamo import Dynamo from collections import namedtuple from chat_handlers.autoreplies import AutoReplies command_marker = '!' dynamo = '' isDebug = 'debug' in sys.argv if isDebug: dynamo = Dynamo(boto3.resource( 'dynamodb', endpoint_url="http://localhost:8000")) else: dynamo = Dynamo(boto3.resource('dynamodb', region_name='us-west-2')) class MikuBot: """ The meat of the miku bot. This needs to be broken up into many testable chunks. For now it will manually join one of the two servers and receive all messages and hold all channel objects """ handlers = [AutoReplies(dynamo)] channels = {} def start(self):
def uploaddata(): dyn = Dynamo(region_name) message = dyn.upload_data() return str(message)
def createtables(): dyn = Dynamo(region_name) message = dyn.create_tables() return str(message)
def run_worker(mount_points, controller, server, nodes, domains, **kwargs): worker = Dynamo(mount_points, controller, server, nodes, domains, **kwargs) worker.run()