예제 #1
0
def add_watch(bot, chat_id, msg_id, address):
    cached_id = cached_address(address)
    if cached_id is None:
        bot.set_handler(chat_id, None)
        bot.reply(chat_id,
                  msg_id,
                  _('watch.blocked_or_broken'),
                  hide_keyboard=True)
        return

    bot.set_handler(chat_id, None)
    result = subscribe(chat_id, cached_id)

    if result[0] is SubscribeStatus.already_watching:
        bot.reply(chat_id,
                  msg_id,
                  _('watch.already_watching'),
                  hide_keyboard=True)
    elif result[0] is SubscribeStatus.done:
        bot.reply(chat_id, msg_id, _('watch.done'), hide_keyboard=True)
    elif result[0] is SubscribeStatus.done_with_blackouts:
        bot.reply(chat_id,
                  msg_id,
                  _('watch.done_with_blackouts') + result[1],
                  hide_keyboard=True)
예제 #2
0
def register():
	endpoint = get_endpoint()
	butler, is_created = models.Butler.objects.get_or_create(endpoint=endpoint)
	
	apps = '\n'.join(get_applications())
	butler.applications = apps
	butler.save()
	
	# pubsubhubbub subscribe!
	from utils import subscribe 
	for app in apps:
		app_url = BUTLER_MASTER_URL + 'job/' + app 
		app_key = get_application_key(app)
		callback_url = reverse('butler.slave.views.callback', args=[app])
		subscribe(hub=BUTLER_HUB_URL, topic=app_url, callback=callback_url, 
			lease_seconds=BUTLER_LEASE_SECONDS, verify_token=app_key)
	return butler
예제 #3
0
def confirm_signup(proxy, vk, phone, activation_id):
    global count
    code = wait_code(activation_id)

    if code == "resign":
        signup(proxy)
        return

    password = generate_password()

    if code != ["STATUS_CANCEL"]:
        vk.auth.confirm(client_id=2274003, client_secret="hHbZxrka2uZ6jB1inYsH", phone=phone, code=code.split(":")[1],
                        password=password)

        requests.get(
            url=f"https://smshub.org/stubs/handler_api.php?api_key={sms_token}&action=setStatus&status=6&id={activation_id}")

        count += 1
        print(f"{count} аккаунт зареган")
        logging.info(f"{count} аккаунт зареган")

        print(f"{phone}:{password}")
        logging.info(f"{phone}:{password}")

        write_log(login=phone, password=password, proxy=proxy)

    for _ in range(15):
        try:
            vk = vk_auth(login=phone, password=password, proxy=proxy)
            break
        except (requests.exceptions.ProxyError, requests.exceptions.ConnectionError):
            print(f"Ошибка авторизации Bad proxy {proxy}")
            logging.error(f"Ошибка авторизации Bad proxy {proxy}")
            sleep(20)
        except vk_api.Captcha as captcha:
            captcha_solver(captcha)

    try:
        upload_photo(vk)
    except vk_api.Captcha as captcha:
        captcha_solver(captcha)

    try:
        subscribe(vk)
    except vk_api.Captcha as captcha:
        captcha_solver(captcha)
예제 #4
0
def start_with_address(bot, msg, arguments, session=None):
    chat_id = msg['chat']['id']
    try:
        b64address = base64.b64decode(arguments[0]).decode("utf-8")
        cached_address = address_cache.add_address_from_url(b64address)
        if cached_address is not None:
            address = session.query(Address).get(cached_address)
            result = subscribe(chat_id, cached_address)
            if result[0] is SubscribeStatus.already_watching:
                bot.send_message(chat_id, _('watch.already_watching'), hide_keyboard=True)
            elif result[0] is SubscribeStatus.done:
                bot.send_message(chat_id, _('start.done').format(addresses=address.address), hide_keyboard=True)
            elif result[0] is SubscribeStatus.done_with_blackouts:
                bot.send_message(chat_id, _('start.done_with_blackouts').format(addresses=address.address) + result[1],
                                hide_keyboard=True)
            return
    except Error as e:
        pass
    except Exception as e:
        traceback.print_exc()
    bot.send_message(chat_id, _('help.line_1'))
예제 #5
0
from camera_tools import get_stereo_cameras, triangulate, rotz

parser = argparse.ArgumentParser()
parser.add_argument("--ip",
                    help="main ground control ip addr",
                    default='127.0.0.1')
parser.add_argument("--scale",
                    help="map size deafult 20",
                    default=20.0,
                    type=float)
args = parser.parse_args()

subs_socks = []
subs_socks.append(
    utils.subscribe([
        config.topic_main_telem, config.topic_comp_vis, config.topic_mav_telem
    ], config.zmq_local_route, args.ip))


def generate_stereo_cameras():
    return get_stereo_cameras(config.focal_length,
                              (config.pixelwidthy, config.pixelwidthx),
                              config.baseline, config.camera_pitch)


def calc_trace(prev_pts, cur_pts, yaw_delta_mat):
    caml, camr = generate_stereo_cameras()

    pt_l_x, pt_l_y, pt_r_x, pt_r_y = prev_pts
    t_pt1 = triangulate(caml, camr, pt_l_x, pt_l_y, pt_r_x, pt_r_y)
    pt_l_x, pt_l_y, pt_r_x, pt_r_y = cur_pts
