def job():
    try:
        print 'run job..... %s' % data_path

        #data_path = 'D:/baolingfeng/GitHub/ProgramComprehension/data/user1/log'
        day = time_util.today()
        #day = None

        outputfile = 'stat_' + user_name + '_' + 'all' + '.txt'

        with EventManager(data_path) as em:
            em.retrieve_events(day)
            #em.retrieve_events()
            em.filter_no_need()
            em.aggregate_events_in_rts()
            em.aggregate_events_in_process()
            em.aggregate_events_in_window()
            
            em.stat(outputfile)

        if 'ftp_host' in config_map:
            send_to_ftp(outputfile, '', config_map['ftp_host'], config_map['ftp_user'], config_map['ftp_password'])

    except Exception, e:
        print e
    data_path = '../data/user1/log'
    day = None
    user_name = getpass.getuser()
    try:
        for idx, arg in enumerate(sys.argv):
            if idx == 0:
                continue

            if arg[0] == '-':
                if idx+1>=len(sys.argv):
                    raise Exception('arguement incomplete')

                next_arg = sys.argv[idx+1]
                if arg[1:] == 't':
                    if next_arg == 'today':
                        day = time_util.today()
                    elif next_arg == 'yesterday':
                        day = time_util.day_with_interval(time_util.today(), -1)
                    else:
                        datetime.strptime(next_arg, '%Y-%m-%d')
                        day = next_arg
                elif arg[1:] == 'data':
                    data_path = next_arg
                elif arg[1:] == 'u':
                    user_name = next_arg
                elif arg[1:] == 'h' or arg[1:] == 'help':
                    print '-t: time option, could be "today", "yesterday", or "YYYY-MM-DD"; no this option means all event data\n'
                    print '-data: data path, e.g. D:/username/log\n'
                    print '-u: username\n'

    except Exception, e: