Example #1
0
File: aa.py Project: Akin-Net/aa
def enviar():
    """Sends data to the server"""
    fim = False
    home = os.getenv("HOME")
    f = open(home+"/.aa.txt", "r")
    alertas = f.read().splitlines()
    f.close()
    # FIXME cuidar de possíveis problemas de concorrência
    f = open(home+"/.aa.txt", "w")
    f.close()
    for alerta in alertas:
        # prepare the string
        alerta = alerta.split(',')
        msg = {'user': aaconfig.get_config(['user','nickname']), 'log': alerta[0]+'::'+alerta[1]}
        dados = urllib.parse.urlencode(msg)
        # sends the string
        print("Sending:",alerta[1])
        req = urllib.request.Request('http://nightsc.com.br/aa/novo_log.php',
                                     dados.encode('ascii'))
        res = urllib.request.urlopen(req)
        #pagina = res.read()
        res.close()
        # prepare the flag that will stop the daemon
        if alerta[1] == 'stop':
            fim = True
    return fim
Example #2
0
def enviar():
    """Sends data to the server"""
    fim = False
    home = os.getenv("HOME")
    f = open(home + "/.aa.txt", "r")
    alertas = f.read().splitlines()
    f.close()
    # FIXME cuidar de possíveis problemas de concorrência
    f = open(home + "/.aa.txt", "w")
    f.close()
    for alerta in alertas:
        # prepare the string
        alerta = alerta.split(',')
        msg = {
            'user': aaconfig.get_config(['user', 'nickname']),
            'log': alerta[0] + '::' + alerta[1]
        }
        dados = urllib.parse.urlencode(msg)
        # sends the string
        print("Sending:", alerta[1])
        req = urllib.request.Request('http://nightsc.com.br/aa/novo_log.php',
                                     dados.encode('ascii'))
        res = urllib.request.urlopen(req)
        #pagina = res.read()
        res.close()
        # prepare the flag that will stop the daemon
        if alerta[1] == 'stop':
            fim = True
    return fim
Example #3
0
File: aa.py Project: Akin-Net/aa
def daemonificar():
    """Runs the daemon"""
    global Sent, Envi
    Sent = Sentinela(int(aaconfig.get_config(['user','interval'])))
    Sent.iniciar()
    Envi = Enviador(0.25)
    Envi.iniciar()
Example #4
0
def daemonificar():
    """Runs the daemon"""
    global Sent, Envi
    Sent = Sentinela(int(aaconfig.get_config(['user', 'interval'])))
    Sent.iniciar()
    Envi = Enviador(0.25)
    Envi.iniciar()