예제 #6
0
grid_h = sum([(1 if a else 0)*2 for a in (args.ud,args.yaw,args.fb,args.lr)])
if args.depth:
    grid_h+=1
if args.roll:
    grid_h+=1
if args.pitch:
    grid_h+=1
if args.imu:
    grid_h+=1

print('grid_h',grid_h)
subs_socks=[]
subs_socks.append(utils.subscribe([\
    config.topic_main_telem,
    config.topic_comp_vis,
    config.topic_imu,
    ],config.zmq_local_route,args.ip))

##### map radious im meters
rad=20

class CycArr():
    def __init__(self,size=20000):
        self.buf=[]
        self.size=size

    def add(self,arr):
        self.buf.append(arr)
        if len(self.buf)>self.size:
            self.buf.pop(0)
예제 #7
0
import numpy as np
import config
from gst import init_gst_reader, get_imgs, set_files_fds, get_files_fds, save_main_camera_stream
from annotations import draw_txt
import utils
import image_enc_dec
import tracker2 as tracker

parser = argparse.ArgumentParser()
parser.add_argument("--gst", help="stream with gst", action='store_true')
parser.add_argument("--data_path", help="path for data", default='../../data')
args = parser.parse_args()

subs_socks = []
subs_socks.append(
    utils.subscribe([config.topic_comp_vis], config.zmq_pub_comp_vis))
subs_socks.append(
    utils.subscribe([config.topic_button, config.topic_axes, config.topic_hat],
                    config.zmq_pub_joy))
subs_socks.append(utils.subscribe([config.topic_imu], config.zmq_pub_imu))
if 1:
    subs_socks.append(
        utils.subscribe([config.topic_main_telem], config.zmq_pub_main))
else:
    subs_socks.append(
        utils.subscribe([config.topic_main_telem, config.topic_mav_telem],
                        config.zmq_pub_main))

#socket_pub = utils.publisher(config.zmq_local_route)
socket_pub = utils.publisher(config.zmq_local_route, '0.0.0.0')
예제 #8
0
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-s",
                        "--send_start",
                        help="sends 02 01 03",
                        action='store_true')
    parser.add_argument("-u",
                        "--usbdevice",
                        help="sets usbdevice default /dev/ttyUSB1",
                        default='/dev/ttyUSB1')
    args = parser.parse_args()

socket_pub = utils.publisher(config.zmq_pub_imu)

zmq_sub_joy = utils.subscribe([config.topic_button], config.zmq_pub_joy)

zmq_sub_v3d = utils.subscribe([config.topic_comp_vis_cmd],
                              config.zmq_pub_comp_vis)

lmap = lambda func, *iterable: list(map(func, *iterable))


def reader():
    laser1_status = False

    ser = serial.Serial(args.usbdevice, 460800)
    ser.flush()
    while ser.inWaiting():
        ser.read()  #flushing
예제 #9
0
def get_disk_usage():
    return os.popen("df -h / |tail -1 | gawk '{print $5}'").read()


save = 0
if args.save:
    #if not os.path.isdir(args.data_path):
    if not os.path.isdir('../data'):
        os.mkdir('../data')

topicl = config.topic_unreal_drone_rgb_camera % 0 + b'l'
topicr = config.topic_unreal_drone_rgb_camera % 0 + b'r'

subs_socks = []
subs_socks.append(
    utils.subscribe([topicl, topicr], config.zmq_pub_unreal_proxy))
subs_socks.append(
    utils.subscribe([config.topic_button, config.topic_axes],
                    config.zmq_pub_joy))
subs_socks.append(utils.subscribe([config.topic_imu], config.zmq_pub_imu))
subs_socks.append(
    utils.subscribe([config.topic_main_telem, config.topic_mav_telem],
                    config.zmq_pub_main))

socket_pub = utils.publisher(config.zmq_pub_comp_vis)

image_fmt = 'ppm'

print('start...')
start = time.time()
예제 #10
0
import pickle
import time, os, sys
import argparse
import numpy as np
from algs import pid
import utils

parser = argparse.ArgumentParser()
parser.add_argument("--sim", help="run in simulation", action='store_true')
args = parser.parse_args()

topic_postition = config.topic_sitl_position_report

subs_socks = []
subs_socks.append(
    utils.subscribe([config.topic_button, config.topic_axes, config.topic_hat],
                    config.zmq_pub_joy))
subs_socks.append(
    utils.subscribe([config.topic_comp_vis], config.zmq_pub_comp_vis))
subs_socks.append(
    utils.subscribe([config.topic_command], config.zmq_pub_command))
subs_socks.append(utils.subscribe([config.topic_imu], config.zmq_pub_imu))

if args.sim:
    #due to bug in SITL take data directly from fdm_pub_underwater.py in dronesimlab
    sitl_bypass_topic = b'position_rep'
    if 1:
        subs_socks.append(utils.subscribe([sitl_bypass_topic], 5566))
        print('************  bypass sitl yaw!')
    bypass_yaw = None

socket_pub = utils.publisher(config.zmq_pub_main)