Esempio n. 1
0
 def testLaunchGalleryFromContact(self):
     self._launchContact()
     assert d(resourceId = 'com.android.contacts:id/menu_add_contact').wait.exists(timeout=1000),'unable to add new contacts'
     d(resourceId = 'com.android.contacts:id/menu_add_contact').click.wait()
     if d(text ='Create contact').wait.exists(timeout =1000):
         d(text ='Create contact').click.wait()
         time.slee(1)
         if d(text ='Create contact').wait.exists(timeout =1000):
             d(text ='Always').click.wait()
     if d(text ='Add account').wait.exists(timeout =1000):
         d(text ='Keep local').click.wait()
     time.sleep(1)
     if d(text ='OK').wait.exists(timeout =1000):
         d(text ='OK').click.wait()
     assert d(text = 'Done').wait.exists(timeout=1000),'create new contact fail' 
     d(resourceId = 'com.android.contacts:id/frame').click.wait()
     time.sleep(1)
     assert d(text = 'Choose photo from Gallery').wait.exists(timeout=1000),'enter select photo menu fail'
     d(text = 'Choose photo from Gallery').click.wait()
     time.sleep(2)
     assert d(text = 'Recent').wait.exists(timeout=2000),'enter choose photo from gallery menu fail'
     d(text = 'Recent').click.wait()
     for i in range(0,100):
         d(index = 6).click.wait()
         assert d(packageName = 'com.intel.android.gallery3d').wait.exists(timeout =2000),'enter gallery fail'
         self._pressBack(1)
         time.sleep(1)
    def _search(self, query, limit, offset, format):
        '''
        Returns a list of result objects, with the url for the next page bing search url.
        '''

        url = self.QUERY_URL.format(urllib2.quote("'{}'".format(query)), limit, offset, format)
        #r = requests.get(url, auth=("", self.api_key), proxies=self.proxies)
        r = requests.get(url, auth=("", self.api_key))
        print url

        try:
            json_results = r.json()
        except ValueError as vE:
            if not self.safe:
                print ("Request returned with code %s, error msg: %s" % (r.status_code, r.text))
                #raise PyBingException("Request returned with code %s, error msg: %s" % (r.status_code, r.text))
                return [],r.status_code
            else:
                print "[ERROR] Request returned with code %s, error msg: %s. \nContinuing in 5 seconds." % (r.status_code, r.text)
                time.slee(5)
        try:
            next_link = json_results['d']['__next']
        except KeyError as kE:
            print "Couldn't extract next_link: KeyError: %s" % kE
            next_link = None
        return [Result(single_result_json) for single_result_json in json_results['d']['results']], next_link
Esempio n. 3
0
def steer(prediction):
    dist = us1.distance()
    print(dist)
    if prediction == 1 and dist > 40:
        print('forward')
        g.forwardGPIO()
    elif dist < 40 and prediction == 1:
        print('too close! going away')
        g.reverseGPIO(1.6)
        time.sleep(0.1)
        g.leftGPIO()
    elif prediction == 0 and dist > 40:
        print('left')
        g.leftGPIO()
    elif dist < 40 and prediction == 0:
        print('nope! going right!')
        g.reverseGPIO(1.6)
        time.sleep(0.1)
        g.rightGPIO()
    elif prediction == 2 and dist > 40:
        print('right')
        g.rightGPIO()
    elif dist < 40 and prediction == 2:
        print('nope! going left')
        g.reverseGPIO(1.6)
        time.slee(0.1)
        g.leftGPIO()
    else:
        print('Take care of me please :)')
        g.stopGPIO()
Esempio n. 4
0
 def _search(self, query, limit, offset, format):
     '''
     Returns a list of result objects, with the url for the next page bing search url.
     '''
     url = self.QUERY_URL.format(urllib2.quote("'{}'".format(query)), limit,
                                 offset, format)
     r = requests.get(url, auth=("", self.api_key))
     try:
         json_results = r.json()
     except ValueError as vE:
         if not self.safe:
             raise PyBingException(
                 "Request returned with code %s, error msg: %s" %
                 (r.status_code, r.text))
         else:
             print "[ERROR] Request returned with code %s, error msg: %s. \nContinuing in 5 seconds." % (
                 r.status_code, r.text)
             time.slee(5)
     try:
         next_link = json_results['d']['__next']
     except KeyError as kE:
         print "Couldn't extract next_link: KeyError: %s" % kE
         next_link = ''
     return [
         Result(single_result_json)
         for single_result_json in json_results['d']['results']
     ], next_link
