예제 #1
0
파일: main.py 프로젝트: jwalke17/uavclass
 def __init__(self):
     self.port = 1234
     self.addr = 'localhost'
     self.id = "default_groundstation"
     self.drone = {"ardupath": "/home/jwalke17/git/ardupilot", "vehicle_type": "VRTL", "vehicle_id": "ND-1","home": [41.697947, -86.233919], "ip": None}
     self.connection = None
     self.controlstation = None
     self.from_dronology = messages.Messages()
     self.to_dronology = messages.Messages()
예제 #2
0
    def __init__(self, messagesFile="./rp/messages.en-gb.xml"):

        self.parser = parsing.Parser()
        self.messages = messages.Messages(messagesFile)

        self.integerAllowedCharacters = "0123456789+- "
        self.nonNegativeIntegerAllowedCharacters = "0123456789+ "
        self.decimalAllowedCharacters = "0123456789.+- "
예제 #3
0
    def __init__(self):

        self.dialog_postar = ui_dialog_postar.Ui_Dialog()
        self.DialogPostar = QtWidgets.QDialog()
        self.dialog_postar.setupUi(self.DialogPostar)
        self.DialogPostar.setModal(True)
        self.service_posting = NotaPaulista_Posting()

        self.dialog_postar.btn_iniciar_postagem.clicked.connect(
            self.inicia_postagem)
        self.dialog_postar.btn_fechar.clicked.connect(self.DialogPostar.reject)

        self.messages = messages.Messages()
예제 #4
0
    def __init__(self, world, level=1):
        pygame.mixer.music.stop()
        scene.Scene.__init__(self, world)
        self.sprites = group.Group()
        self.messages = messages.Messages(self.sprites)
        self.map = map.Map(self, self.sprites, self.messages, world.audio,
                           level)
        self._draw_background_and_map()
        self.change_state(PlayingGameState(self))
        self.level = level

        #self._create_a_pipe()
        self._create_mouse_pointer()
        self.sprites.sort_by_z()
예제 #5
0
    def __init__(self):

        self.dialog_login = ui_login.Ui_Dialog()

        self.DialogLogin = QtWidgets.QDialog()
        self.dialog_login = ui_login.Ui_Dialog()
        self.dialog_login.setupUi(self.DialogLogin)
        self.DialogLogin.setModal(True)

        self.dialog_login.btn_login.clicked.connect(self.executa_login)
        self.dialog_login.btn_cancel.clicked.connect(self.DialogLogin.reject)

        self.limpa_info_login()

        self.messages = messages.Messages()
예제 #6
0
def salva_chave_banco(new_nota):
    conn = sqlite3.connect('notas.db')
    cursor = conn.cursor()
    cursor.execute(constant.QUERY_SAVE,  
                    (new_nota.chave, 
                     new_nota.cnpj, 
                     new_nota.data, 
                     new_nota.uf, 
                     new_nota.numero, 
                     new_nota.codigo, 
                     new_nota.modelo, 
                     new_nota.serie, 
                     new_nota.tipo_emissao, 
                     constant.DEFAULT_STATUS, 
                     messages.Messages().aguardando_postagem) )
    conn.commit()
    conn.close()
예제 #7
0
async def test_receive(caplog):
    """ Test PubNub receive """
    caplog.set_level(logging.DEBUG)
    msg_con = messages.Messages(os.environ['SUBKEY'], os.environ['PUBKEY'],
                                os.environ['PUBNUBID'])
    # purge message pipe
    while msg_con.is_message():
        await msg_con.get_message()

    await send({"content": "Hello my friend :)!"})
    msg = await msg_con.get_message()  # wait until message is received
    assert msg == "Hello my friend :)!", f"Received {msg}"

    await send({"content": '{"dummy": "data"}'})
    msg = await msg_con.get_message()  # wait until message is received
    assert msg == '{"dummy": "data"}', f"Received {msg}"

    await msg_con.stop()
예제 #8
0
def update_record():
    """POST method to get market information with specific parameters."""
    logger.info('************************************')
    logger.info('POST called - ' + request.url_rule.rule)
    cnst = const.Parametros()  # Const object creation
    msg = msgs.Messages()  # Object creation.

    records = json.loads(request.data)  # Get data from post
    check = all([x in records.keys() for x in cnst.POST_KEYS
                 ])  # Check if expected parmeters are passed

    if check:
        logger.info("All parameters are OK.")
        key = fc.getKey(records)  # Get new key
        logger.info("Saving user ...\n")
        cnst.saveParameters(records, key)  # Save info in database/file
        return msg.POSTReturnSuccess(key)  # Return success message
    return msg.POSTReturnError(cnst.POST_KEYS)  # Else return error message
예제 #9
0
 def __init__(self, parent):
     self.board = board.create_new_board()
     self.all_gems = self.get_all_gems()
     self.surface = parent
     self.bg = pygame.image.load("assets/bg.png").convert()
     self.level_hint = 3
     self.level = 0
     self.player = rpg.Player()
     self.enemies = self.new_level()
     self.spawn_enemy()
     self.msg = messages.Messages(self.surface)
     self.enemy_killed_msg = ""
     self.enemy_killed_cooldown = 0
     self.level_start = True
     self.level_up = False
     self.level_up_cooldwon = 30 * 3
     self.start = 30 * 2
     self.pause = False
     self.display_hint = False
예제 #10
0
def get_info():
    """GET method to get market information with specific parameters."""
    logger.info('************************************')
    logger.info('GET called - ' + request.url_rule.rule)
    cnst = const.Parametros()  # Object creation.
    msg = msgs.Messages()  # Object creation.

    dct = request.args.to_dict()  # Get arguments

    if cnst.checkParameters(
            dct):  # Check if arguments are the same as the expected ones
        if cnst.checkKey(dct['apikey']):
            logger.info("All parameters are OK.")
            URL = cnst.createURL(dct)  # URL generation to get info required
            res = requests.get(URL)  # Get information from URL
            result = fc.getNumberOfRowsToShow(
                res, request.args
            )  # Get number of rows if exist, else show everything
            return jsonify(result)  # Return information
        return msg.GETReturnErrorInKey()
    return msg.GETReturnError(cnst.GET_KEYS)
예제 #11
0
    def __init__(self, my_ip, ip_ver, interface_idx, main_logger):  
        """PeerUDPConnection initial function.

        Args:
            my_ip: String value of IP address.
            ip_ver: Integer value of IP version (4 or 6).
            interface_idx: Integer value of interface index.
        """
        self.IP_VER = ip_ver
        self.MY_IP = my_ip
        self.HOST = ''
        self.MULTICAST = 'ff02::1:6' # 'ff02::1' # 
        self.BROADCAST = '192.168.2.255'
        self.LOCALHOST_IPV6 = '::1'
        self.LOCALHOST_IPV4 = '127.0.0.1'
        self.PORT_IPV6 = 6696
        self.PORT_IPV4 = 6696 
        self.BUFFER_SIZE = 2048
        self.TTL = 16
        self.INTERFACE_INDEX = interface_idx
        self.main_logger = main_logger
        

        if self.IP_VER == 4: 
            self.ADDR = (self.HOST, self.PORT_IPV4)  
            self.BROADCAST_ADDR = (self.BROADCAST, self.PORT_IPV4) 
            self.LOCALHOST = self.LOCALHOST_IPV4
            self.PORT = self.PORT_IPV4
        elif self.IP_VER == 6:
            self.ADDR = (self.HOST, self.PORT_IPV6,0,self.INTERFACE_INDEX)  
            self.MULTICAST_ADDR = (self.MULTICAST, self.PORT_IPV6,0,self.INTERFACE_INDEX) 
            self.LOCALHOST = self.LOCALHOST_IPV6
            self.PORT = self.PORT_IPV6

        self.my_selector = selectors.DefaultSelector()
        self.msg = messages.Messages(self.main_logger)
        # record in output_queue = msg
        self.output_queue = []
        # record in input_queue = msg
        self.input_queue = []
예제 #12
0
async def test_send(pubnub_bot, caplog):
    """ Test PubNub send """

    caplog.set_level(logging.DEBUG, logger="sprinkler")

    listener = SubscribeListener()
    pubnub_bot.add_listener(listener)
    pubnub_bot.subscribe().channels('sprinkler').execute()
    listener.wait_for_connect()

    # Empty message queue
    while not listener.message_queue.empty():
        await listener.message_queue.get()

    msg_con = messages.Messages(os.environ['SUBKEY'], os.environ['PUBKEY'],
                                os.environ['PUBNUBID'])
    await msg_con.send("Test send message")

    msg = await listener.message_queue.get()
    await msg_con.stop()

    assert msg.message['content'] == "Test send message"
예제 #13
0
def update_record():
    """POST method to get market information with specific parameters."""
    logger.info('************************************')
    logger.info('POST called - ' + request.url_rule.rule)
    cnst = const.Parametros()  # Const object creation
    msg = msgs.Messages()  # Object creation.

    records = json.loads(request.data)  # Get data from post

    if cnst.checkParameters(
            records, cnst.POST_KEYS
    ):  # Check if arguments are the same as the expected ones
        logger.info("All parameters are OK.")
        if not cnst.existUser(records):  # Check if user already exist
            key = fc.getKey(records, user=False)  # Get new key
            logger.info("Saving user ...\n")
            cnst.saveParameters(records, key)  # Save info in database/file
            return msg.POSTReturnSuccess(key)  # Return success message
        else:
            key = fc.getKey(records, user=True)  # Get existing key for user
            return msg.POSTReturnUserExist(key)  # User already exist
    return msg.POSTReturnError(cnst.POST_KEYS)  # Else return error message
예제 #14
0
파일: client.py 프로젝트: tatkeller/cheetah
    def __init__(self, args):
        QtGui.QMainWindow.__init__(self)
        self.resize(800, 500)
        self.setWindowTitle('Cheetah Manager Client')

        self.init = True

        self.C = configobj.ConfigObj(args.filename)

        self.tabs = QtGui.QTabWidget()

        self.runTable = runTable.RunTableWidget(self.C)
        self.tabs.addTab(self.runTable, "Run Table")

        self.messages = messages.Messages(self.C)
        self.tabs.addTab(self.messages, "Log messages")

        self.setCentralWidget(self.tabs)

        self.client = clientZMQ.Client(self.C)

        self.updateReqTimer = QtCore.QTimer(self)
        self.updateReqTimer.setInterval(5000)
        self.updateRecvTimer = QtCore.QTimer(self)
        self.updateRecvTimer.setInterval(1000)

        # Connect signals
        self.client.newRList.connect(self.runTable.update)
        self.client.newRList.connect(self.messages.update)
        self.runTable.changed.connect(self.client.sendChangeRunRequest)
        self.updateReqTimer.timeout.connect(self.client.sendUpdateRequest)
        self.updateRecvTimer.timeout.connect(self.client.recvUpdate)

        # Initialize list by sending out request for full list
        self.client.sendUpdateRequest("REQ_FULL_LIST")
        # Starting timers
        self.updateReqTimer.start()
        self.updateRecvTimer.start()
예제 #15
0
    def PushTheMessage(self, message):

        # Initialize response
        response = responses.Responses()
        response.setResponse("response", True)

        # Create new message 'm' with all field setted
        m = messages.Messages(message["Username"], message["Sender"],
                              message["ReceiverNumber"], message["Text"],
                              message["IMEI"])

        # Convert 'm' object into JSON
        messageList = m.createJson()

        # Insert the message into database
        database.insertMessageList(messageList)

        # Just for debug
        print m.getSender() + " ha inviato a " + m.getReceiver(
        ) + ": " + m.getText()

        # Return response
        return response
