if getConfig().is_processed_for(date, 'squidlogs'):
			del_row_query_for_squidlogs(date)
			getConfig().remove_from_processed_list(date, 'squidlogs')
			print "Deleted rows for " + str(date)
		elif not getConfig().year_not_exists_in_list(year, 'squidlogs'):
			print "\t" + str(date) + " not in processed list for " + db_name


###############
#
#  MAIN
#
###############

args = init_argparser(
	test='Removes only test regs in chosen database',
	database='Especify database name',
	date='Delete regs from database between 2 dates or just one')

test_mode = True if args.test else False
setConfig(test_mode=test_mode)

# nombre de la base de datos en la cual eliminar los registros
db_name = getConfig().db_name_squidlogs if args.database[0] == 'squidlogs' \
			else getConfig().db_name_analysis


from helpers.mysql_helper import exec_mysql

# crea diálogo de confirmación en caso de no ejecutar en modo test
if not test_mode:
	ans = raw_input("WARNING: Not in test mode. Type " + db_name + " to continue..\n")
			del_table_query("saved", year)
			del_table_query("visited", year)
			print "Deleted tables for " + year

	else:
		print str(date) + " not in processed list"


###############
#
#  MAIN
#
###############

args = init_argparser(
	test="Clear test_analysis database regs",
	date='Delete regs from database between 2 dates or just one')


test_mode = True if args.test else False

# crea diálogo de confirmación en caso de no ejecutar en modo test
if not test_mode:
	ans = raw_input("WARNING: Not in test mode. Type 'analysis' to continue..\n")
	if ans != 'analysis':
		print "Exiting without changes.."
		sys.exit(0)


database = "test_analysis" if test_mode else "analysis"
# transfiere a ~/logs del remoto el log generado
def transfer_to_remote(date):
	crear_log(date)

	local = Config().get_dir_test_logs()
	remote = Config().get_dir_test_logs_remote()
	log_name = Config().get_log_filename(date)

	cmd = "scp " + local + log_name + " " + remote

	print "Subiendo " + log_name + " a equipo remoto.."
	exec_proc(cmd)
	print "Log " + log_name + " subido\n"


args = init_argparser(
	date="Sube logs para la/s fecha/s dada/s en el equipo remoto")

do_for_dates(transfer_to_remote, args)


# d = get_now_to_zero()
# d = d.replace(year=2012, month=1, day=30)
# d2 = d.replace(year=2013, month=2, day=1)

# # mientras que la fecha d sea menor o igual a la final (d2)..
# while d <= d2:
# 	crear_log(d)
# 	transfer_to_remote(d)
# 	d += timedelta(1)
示例#4
0
		while d <= d2:
			run_for_day(d)
			d += timedelta(1)


###########################
#
# EJECUCIÓN PRINCIPAL
#
###########################

# obtenemos los argumentos con el uso del parseador..
from helpers.parser_helper import init_argparser
args = init_argparser(
	test='Runs in test mode',
	manual='Manually process a certain volume of logs between 2 dates.\n'
		'e.g. main.py -m 20130101 20130327 -> '
		'This will process all logfiles between 1st Jan 2013 and 27th Mar 2013,'
		' both included.')
test_mode = True if args.test else False
manual_mode = True if args.manual else False

# seteamos la instancia 'config' del módulo de configuración, la cual usaremos
# a lo largo del script para interactuar con la configuración elegida.
from helpers.config_helper import setConfig, getConfig
setConfig(test_mode)

# configuramos un logger para informarnos de la ejecucion en el archivo main-[fecha].log
from helpers.logging_helper import *
init_logger("main")