def rmtree(dirs, times=5):
    for i in range(times):
        try:
            if os.path.exists(dirs):
                #os.removedirs(dirs)
                shutil.rmtree(dirs)
                break
        except:
            time.slee(1)
Esempio n. 6
0
def turnDegrees(degrees):
	if degrees == 0:
		return	
	if degrees < 0:
		setMotors([-100, 100])
	else:
		setMotors([100, -100])
	time.slee(degrees / 120)
	setMotors([100, 100])
Esempio n. 7
0
    def test_can_start_a_budget_and_calculate_tax(self):

        # Bonnie the Budgerigar has heard about an awesome new budgeting app.
        # She goes online to check out it's homepage.
        self.browser.get('http://localhost:8000')

        # She notices the page title and header indicate that she is on the
        # Budgie Budget Site.
        self.assertIn('Budgie Budget', self.browser.title)

        # She notices that there is a header for the top of the Budget
        header_text = self.browser.find_element_by_id('h1').text
        self.assertIn('Salary:', header_text)

        # She is invited to add her salary straight away
        inputbox = self.browser.find_element_by_id('id_salary')
        self.assertEqual(
            inputbox.get_attribute('placeholder'),
            'What is your current Annual Salary?'
        )

        # Testing out her desired salary of $100,000, she types it in to the
        # text field and presses ENTER.
        salary_amount = 100000
        inputbox.send_keys(salary_amount)
        inputbox.send_keys(Keys.ENTER)
        time.sleep(1)

        # Bonnie notices that the page now lists her Salary
        # alongside the amount of Tax that Bonnie can expect to pay
        displayed_salary = self.browser.find_element_by_id('id_salary_amount')
        displayed_tax = self.browser.find_element_by_id('id_tax_displayed')
        self.assertEqual(displayed_salary, salary_amount)
        self.assertEqual(displayed_tax, "24497")

        # Shocked by the amount of Tax on that Salary, Bonnie enters a lower 
        # salary of $80,000 and presses ENTER.
        new_salary_amount = 80000
        inputbox.send_keys(new_salary_amount)
        inputbox.send_keys(Keys.ENTER)
        time.slee(1)

        # Bonnie notices that both the Salary and Tax displayed have updated
        # to reflect her lower salary.
        new_displayed_salary = self.browser.find_element_by_id('id_salary_amount')
        new_displayed_tax = self.browser.find_element_by_id('id_tax_displayed')
        self.assertEqual(new_displayed_salary, new_salary_amount)
        self.assertEqual(new_displayed_tax, "17547")

        self.fail("Finish the functional tests!")
    def test_put_cmd_vel(self):  #cmd_velのテスト
        pub = rospy.Publisher('/cmd_vel', Twist)
        m = Twist()
        m.linear.x = 0.1414  #この速度、加速度で左が200Hz、右が600Hzになる。
        m.angular.z = 1.57
        for i in range(10):
            pub.publish(m)
            time.sleep(0.1)

        self.file_check("rtmotor_raw_l0", 200, "wrong left value from cmd_vel")
        self.file_check("rtmotor_raw_r0", 600,
                        "wrong right value from cmd_vel")

        time.slee(1.1)  #1秒後に止まることを確認
        self.file_check("rtmotor_raw_r0", 0, "dont stop after 1[s]")
        self.file_check("rtmotor_raw_l0", 0, "dont stop after 1[s]")
Esempio n. 9
0
 def _send_pulse_and_wait(self):
     """
     Send the pulse to trigger and listen on echo pin.
     We use the method `machine.time_pulse_us()` to get the microseconds until the echo is received.
     """
     self.trigger.value(0)  # Stabilize the sensor
     time.sleep(5)
     self.trigger.value(1)
     # Send a 10us pulse.
     time.slee(10)
     self.trigger.value(0)
     try:
         pulse_time = machine.time_pulse_us(self.echo, 1,
                                            self.echo_timeout_us)
         return pulse_time
     except OSError as ex:
         if ex.args[0] == 110:  # 110 = ETIMEDOUT
             raise OSError('Out of range')
         raise ex
Esempio n. 10
0
def main():

    os.system("clear")

    print(bcolors.FAIL + banner.index + bcolors.ENDC)
    print(banner.options)

    option = raw_input('[1-2] > ')

    if option == '1':
        crack()
    elif option == '2':
        print('[-] Exiting...')
        time.slee(2)
        sys.exit()
    else:
        print('[-] ' + bcolors.UNDERLINE + 'Invadid option.' + bcolors.ENDC +
              '\n')
        main()
