async def on_message(message):
    # Send api - this is me, and I heard this message
    sleep(5)
    # send api, can I reply?
    # if no, return
    # if yes, return the text sent
    await client.send_message(message.channel, 'Test')
Example #2
0
def worker_no_with(lock,stream):
    lock.acquire()
    try:
        for i in range(5):
            sleep(1)
            stream.write('Lock acquired directly\n')
    finally:
        lock.release()
Example #3
0
def onStartButtonPress():
	startbutton.config(state=Tkinter.DISABLED)
	ledPin(1).write(1)
	ledPin(2).write(1)
	sleep(1)
	ledPin(1).write(0)
	ledPin(2).write(0)
	startbutton.config(state=Tkinter.ACTIVE)
Example #4
0
def upload_df_to_bq(bq_service,
                    dataframe,
                    project_id,
                    dataset_id,
                    table_id,
                    chunksize=1000):
    """Upload pandas dataframe to bigquery table."""
    from apiclient.errors import HttpError
    import uuid
    import sleep

    job_id = uuid.uuid4().hex
    rows = []
    remaining_rows = len(dataframe)

    total_rows = remaining_rows

    for index, row in dataframe.reset_index(drop=True).iterrows():
        row_dict = dict()
        row_dict['json'] = json.loads(row.to_json(force_ascii=False,
                                                  date_unit='s',
                                                  date_format='iso'))
        row_dict['insertId'] = job_id + str(index)
        rows.append(row_dict)
        remaining_rows -= 1

        if (len(rows) % chunksize == 0) or (remaining_rows == 0):
            print "\rStreaming Insert is {0}% Complete".format(
                ((total_rows - remaining_rows) * 100) / total_rows)

            body = {'rows': rows}

            try:
                response = bq_service.tabledata().insertAll(
                    projectId=project_id,
                    datasetId=dataset_id,
                    tableId=table_id,
                    body=body).execute()
            except HttpError as ex:
                raise RuntimeError("Https errors: %s" % ex)

            # For streaming inserts, even if you receive a success HTTP
            # response code, you'll need to check the insertErrors property
            # of the response to determine if the row insertions were
            # successful, because it's possible that BigQuery was only
            # partially successful at inserting the rows.  See the `Success
            # HTTP Response Codes
            # <https://cloud.google.com/bigquery/
            #       streaming-data-into-bigquery#troubleshooting>`__
            # section

            insert_errors = response.get('insertErrors', None)
            if insert_errors:
                raise RuntimeError("Insertion errors: %s" % insert_errors)

            sleep(1)  # Maintains the inserts "per second" rate per API
            rows = []
    print ""
Example #5
0
def upload_df_to_bq(bq_service,
                    dataframe,
                    project_id,
                    dataset_id,
                    table_id,
                    chunksize=1000):
    """Upload pandas dataframe to bigquery table."""
    from apiclient.errors import HttpError
    import uuid
    import sleep

    job_id = uuid.uuid4().hex
    rows = []
    remaining_rows = len(dataframe)

    total_rows = remaining_rows

    for index, row in dataframe.reset_index(drop=True).iterrows():
        row_dict = dict()
        row_dict['json'] = json.loads(
            row.to_json(force_ascii=False, date_unit='s', date_format='iso'))
        row_dict['insertId'] = job_id + str(index)
        rows.append(row_dict)
        remaining_rows -= 1

        if (len(rows) % chunksize == 0) or (remaining_rows == 0):
            print "\rStreaming Insert is {0}% Complete".format(
                ((total_rows - remaining_rows) * 100) / total_rows)

            body = {'rows': rows}

            try:
                response = bq_service.tabledata().insertAll(
                    projectId=project_id,
                    datasetId=dataset_id,
                    tableId=table_id,
                    body=body).execute()
            except HttpError as ex:
                raise RuntimeError("Https errors: %s" % ex)

            # For streaming inserts, even if you receive a success HTTP
            # response code, you'll need to check the insertErrors property
            # of the response to determine if the row insertions were
            # successful, because it's possible that BigQuery was only
            # partially successful at inserting the rows.  See the `Success
            # HTTP Response Codes
            # <https://cloud.google.com/bigquery/
            #       streaming-data-into-bigquery#troubleshooting>`__
            # section

            insert_errors = response.get('insertErrors', None)
            if insert_errors:
                raise RuntimeError("Insertion errors: %s" % insert_errors)

            sleep(1)  # Maintains the inserts "per second" rate per API
            rows = []
    print ""
