Beispiel #1
0
def seekTh(goal, cur):
	# get to the theta you need to get to!!!
	# don't continue untill you are there
	# everything else can sleep


	print("start seeking")
	tr()
	dt1 = goal[1] - cur[1]
	dt2 = goal[0] - cur[0]

	# run the one that goes farther at 300
	run_time = int((11500/(pi/2)) * abs(max(dt1, dt2,key=abs)))
	slow_speed = copysign(int(300*min(dt1, dt2,key=abs)/max(dt1, dt2,key=abs)), min(dt1, dt2,key=abs)) 
	fast_speed = copysign(300, max(dt1, dt2,key=abs))

	if dt1<dt2:
		mb.run_timed(time_sp=run_time, speed_sp=fast_speed)
		mc.run_timed(time_sp=run_time, speed_sp=slow_speed)
	else:
		mb.run_timed(time_sp=run_time, speed_sp=slow_speed)
		mc.run_timed(time_sp=run_time, speed_sp=fast_speed)

	sleep(run_time/1000)
	print("done seeking")
Beispiel #2
0
def pt_seek_grad(th1, th2, x):
    epsilon = 0.03
    th1u = dist(th1 + epsilon, th2, x)
    th1d = dist(th1 - epsilon, th2, x)
    th2u = dist(th1, th2 + epsilon, x)
    th2d = dist(th1, th2 - epsilon, x)

    j1 = (th1u - th1d) / (2 * epsilon)
    j2 = (th2u - th2d) / (2 * epsilon)

    update = V(j1, j2)
    update.toUnit()
    rate = 1
    update = update * epsilon * rate

    if isnan(th1 - update.x) or isnan(th2 - update.y):
        tr()

    return th1 - update.x, th2 - update.y
Beispiel #3
0
 def ntest_unchallenged_white_listed_ip(self):
     tr()
     self.replace_config("white_listed.conf")
     result = self.do_curl(Test.BANNED_URL)
     self.assertEqual(result, self.ALLOWED_PAGE)
Beispiel #4
0
    def extract_data(self, post):
        def _extract_phones():
            lst = post['contacts']['list']
            phones_list = []
            for item in lst:
                if item['type'] == 'phone':
                    phone_uri = item['value']['uri']
                    phone = phone_uri.split('number=')[-1].replace('%2B', '+')
                    phones_list.append(phone)
            return ', '.join(phones_list)

        def _extract_address():
            # a hack to merge two stations
            m_id = post.get('metroId')
            if m_id == 2163:
                station = 2146
            else:
                station = m_id
            addr_dict = {
                'address': post['address'].replace('Москва, ', ''),
                'metro_id': station,
                'coords': post['coords'],
            }
            # probably do smth with addr_dict in the future
            return addr_dict

        def _parse_apt_title():
            values = post['title'].split(', ')
            if values[0] == 'Студия':
                rooms = '1'
            else:
                rooms = values[0].split(' ')[0][0:1]
            area = values[1].split(' ')[0]
            floor, floors_total = values[2].split(' ')[0].split('/')
            return {
                'rooms': rooms,
                'area': area,
                'floor': floor,
                'floors_total': floors_total,
            }

        def _parse_room_title():
            vals = post['title'].split(' ')[1:]
            values = []
            for val in vals:
                if val != '>':
                    values.append(val)
            rooms = values[3][0:-3]
            area = values[0]
            floor, floors_total = values[4].split('/')
            return {
                'rooms': rooms,
                'area': area,
                'floor': floor,
                'floors_total': floors_total,
            }

        def _parse_currency():
            values = post['price'].get('metric', '').split(' ')
            if values:
                currency = values[0]
                return currency

        def _parse_is_agency():
            return post['firebaseParams']['commission'] != 'Собственник'

        try:
            phones_str = _extract_phones()
            address_dict = _extract_address()
            if self.kind == 'apartment':
                parsed = _parse_apt_title()
            else:
                parsed = _parse_room_title()
            currency = _parse_currency()
            is_agency = _parse_is_agency()
        except:
            tr()

        data = {
            'address': address_dict.get('address'),
            'station_id': address_dict.get('metro_id'),
            'lat': address_dict.get('coords', {}).get('lat'),
            'lng': address_dict.get('coords', {}).get('lng'),
            'price': post['price']['value'],
            'currency': currency,
            'description': post['description'],
            'origin': self.name,
            'origin_id': post['id'],
            'phones': phones_str,
            'name': post['seller']['name'],
            'added': post['time'],
            'kind': self.kind,
            'is_agency': is_agency,
        }
        data['price'] = "".join(data['price'].split())
        data.update(parsed)
        itm = PostItem(**data)
        if not storage.check_if_post_already_exists(itm):
            self.init_bookkeep_files(post.get('id'),
                                     len(post.get('images', [])))
            yield from self.extract_images_urls(post)
            yield itm
Beispiel #5
0
    delta = np.random.randint(0, 255, size=(h, w, 3)).astype("uint8")
    conta = np.zeros((h, w, 1)).astype("uint8")
    total = np.concatenate((delta, conta), axis=2)

    datas = ((total + datas) % 256).astype("uint8")

    if show:
        plt.imshow(datas)
        plt.pause(2)

    print("Saved")
    datas = datas.reshape(w * h, 4)
    datas = datas.tolist()
    datas = [tuple(datasi) for datasi in datas]
    img.putdata(datas)
    img.save(os.path.join("batch", imgPath))


if not os.path.exists("batch"):
    os.mkdir("batch")
for file in os.listdir():
    if ".png" in file:
        print("randifying " + file)
        randPicture(file, show=False)
"""
tr()
x=np.ones((4,4,1))
y=np.zeros((4,4,1))
xy=np.concatenate((x,y),axis=2)
"""
 def ntest_unchallenged_white_listed_ip(self):
     tr()
     self.replace_config("white_listed.conf")
     result = self.do_curl(Test.BANNED_URL)
     self.assertEqual(result,self.ALLOWED_PAGE);
 def ntest_unchallenged_white_listed_ip(self):
     tr()
     self.replace_config("white_listed.conf")
     result = self.do_curl(BanjaxBehaviorTest.BANNED_URL)
     self.assertEqual(result[self.STD_OUT],self.ALLOWED_PAGE);