예제 #16
0
def Main():

    outMsg = m.Messages()
    if len(sys.argv) == 2:
        if sys.argv[1] == '-h':
            outMsg.helpMessage()
            sys.exit(0)
        if sys.argv[1] == '-v':
            outMsg.versionMessage()
            sys.exit(0)
        if sys.argv[1] == '-e':
            outMsg.examlpeMessage()
            sys.exit(0)
        else:
            outMsg.errorMessage()
            exit(1)

    if len(sys.argv) == 4:
        if sys.argv[3] == '-u':
            update = updateHandle.UpdateHandle()

            path = sys.argv[1]

            targetFile = sys.argv[2]
            # print("\n Do you wanna safe updating? (y/n)\n")
            # string = str(input())
            # safe= False
            # if string[0] == 'y':
            #     safe= True
            safe = False
            update.updateDir(path, targetFile, safe)

            exit(0)
        else:
            outMsg.errorMessage()
            exit(1)

    if len(sys.argv) > 4:
        validator = av.ArgVal(sys.argv)
        if validator.validArgs() == "error":
            outMsg.errorMessage()  #EDITUJ OVE PORUKE
            exit(1)

        sorArg = validator.getSortedArgs()

        targetFile = sorArg[0]

        targetEncoding = sorArg[1]

        outFile = sorArg[2]

        outEncoding = sorArg[3]

        option = sorArg[4]

        optionArg = sorArg[5]

        if validator.getFileType() is 'property':
            procesor = pf.PFhandle(targetFile, option, optionArg)
            procesor.processFile(outFile, targetEncoding, outEncoding)
        else:
            print("Reg file funcionality coming soon")
            exit(0)
        outMsg.success()
예제 #17
0
파일: api.py 프로젝트: bruno-bert/nfpauto
 def __init__(self):
     self.url = settings.API_URL
     self.url_login = self.url + settings.API_ROUTE_LOGIN
     self.url_register = self.url + settings.API_ROUTE_REGISTER
     self.url_notas = self.url + settings.API_ROUTE_NOTAS
     self.m = messages.Messages()
예제 #18
0
    def __init__(self):
        pygame.init()
        pygame.display.set_caption("Arkanoid_Clone")
        pygame.mixer.init()
        self.surface = pygame.display.set_mode(size=(SCR_WIDTH, SCR_HEIGHT))

        self.bonus_lives = BONUS_LIVES
        self.level = 1
        self.score = 0
        self.lives = 3

        self.powerup_options = [
            "enlarge", "1up", "magnet", "balls", "skip", "laser", "speeddown"
        ]
        self.powerup_falling = []
        self.powerup_active = []
        '''
        stuff to handle block colors, images and relations between blocks
        '''
        block_white = pygame.image.load("assets/block_white.png").convert()
        block_orange = pygame.image.load("assets/block_orange.png").convert()
        block_light_blue = pygame.image.load(
            "assets/block_light_blue.png").convert()
        block_green = pygame.image.load("assets/block_green.png").convert()
        block_red = pygame.image.load("assets/block_red.png").convert()
        block_blue = pygame.image.load("assets/block_blue.png").convert()
        block_pink = pygame.image.load("assets/block_pink.png").convert()
        block_yellow = pygame.image.load("assets/block_yellow.png").convert()
        block_silver = pygame.image.load("assets/block_silver.png").convert()
        block_gold = pygame.image.load("assets/block_gold.png").convert()
        self.show_level = 90
        # colorprefix: (image, hit to be destroyed, score)
        self.block_dict = {
            "w": (block_white, 1, 50),
            "o": (block_orange, 1, 60),
            "c": (block_light_blue, 1, 70),
            "g": (block_green, 1, 80),
            "r": (block_red, 1, 90),
            "b": (block_blue, 1, 100),
            "p": (block_pink, 1, 110),
            "y": (block_yellow, 1, 120),
            "s": (block_silver, 3, 50 * self.level),
            "G": (block_gold, 9999, 0)
        }
        self.on_screen_blocks = []

        self.frame = pygame.image.load("assets/background.png").convert_alpha()
        self.load_bg_img()
        self.messages = messages.Messages(self.surface)

        self.platform = platform.Platform(self.surface)

        self.balls = [ball_class.Ball(self.surface)]

        self.load_map()
        self.block_left = level_map.get_bricks_to_destroy(self.map_blocks)

        self.lasers = []

        self.enemy_spawn_cooldown = 0
        self.list_enemies = []
        self.max_enemies = 3
예제 #19
0
    def __init__(self):

        self.messages = messages.Messages()