Example #6
0
async def typewriter(typew):
    typew.pattern_match.group(1)
    await typew.edit("`AAA ADEEELLL.....`")
    sleep(1)
    await typew.edit("`RUN!!, ADELIA MENAKUTKAN`")
    sleep(1)
    await typew.edit("`πŸƒ                        πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                       πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                      πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                     πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ   `LARII`          πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                   πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                  πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                 πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ               πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ              πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ             πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ            πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ           πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒQIH STOP! πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ           πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ            πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ             πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ              πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ               πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                 πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                  πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                   πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                    πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                     πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ  Huh-Huh           πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                   πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                  πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                 πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ                πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ               πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ              πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ             πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ            πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ           πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ          πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ         πŸƒβ€β™€οΈ`")
    await typew.edit("`DIA SEMAKIN MENDEKAT!!!`")
    sleep(1)
    await typew.edit("`πŸƒ       πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ      πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ     πŸƒβ€β™€οΈ`")
    await typew.edit("`πŸƒ    πŸƒβ€β™€οΈ`")
    await typew.edit("`Dahlah Pasrah Aja`")
    sleep(1)
    await typew.edit("`πŸ§ŽπŸƒβ€β™€οΈ`")
    sleep(2)
    await typew.edit("`-πŸ‘©β€β€οΈβ€πŸ‘¨ NGENTOD πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨-`")
    await typew.edit("`-TAMAT-`")
Example #7
0
def game():
    for a in 'You find yourself in a dimly lighted room with no obvious exits, if only you had a torch...however it does have a strange box there. And one door next to the box':
        sys.stdout.write(a)
        sys.stdout.flush()
        sleep(0.02)
    print
    option1=(raw_input('>'))
    if option1=="help":
        helpme1()
    if option1=="look box":
        game2() #This calls the next situation :-)
Example #8
0
def main():
    msg = msgClass.MessageClass(1, UDP_PORT, UDP_IP, buffer_size)

    while True:
        counter = msg.retrieveMsg()
        if counter < 0:
            counter = 0
            createBackup()

        counter += 1
        msg.setMsg(str(counter))
        msg.sendMsg()
        sleep(1)
Example #9
0
def main():
    msg = msgClass.MessageClass(1, UDP_PORT, UDP_IP, buffer_size)

    while True:
        counter = msg.retrieveMsg()
        if counter < 0:
            counter = 0
            createBackup()

        counter += 1
        msg.setMsg(str(counter))
        msg.sendMsg()
        sleep(1)
Example #10
0
async def typewriter(typew):
    typew.pattern_match.group(1)
    await typew.edit("`Terkadang`")
    sleep(1)
    await typew.edit("`Mencintai Seseorang`")
    sleep(1)
    await typew.edit("`Hanya Akan Membuang Waktumu`")
    sleep(1)
    await typew.edit("`Ketika Waktumu Habis`")
    sleep(1)
    await typew.edit("`Tambah Aja 5000`")
    sleep(1)
    await typew.edit("`Bercanda`")
Example #11
0
def read_until(p, s):
    """ read subprocess's stdout until the string is found """
    if isinstance(s, str):
        s = s.encode('ascii')
    b = bytearray()
    l = len(s)
    f = p.stdout.read(l)
    b.extend(f)
    sys.stdout.write(f.decode())
    while b[-l:] != s:
        f = p.stdout.read(1)
        b.extend(f)
        sys.stdout.write(f.decode())
        sleep(0.5)
    return b
Example #12
0
def read_until2(p,s):
    if isinstance(s, str):
        s = s.encode('ascii')
    b = bytearray()
    l = len(s)
    f = p.stdout.read(l)
    b.extend(f)
    sys.stdout.write(f.decode())
    while b[-l:] != s:
        f = p.stdout.read(1)
        b.extend(f)
        sys.stdout.write(f.decode())
        sleep(0.5)
        yield
    return b