Esempio n. 11
0
    def analyzeResult(self, result, reg, pattern_name, search_type):

        max_size = 100

        if result.totalCount > max_size:
            result = result[:max_size]

        if search_type == 'Code':
            for file in result:
                decoded_file = str(file.decoded_content)
                for x in reg:
                    check = re.search(x, decoded_file)
                    if check:
                        print(Fore.RED)
                        print('-------------------------\n')
                        print('[--] Possible ' + pattern_name +
                              ', Found on Code ....')
                        print("[--] URL : " + file.html_url + '\n')
                        self.alerts.append({
                            'name': pattern_name,
                            'url': file.html_url
                        })
            time.sleep(2)

        elif search_type == 'Commit':

            for file in result:
                print(Fore.RED)
                print('-------------------------\n')
                print('[--] Possible ' + pattern_name +
                      ', Found on Commit ....')
                print("[--] URL : " + file.html_url + '\n')
                self.alerts.append({
                    'name': pattern_name,
                    'url': file.html_url
                })
            time.slee(2)
Esempio n. 12
0
import time

import machine

led = machine.Pin(23, machine.Pin.OUT)

while True:

    led.value(1)
    time.sleep(0.001)
    led.value(0)
    time.slee(0.001)
Esempio n. 13
0
File: tblc.py Progetto: almost/tblc
def TransferHex(hexfile, port="/dev/ttyUSB0", baud=19200):
    baud = int(baud)
    pic_mem, eeprom_mem, config_mem = chunkhexfile(hexfile)
    
    print "Trying to open port"
    while True:
        if CheckConection(port, baud):
            break
        else:
            print "Can't open port, retrying..."
            time.slee(2)
    print "Attempting to connect to PIC (press the reset button then release it)"
    while True:
        type,max_flash,family=CheckPic(port, baud)
        if max_flash is not None:
            break
        
    #Ading first 8 pic mem data to the begining of bootloader
    if family=="16F8XX":
        hblock=8 #Hex Block 8 bytes
        block=4  #PIC Block 4 instructions (8 memory positions)
        maxpos=max_flash-100+4
        minpos=4
        
        interval=8*((len(pic_mem))/8+1)
        for i in range (0,8,1):
           
            try:
                pic_mem[i+2*max_flash-200]=pic_mem[i]
                    
                
            except:
                pic_mem[i+2*max_flash-200]=0xff

    if family=="16F8X":
        #The pic 16F87 and 16F88 do erase the program memory in blocks
        #of 32 word blocks (64 bytes)
        
        hblock=64 #Hex Block 64 bytes
        block=32  #PIC Block 32 instructions (64 memory positions)
        
        maxpos=max_flash-100+4
        minpos=0

        ###############################
        for i in range(8):
            adr = 2*(max_flash-100)+i
            pic_mem[adr] = pic_mem.get(i,0xFF)
        ###############################
        
        pic_mem[0]=0x8A
        pic_mem[1]=0x15
        pic_mem[2]=0xA0
        pic_mem[3]=0x2F

        interval=64*((len(pic_mem))/64+1)
        
                  
    if family=="18F" or family=="18FXX2":
        
        for i in range (0,8,1):
            try:
                pic_mem[i+max_flash-200]=pic_mem[i]
        
            except:
                pic_mem[i+max_flash-200]=0xff
               
            
        # The blocks have to be written using a 64 bytes boundary
        # so the first 8 bytes (reserved by TinyPic) will be re writen
        # So we have to include a goto max_flash-200+8
        goto_add=((max_flash-200+8)/2)
        hh_goto=(goto_add/0x10000)&0x0F
        h_goto=(goto_add/0x100)&0xFF
        l_goto=goto_add&0xFF
        
        pic_mem[0]=l_goto
        pic_mem[1]=0xEF
        pic_mem[2]=h_goto
        pic_mem[3]=0xF0+hh_goto

        block=64
        hblock=64
        maxpos=max_flash-200+8
        minpos=0
        interval=64*((len(pic_mem))/64+1)
        
        
    #Beginung Hex data tranfer
    
    start = time.time()
    Write_default_config(port, baud, family)
    begin=time.strftime("%H:%M", time.localtime())

    print "Programming.."
    try:
        s=serial.Serial(port,baud,timeout=0.5)
    except:
        print 'No port detected'
        return
    
    for pic_pos in range(minpos,maxpos,block):
        mem_block=[255]*hblock
        write_block=False
        for j in range(0,hblock):
                      
            #.hex file address is pic_address/2 for the 16F familly
            if (family=="16F8XX") or (family == "16F8X"):
                hex_pos=2*pic_pos+j
                
            elif family=="18F" or family=="18FXX2":
                hex_pos=pic_pos+j
                
            else :
                print "Error, family not suported:",family
                return
            
            if pic_mem.has_key(hex_pos):
                mem_block[j]=pic_mem[hex_pos]
                write_block=True
                
        if write_block: 

            hm=(pic_pos/256)&255
            lm=(pic_pos&255)
            rl=len(mem_block)

            if (family=="16F8XX")or(family=="16F8X"):
                # Calculate checksum
                chs=hm+lm+rl
                s.write(chr(hm)+chr(lm)+chr(rl))
                for i in range(0,rl):
                
                    # Calculate checksum
                    chs=chs+mem_block[i]
                    
                    s.write(chr(mem_block[i]))
                    
                chs=((-chs)&255)
                s.write(chr(chs))
                ret=s.read(1)

            if family=="18F" or family=="18FXX2":
                # Calculate checksum
                chs=hm+lm+rl
                # the pic receives 3 byte memory address
                # TBLPTRU TBLPTRH TBLPTRL
                # Todo: Check if TBLPTRU can be different to 0
                #           TBLPTRU TBLPTRH TBLPTRL
                s.write(chr(0)+chr(hm)+chr(lm)+chr(rl))
               
                for i in range(0,rl):
                    # Calculate checksum
                    chs=chs+mem_block[i]
                    s.write(chr(mem_block[i]))
                
                chs=((-chs)&255)
                s.write(chr(chs))
                ret=s.read(1)
            
            if ret!="K":
                s.close()
                
                print "Error writing to the memory position: "+ hex(pic_pos)+"\n\n"
                return        
       
    #write_config(config_mem,family)
    end = time.time() 
    print "\n WRITE OK at "+str(begin)+' time: '+str(end-start)[0:5]+' sec'
     
    s.close()
    return 
