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
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
def daemonificar(): """Runs the daemon""" global Sent, Envi Sent = Sentinela(int(aaconfig.get_config(['user','interval']))) Sent.iniciar() Envi = Enviador(0.25) Envi.iniciar()
def daemonificar(): """Runs the daemon""" global Sent, Envi Sent = Sentinela(int(aaconfig.get_config(['user', 'interval']))) Sent.iniciar() Envi = Enviador(0.25) Envi.iniciar()