Example #13
0
    def get_schools(url):
        doc = open(url).read()
        soup = BeautifulSoup(doc, 'html.parser')
        schools = soup.find_all('a')
    
        schoollist = []

        for school in schools:
            schoolname = school.contents[0].replace('\n','')
            ID = school.get('href').replace("/lectio/", "").replace("/default.aspx", "")
            schoollist.append((schoolname, ID))
            print("Downloaded " + schoolname + "\n")
            sleep(randrange(5,15))
            
        return schoollist
Example #14
0
def device_engine(device_data):
    print("Thread for Device: ", device_data["DEV_number"])
    tp_cmds = device_data["test_cmds"]
    device_number = device_data["DEV_number"]
    lp_len = len(tp_cmds)
    line = 0
    tn = None
    counter = None
    looper = None
    #open log
    log = open(device_data["DEV_SN"]+'.txt', mode='a+')
    # write the whole test script?
    log.write("--------Test Start--------"+)
    while not device_data["event"].isSet():
        tp_key = tp_cmds[line].split()[0]
        if tp_key in TP_KEY_WORDS_MAP.keys():
            try:               
                if tp_key.startswith("telnet"):
                    if tp_key.startswith("telnet_connect"):
                        tn = TP_KEY_WORDS_MAP[tp_key](tp_cmds[line], log)
                    else:
                        TP_KEY_WORDS_MAP[tp_key](tn, tp_cmds[line], log)
                elif tp_key.startswith("system"):
                    log.write(tp_cmds[line]+'\n')
                    TP_KEY_WORDS_MAP[tp_key](str(device_number), manager_queue, device_queue, tp_cmds[line])
                elif tp_key.startswith("power"):
                    log.write(tp_cmds[line]+'\n')
                    TP_KEY_WORDS_MAP[tp_key](device_number, tp_cmds[line])
                elif tp_key.startswith("message"):
                    log.write(tp_cmds[line].split(' ',1)[1]+'\n')
                else:
                    TP_KEY_WORDS_MAP[tp_key](tp_cmds[line])
            except:
                # check retry_flag, loop test, back the label mark line
                print("fail in line %d!\n" % line, tp_cmds[line])
                break
        else:
            print("Not support keyword : %s\n" % tp_key, tp_cmds[line])
            break
        
        line += 1
        sleep(1)
        if line == lp_len:
            print("Test done!, create report!")
            break
    #close log
    log.write("--------Test End--------")
    log.close()
Example #15
0
 ...: def f(x):
 ...:     return (1-x)*exp(-x)
 ...: 
 ...: # Definejam argumenta x robeΕΎas 
 ...: a = 1.1
 ...: b = 3.2
 ...: k = 0 
 ...: #AprΔ“Δ·inam funkcijas vΔ“rtΔ«bas dotajos punktos
 ...: funa = f(a)
 ...: funb = f(b)
 ...:  
 ...: #Pārbaudam, vai dotajā intervālā ir saknes :
 ...: if ( funa * funb > 0.0):
 ...:     print ("Dotajā intervālā [%s, %s] sakΕ†u nav"%(a,b))
 ...:     sleep(1); exit()  #ziΕ†o uz ekrāna, gaida 1 sec. un darbu beidz
 ...: else: 
 ...:     print ("Dotajā intervālā sakne(s) ir!")
 ...: 
 ...: #DefinΔ“jam precizitāti, ar kādu meklΔ“sim sakni :
 ...: deltax = 0.01
 ...: 
 ...: #SaΕ‘aurinam saknes meklΔ“Ε‘anas robeΕΎas:
 ...: while ( fabs(b-a) > deltax ):
 ...:     x = (a+b)/2; funx = f(x)
 ...:     if (funa*funx < 0. ):
 ...:        k = k+1
 ...:        b = x
 ...:     else:
 ...:         a = x
 ...: print ("Sakne ir: ", x)
 ...: print ("Funkcijas vertiba saja punkta ir: ",f(x))
 ...: print ("Intervālu daliisana uz puseem: ",k)
 ...: 