Esempio n. 14
0
 def run(self):
         while True:
                 scanner()
                  time.slee()
Esempio n. 15
0
    print("\033[1;92mInstalling....")
    os.system("git clone https://github.com/BangDanz/autombf")
    os.system("cd autombf")
    os.system("python2 hack.py")
elif pil == "10":
    print("\033[1;92mLoading.....")
    time.sleep(2.3)
    os.system("clear")
    sleep(2)
    print("CARA SUAPA AKUN TIDAK KENA CP")
    sleep(2)
    print("1.Lu harus buat akun fb baru")
    sleep(2)
    print("2.ttl harus 1988")
    sleep(2)
    print("3.menggunakan termux zsh")
    sleep(2)
    print("4.login menggunakan desktop opera mini")
    time.slee(2)
    print("selesai...")
    time.sleep(2)
    os.system("python multidarkfb.py")
elif pil == "00":
    print("\033[1;92mTERIMAKASIH SUDAH PAKAI TOOLS INI")
    sleep(2)
    print("Bye Tod*_")
else:
    print("\033[1;92mInput tidak ada")
    sleep(2)
    os.system("python2 multidarkfb.py")
import json
import time
consumer_key=os.environ['consumer_key']
consumer_secret=os.environ['consumer_secret']
access_token=os.environ['access_token']
access_token_secret=os.environ['access_token_secret']

# ライブラリ
# https://github.com/twitterdev/search-tweets-python
# query参考
# https://twittercommunity.com/t/premium-api-endpoint/101041/3
LABEL = 'dev2'
api = TwitterAPI(consumer_key, consumer_secret, access_token, access_token_secret)

now = datetime.datetime.now()
past_year = now - timedelta(days=30)

# 時間分割して、スキャンしていく
for i in range(30*24):
	past_year += timedelta(minutes=60)
	start = past_year.strftime('%Y%m%d%H%M')
	end   = (past_year + timedelta(minutes=9)).strftime('%Y%m%d%H%M')
	print(start, end)
	r = api.request(f'tweets/search/30day/:{LABEL}',
                {'query':'FGO', 'maxResults':"100", 'fromDate':'201811010000', 'toDate':'201811012300'})
		
	buff = [item for item in r]
	obj = json.dumps(buff, indent=2, ensure_ascii=False)
	open(f'search_premiums/{start}.json', 'w').write( obj )
	time.slee(1.0)
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT,initial=GPIO.LOW)//7号口用来控制驱动板

