from json import loads import python3_gearman as gearman import numpy as np from keras.models import model_from_json from skimage.transform import resize from PIL import Image import warnings warnings.filterwarnings("ignore") print("Ignorando warnings, especialmente do scikit-image") gm_worker = gearman.GearmanWorker(['localhost:4730']) def process(gearman_worker, gearman_job): try: # ### Carregar o modelo de arquivos JSON e H5 # print("Carregando modelo") json_file = open( "/home/diego/projetos/ferias2018.2/core/mnist/model/model.json") h5file = "/home/diego/projetos/ferias2018.2/core/mnist/model/model.h5" loaded_model_json = json_file.read() json_file.close() loaded_model = model_from_json(loaded_model_json) # load weights into new model loaded_model.load_weights(h5file) # ### Ler a imagem do disco, tratá-la e dar o veredito
import python3_gearman import configparser config = configparser.ConfigParser() config.read('config.ini') CONNECTION_STRING = '%s:%s' % (config['CORE']['GEARMAN_SERVER_HOST'], config['CORE']['GEARMAN_SERVER_PORT']) print(CONNECTION_STRING) gm_worker = python3_gearman.GearmanWorker([CONNECTION_STRING]) # See python3_gearman.job.py to see attributes on the GearmanJob # Send back a reversed version of the 'data' string def task_listener_reverse(gearman_worker, gearman_job): return gearman_job.data[::-1] # gm_worker.set_client_id is optional gm_worker.set_client_id('plabs_reverse_string_py3') gm_worker.register_task('reverse', task_listener_reverse) # Enter our work loop and call gm_worker.after_poll() after each time we timeout/see socket activity gm_worker.work()
print(user.get_recent_activity()) def get_team_data(team_id="955529db-5622-4dca-9c90-8cb0e5fe032f"): client_secret = "W9hAa7i62Uv?hLTLH-?BlxhRCYWIkj?A" application_id = "bdf4dd0c-9ba0-4bc2-b72f-d7ce5023f0b9" credentials = (application_id, client_secret) tenant_id = "17855ce0-d47e-48df-9c90-33b4fa21c861" account = Account(credentials, auth_flow_type="credentials", tenant_id=tenant_id) account.authenticate() team = Group(group_id=team_id, parent=account, protocol=MSGraphProtocol()) print(team.get_id()) response = team.get_reports() print(json.loads(response.text)) with open('data.txt', 'w') as outfile: json.dump(response.text, outfile) gm_worker = python3_gearman.GearmanWorker(['localhost:4730']) while (True): print("Waiting for client requests...") gm_worker.register_task('create_team', create_team) gm_worker.register_task('update_team', update_team) gm_worker.register_task('archive_nd_delete_team', archive_nd_delete_team) gm_worker.work()
import python3_gearman gm_worker = python3_gearman.GearmanWorker(['10.240.154.201:4730']) def task_listener_reverse(gearman_worker, gearman_job): print('Reversing string: ' + gearman_job.data) return gearman_job.data[::-1] # gm_worker.set_client_id is optional gm_worker.set_client_id('python-worker3') gm_worker.register_task('crawl', task_listener_reverse) # Enter our work loop and call gm_worker.after_poll() after each time we timeout/see socket activity gm_worker.work()