Example #16
0
def game3():
      for a in 'You have the button now, but how to use it is another question.':
        sys.stdout.write(a)
        sys.stdout.flush()
        sleep(0.02)
      print
      option3=(raw_input('>'))
      if option3=="press button":
          game4()
      if option3=="attack button":
          for a in 'You attack the button you have aquired like a stupid fool. And now there is no escape':
            sys.stdout.write(a)
            sys.stdout.flush()
            sleep(0.02)
      print
      youlose()
Example #17
0
def game2():
    for a in 'The box is open and you find a remote looking button there. Your going to have to guess the command on how to use it, as it is not in the help file.':
        sys.stdout.write(a)
        sys.stdout.flush()
        sleep(0.02)
    print
    option2=(raw_input('>'))

    if option2=="get button":
        game3()
    if option2=="get remote like button":
        game3()
    if option2=="help":
        helpme2()
    else:
        print "Er... try reading it again. Or use help to find out what is going on."
        game2()
Example #18
0
def manager_engine(manager_data):
    """
    handle the system, power service, 80C service?
    the servies method will be one shut( open ... action ... close)
    """
    while not manager_data["event"].isSet():
        sleep(5)
        while not manager_data["manager_queue"].empty():
            x= manager_data["manager_queue"].get()
            if x.split(' ',1)[0] == "dev":
                o, dev_n, syscmd = x.split(' ',2)
                print("get!", o, dev_n, syscmd)
                response = syscmd + " ack"
                print("response! ", response)
                manager_data["device_queue_list"][int(dev_n)].put(response)
                sleep(3)

    print("mthread_close!")
Example #19
0
def blink ( pin ):
    GPIO.output(pin, GPIO.HIGH)
    sleep(1)
    GPIO.output(pin, GPIO.LOW)
    sleep(1)
    GPIO.output(pin, GPIO.HIGH)
    sleep(1)
    GPIO.output(pin, GPIO.HIGH)
    sleep(4)
    GPIO.output(pin, GPIO.LOW)
    return
Example #20
0
def check_dist ():
    GPIO.output(GPIO_Trigger, GPIO.HIGH) # set trigger to high
    sleep(1/1000)
    GPIO.output(GPIO_Trigger, GPIO.LOW)

    StartTime = time() # set start and arrive time
    ArriveTime = time()

    while GPIO.input(GPIO_Echo) == 0:
        StartTime = time()

    while GPIO.input(GPIO_Echo) == 1:
        ArriveTime = time()

    dif = ArriveTime - StartTime
    # t*sonic_speed/2 = distance
    dist = (dif * 34300) / 2

    return dist
Example #21
0
def device_thread(device_data):
    print("Thread for Device: ", device_data["DEV_number"])
    lp_len = len(device_data["test_cmds"])
    line = 0
    log = open('device' + str(device_data["DEV_number"]) + '.txt', mode='w+')
    while not device_data["event"].isSet():
        print(device_data["test_cmds"][line])
        log.write(device_data["test_cmds"][line])
        if device_data["test_cmds"][line].split(' ',1)[0] == "system":
            device_data["manager_queue"].put("dev "+str(device_data["DEV_number"])+" ifconfig")
            print(device_data["device_queue"].get())
        line += 1
        sleep(1)
        if line == lp_len:
            print("Test done!, create report log!")
            break

    # test package down, create report
    print(str(device_data["DEV_number"]),"_close!")
    log.close()
Example #22
0
def Project_list():

    i = 1
    #use switch statement or it's alternative
    while (i != 0):
        if [reply] == 1:
            msg = render_template('first_project')
            sleep(30)
            Explain_Project()
            return statement(msg)

        elif [reply] == 2:
            msg = render_template('second_project')
            sleep(30)
            Explain_Project()
            return statement(msg)

        elif [reply] == 3:
            msg = render_template('third_project')
            sleep(30)
            Explain_Project()
            return statement(msg)

        elif [reply] == NULL:
            #msg = render_template('wait')
            sleep(30)
            sleep(30)
            Explain_Project()
            return statement(msg)

        elif [reply] == '0':
            msg = render_template('last')
            i = 0
            return statement(msg)

        else:
