Beispiel #1
0
    def __init__(self, startingState='idle', triggerPin=25):
        self.state = startingState

        with open('ports.json', 'r') as f:
            self.ports = json.load(f)
        with open('bins.json', 'r') as f:
            self.bins = json.load(f)

        # set up the magnetic trigger
        self.triggerPin = triggerPin
        gpio_setup(self.triggerPin)

        # set up the cameras
        # self.camera_top = Camera('1.1.3') # when installing make sure the usb port ids match
        self.camera_side = Camera('1.2')

        # connecting to the classifier server
        self.MLServer = WebClient('http://192.168.192.200:5000')

        # initialise the electro magnet locks
        stopMagnet()  # release the locks

        # initialise the i2c lcd screen
        self.ledRed = pinMode(ports['sensors']['digital']['ledRed'], "OUTPUT")
        self.lastText = None
Beispiel #2
0
    def login(self, login, password):
        wait = WebDriverWait(self.driver, 10)
        if not self.driver.title == "Odoo" and not self.driver.current_url.endswith(
                "/web/login"):
            self.driver.get(self.instance_url)
        wait.until(
            expected_conditions.presence_of_element_located(
                (By.NAME, "login")))

        self.driver.find_element_by_name("login").send_keys(login)
        self.driver.find_element_by_name("password").send_keys(password)
        self.driver.find_element_by_name("password").submit()

        wait.until(
            expected_conditions.presence_of_element_located(
                (By.CLASS_NAME, "o_web_client")))
        wait.until(
            expected_conditions.invisibility_of_element_located(
                (By.CLASS_NAME, "o_loading")))
        wait.until(
            expected_conditions.visibility_of_element_located(
                (By.CLASS_NAME, "o_main_navbar")))
        wait.until(
            expected_conditions.visibility_of_element_located(
                (By.CLASS_NAME, "o_user_menu")))

        return WebClient(self.driver)
Beispiel #3
0
    def __init__(self, url, port):
        self.client = WebClient(url)
        self.port = port
        self.app = Flask(__name__)
        self.recycalbe = ['paper', 'plastic', 'glass']

        # when installing make sure the usb port ids match
        self.camera_top = Camera('1.1.3')
        self.camera_side = Camera('1.2')
 def get_items(self):
     web_client = WebClient(WANIKANI_PROFILE_URL + self.username)
     wanikani_soup = BeautifulSoup(web_client.html, features='html.parser')
     apprentice_element = wanikani_soup.find('li', {'id': 'apprentice'})
     apprentice_count = apprentice_element.find('span').text if apprentice_element else None
     guru_element = wanikani_soup.find('li', {'id': 'guru'})
     guru_count = guru_element.find('span').text if apprentice_element else None
     master_element = wanikani_soup.find('li', {'id': 'master'})
     master_count = master_element.find('span').text if apprentice_element else None
     enlightened_element = wanikani_soup.find('li', {'id': 'enlightened'})
     enlightened_count = enlightened_element.find('span').text if apprentice_element else None
     burned_element = wanikani_soup.find('li', {'id': 'burned'})
     burned_count = burned_element.find('span').text if apprentice_element else None
     level_element = wanikani_soup.find('span', {'class': 'level'})
     level = level_element.text if level_element else None
     return {'apprentice': apprentice_count, 'guru': guru_count, 'master': master_count,
             'enlightened': enlightened_count, 'burned': burned_count, 'level': level}
Beispiel #5
0
def loop(scheme, host, port, path):

    try:
        server = WebClient(scheme, host, port, path)
        network = GetSpeed()
        int_addr = InterAddr()

        d1 = threads.deferToThread(network.get_speed)
        d2 = threads.deferToThread(int_addr.get_addr)
        d1.addCallback(server.post_data)
        d2.addCallback(server.post_data)
        d1.addErrback(server.failure)
        d2.addErrback(server.failure)
    except Exception:
        log.critical('Uncaught exception: ', exc_info=sys.exc_info())

    reactor.callLater(1200, loop, scheme, host, port, path)
Beispiel #6
0
    def _process_task(self, client_id, action_id, action, args):
        self.logger.info("start to process task for id:%s" % client_id)        
        
        client = self._web_clients.get(client_id, None) 
        if client is None:
            client = WebClient(client_id, "", "clients")
            client.start_client()
            self._web_clients[client_id] = client

        try:
            handler = self.actions.get(action, None)
            self.logger.debug("[%s] %s, args:%s" % (client_id, action, str(args)))
            if handler is not None:
                result = handler(client, self.robot_api, **args)
                self.action_done(action_id, client, result, self.robot_api)
            else:
                self.logger.error("not found sipder action:'%s'", action)
                                    
        except Exception, e:
            self.logger.exception(e)
Beispiel #7
0
from web_client import WebClient
from camera import Camera
import time

client = WebClient('http://localhost:5000')
camera_top = Camera(
    '1.1.3')  # when installing make sure the usb port ids match
camera_side = Camera('1.2')

print('entering main loop')
while True:
    print('input signal?')
    input()
    time1 = time.time()
    image_top = camera_top.capture()
    image_side = camera_side.capture()
    time2 = time.time()
    pred_label = client.classify(image_top=image_top, image_side=image_side)
    time3 = time.time()
    print('capture time, prediction time', time2 - time1, time3 - time2)
    print('prediction label:', pred_label)
    if pred_label == 'unknown':
        print('need manual label for unknown item:')
        mann_label = input()
        print(client.update(mann_label))
Beispiel #8
0
from flask import Flask, request
import redis

from jnt_client import JnTClient
from web_client import WebClient

app = Flask(__name__)

r = redis.Redis(host="localhost", port=6379, db=0)
web_client = WebClient()
jnt_client = JnTClient()


def check_stock(user_id, name, msg):
    product_name = " ".join(msg.split()[:-2])
    sku, stock = web_client.get_detail(product_name)
    if stock:
        r.set(user_id, f"order|{sku}|{product_name}")
        return f"Ready gan, sisa {stock} nih"
    else:
        r.set(user_id, "default")
        return f"Wah sori gan, kosong..."


def accept_order(user_id, name, msg):
    state, sku, product_name = str(r.get(user_id))[2:-1].split("|")
    r.set(user_id, f"address|{sku}|{product_name}")
    return f"{product_name} kan? Bisa gan, mau dikirim ke mana?"


def send_bill(user_id, name, msg):
Beispiel #9
0
def part_1():
    print("Downloading {}".format(TEST_FILE))
    client = WebClient()
    client.download(TEST_URL, TEST_FILE)
Beispiel #10
0
import ConfigParser
import auth
from web_client import WebClient

configParser = ConfigParser.ConfigParser()
configParser.read('booli.config')

host = configParser.get('auth', 'host')
caller_id = configParser.get('auth', 'caller_id')
api_key = configParser.get('auth', 'api_key')

print 'Collecting data from {} with caller id {}'.format(host, caller_id)

client = WebClient(host, caller_id, api_key)
print client.get('/listings?q=nacka')