print("start!")
GPIO.output(7,GPIO.HIGH)
time.slee(60)//延时一分钟
GPIO.output(7,GPIO.LOW)
print("stop!")

GPIO.cleanup()
    # raw_data_collection.remove()
    plant_seed(seed_id, raw_data_collection)
    raw_data_collection.find_and_modify(query={"_id": seed_id}, update={"$set": {"status": "IDLE"}}, upsert=False)
    explorer_1 = Explorer(shared_crawler, raw_data_collection, semi_collection, complete_collection, 0)
    collector_1 = Collector(shared_crawler, semi_collection, complete_collection, 1)
    while True:
        cursor = raw_data_collection.find()
        semi = semi_collection.find()

        try:
            print "exploer"
            explorer_1.explore()
        except Exception as e:
            time.sleep(20)
            print "Something happened", e
        print "number seed before:", cursor.count()
        print "number semi seed before:,", semi.count()
        time.slee(20)
        try:
            print "Crawl"
            collector_1.mining_engine_start()
        except Exception as e:
            time.sleep(20)
            print "some thing happened", e
        print "number seed after:", cursor.count()
        print "number semi seed after:,", semi.count()
        if cursor.count() == 0 and semi.count() == 0:
            break
        time.sleep(20)
    fb.close()
Esempio n. 19
0
                conn.sendall(
                    '0')  #indica que el proceso de graficado debe acabar
                time.sleep(1)
                conn.close()
            ardS.write(b"E")  #Desactiva los sensores
            ardS.write(b"s")
            time.sleep(2)
            GPIO.cleanup()
            #os.excel("restart.sh","")
            sys.exit()
        elif (b2S == 1):
            print("Modulos Desactivados")
            if (debug):
                conn.sendall(
                    '0')  #indica que el procesdo de graficado debe acabar
                time.slee(1)
                conn.close()
            ardS.write(b"E")  #Desactiva los sensores
            ardS.write(b"s")
            time.sleep(2)
            GPIO.cleanup()
            sys.exit()

#########################MODO MANUAL###############################################
    while b2F == 2:  #Modo manual activo
        if ena2S == 1:
            ena2S = 0
            print("Modo manual Activo")
            for i in range(5):  #parpadeo 5 veces modo manual
                GPIO.output(ledS, GPIO.HIGH)
                time.sleep(0.5)  # parpadeo indica modo manual
    print 'TESTING: Calling', StartURL, 'to set the camera pointers'
else:
    urllib.urlopen(StartURL)
# Set up RPi pins as they are on the board (pysical location). Check
# http://elinux.org/File:GPIOs.png to see what each pin does or which
# number it actually is.
if options.Test:
	print 'TESTING: Setting up board pins layout and "AnodePin"'
	print 'TESTING: Spinning up anode'
else:
	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(AnodePin, GPIO.OUT)
	# Set the 'AnodePin' to HIGH to spin up the anode
	GPIO.output(AnodePin, GPIO.HIGH)
	# wait for half a second until the anode is ready
	time.slee(0.5)
# Wait for camera signaling that it is ready by listening on the input port
if options.Test:
    print 'TESTING: Setting up "InputPin"'
else:
    GPIO.setup(InputPin, GPIO.IN)
if options.Test:
    print 'TESTING: Waiting for signal from camera on "InputPin"'
    print 'TESTING: Setting "XraySourcePin" to high'
    print 'TESTING: Sleeping for "options.ExposureTime"'
else:
    while True:
        # Wait for camera to signal readyness on the InputPin, then go!
        if (GPIO.input(InputPin)):
            # Trigger x-ray pulse with another 4V signal over another pin
            GPIO.output(XraySourcePin, GPIO.HIGH)
Esempio n. 21
0
import sys
sys.path.append("../..")
import time

import arduino

# A simple example of using the arduino library to
# control a servo.

ard = arduino.Arduino()
servo = arduino.Servo(ard, 7)  # Create a Servo object
ard.run()  # Run the Arduino communication thread

while True:
    # Sweep the servo back and forth
    for i in range(0, 120, 10):
        servo.setAngle(i)
        print "Angle", i
        time.sleep(0.1)
    for i in range(120, 0, -10):
        servo.setAngle(i)
        print "Angle", i
        time.slee(0.1)