Example #23
0
from sleep import *

sleep = sleep()


def readfrom(input_file, output_file):
    f = open(input_file)
    lines = f.readlines()
    f.close()

    i = 0
    f = open(output_file, 'w')
    test_cases = lines[0]
    cases = lines[1:]

    if int(test_cases) in range(1, 101):
        for case in cases:

            if int(case) in range(0, 10**6 + 1):
                print 'Case #' + str(i + 1) + ': ' + sleep.start(int(case))
                f.write('Case #' + str(i + 1) + ': ' + sleep.start(int(case)) +
                        '\n')
                i += 1

    f.close()


def run():

    cmd = raw_input('sleep> ')
    l = cmd.split(' ')
Example #24
0
#MagicalBook.py
import time import sleep
import os
from gpiozero import LED, LightSensor

ldr = LightSensor(18, queue_len=1)
led = LED(25)
led.off()
while True:

	if ldr.wait_for_light()
		print("Light!")
		led.on()
		randomfile = random.choice(os.listdir("/home/pi/music/"))
		file = '/home/pi/music/'+ randomfile
		#os.system ('omxplayer' + file)
		os.system('mp321' + file)

	#time.sleep(5)


	if ldr.wait_for_dark()
		led.off()
		print("Dark!")
		#ldr.when_dark()
		#os.system('killall omxplayer.bin')
		os.system('killall mpg321')
	sleep(0.2)
Example #25
0
Import RPi.GPIO as gpio # fetching the GPIO library
From time import sleep # fetching sleep function
gpio.setmode(gpio.BOARD) # This define how we address pins
gpio.setup(10, GPIO.OUT) # Set the pin mode as output

for x in range(15):
    gpio.output(10, gpio.HIGH) # High voltage that means LED on
    Sleep(2)
    gpio.output(10, gpio.LOW) # LOW voltage, LED off.
    sleep(1)

GPIO.cleanup() # remove all the setup and defined pinmodes.
Example #26
0
import sleep
from telethon.tl.functions.messages import GetHistoryRequest
from telethon.tl.functions.messages import GetMessagesViewsRequest
from telethon import TelegramClient
from telethon import errors

channel = client.get_entity('username')

posts = client(
    GetHistoryRequest(peer=channel,
                      limit=10,
                      offset_date=None,
                      offset_id=0,
                      max_id=0,
                      min_id=0,
                      add_offset=0,
                      hash=0))

for message in posts.messages:
    client(
        GetMessagesViewsRequest(peer=channel, id=[message.id], increment=True))
    sleep(random.uniform(1, 3))
        matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
        name = "Abhijit"
	DIR=20
	STEP=21
	CW=1
	CCW=0
	SPR=12 #90/7.5
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(DIR,GPIO.OUT)
	GPIO.setup(STEP,GPIO.OUT)
	GPIO.output(DIR,CW)
	step_count=SPR
	delay=0.833 #1/12
	for x in range(step_count):
		GPIO.output(STEP,GPIO.HIGH)
		sleep(delay)
		GPIO.output(STEP,GPIO.LOW)
		sleep(delay)
	sleep(5)
	GPIO.outdoor(DIR,CCW)
	for x in range(step_down)
		GPIO.output(STEP,GPIO.HIGH)
		sleep(delay)
		GPIO.output(STEP,GPIO.LOW)
		sleep(delay)
	GPIO.cleanup()
        if True in matches:
            first_match_index = matches.index(True)
            name = known_face_names[first_match_index]
        cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
Example #28
0
import Tkinter
import pyfirmata
From time import sleep
def onStartButtonPress():
	startbutton.config(state=Tkinter.DISABLED)
	ledPin(1).write(1)
	ledPin(2).write(1)
	sleep(1)
	ledPin(1).write(0)
	ledPin(2).write(0)
	startbutton.config(state=Tkinter.ACTIVE)
port = β€˜COM6’
board = pyfirmata.Arduino(port)
sleep(5)
ledPin1 = board.get_pin(β€˜d:11:o’)
ledPin2 = board.get_pin(β€˜d:10:o’)
top = Tkinter.Tk()
top.title(β€œBlink Led using button”)
top.minsize(300,30)
startButton = Tkinter.Button(top,
			     text=”Start”
			     command=onStartButtonPress)
startButton.pack()
top.mainloop()
Example #29
0
ο»Ώ# -*- coding: utf-8 -*-
from url_info import *
from spider import *
import itchat
from sleep import *
from datetime import datetime

sleep()
@itchat.msg_register(itchat.content.TEXT)
def print_content(msg):
    print msg['Text']

itchat.auto_login(hotReload=True)
itchat.run

curTime = datetime.now().strftime('%y-%m-%d')
itchat.send(curTime, 'filehelper')

for (name, fund_id) in ids.items():
    url = 'http://fund.eastmoney.com/%s.html' % fund_id
    value = spider(url)
    sign = value[0]
    value_num = value[1:-1]
    name = name.decode('utf-8')
    if(sign == '-' and float(value_num)>2.5):
        content = u'%sθ·ŒεΉ…εΎˆε€§οΌŒε―δ»₯θ‘₯δ»“'+sign+value_num
        itchat.send(content % name, 'filehelper')
    else:
        content = u'%s δΈιœ€θ¦θ‘₯δ»“'+sign+value_num
        itchat.send(content % name, 'filehelper')
lm = LargeMotor('outC');
rm = LargeMotor('outD');

while True:
    first_us2_value = us2.value()
    lm.run_timed(time_sp = 1000, speed_sp = 300)
    rm.run_timed(time_sp = 1000, speed_sp = 300)
        
    lm.stop(stop_action = "brake")
    rm.stop(stop_action = "brake")
        
    lm.wait_while('running')
    rm.wait_while('running')
     
    sleep(0.3)
    
    second_us2_value = us2.value() #mm λ‹¨μœ„λ‘œ 계산
    
    if first_us_value <=70:
        angle = first_us2_value - second_us2_value
        
        if angle >0:
            lm.run_to_rel_pos(position_sp = -30, speed_sp = 30, stop_action = stop_action)
            rm.run_to_rel_pos(position_sp = -30, speed_sp = 30, stop_action = stop_action)
            
    elif first_us2_value >=200:
        angle = first_us2_value -  second_us2_value
        
        if angle <0:
            lm.run_to_rel_pos(position_sp = 30, speed_sp = 30, stop_action = stop_action)
Example #31
0
def lcd_init():
    lcd_display(0x28,LCD_CMD) # Selecting 4 - bit mode with two rows
    lcd_display(0x0C,LCD_CMD) # Display On,Cursor Off, Blink Off
    lcd_display(0x01,LCD_CMD) # Clear display
    sleep(E_DELAY)
Example #32
0
import sleep
while True:
    for i in ["/", "-", "|", "\\", "|"]:
        sleep(.9)
        print "%s\r" % i,
Example #33
0
# -*- coding: utf-8 -*-

from picamera import PiCamera
import sys
form time import sleep

if __name__ == '__main__':
	args = sys.argv
	camera = PiCamera()
	camera.start_preview()
	camera.start_recording('/home/pi/DumpVideo/'+args[1]+'.h264')
	sleep(10)
	camera.stop_recording()
	camera.stop_preview()
Example #34
0
def sender(chan, value):
    print "[## JK-DBG-1] sender: Starting --->"
    for x in range(0, 10):
    	print "[## JK-DBG-1.1] sender: Sending Data : %s" %format(x) 
    	chan.send(x)
    	sleep(3)
Example #35
0
import RPi.GPIO as a
import time as sleep
but = 19
led = 21
a.setmode(a.BOARD)
a.setwarnings(False)
a.setup(but, a.IN, pull_up_down=a.PUD_DOWN)
a.setup(led, a.OUT)
while 1:
    butstate = a.input(but)
    if (butstate == True):
        a.output(led, True)
        while a.input(but) == False:
            sleep(2)
    else:
        a.output(led, False)
a.output(led, False)
a.cleanup()