def separate_range_build_list(dir_of_logs, unbzipped_logs, start_datetime, to_datetime, server_vers):
    # todo - this is a bit big and nasty, but good enough for now
    """Opens current debug.log and un-bz'd logs and builds new list of loglines
       that fall within our reporting period. Returns two lists of strings: one for bandwidth,
       other for eventual parsing of filetypes served, device os/model, and ips devices accessed from."""
    our_range_logline_str_list, bandwidth_lines_list, filetype_lines_list, service_restart_timestamps = [], [], [], []
    try:
        with open(os.path.join(dir_of_logs, 'Debug.log'), 'rU') as current, open(unbzipped_logs, 'rU') as unzipped:
            for f in current, unzipped:
                for line in f:
                    if line[:23] > start_datetime:
                        if line[:23] < to_datetime:
                            our_range_logline_str_list.append(line)
    except __HOLE__ as e:
        print 'Operation failed: %s' % e.strerror
        sys.exit(4)
    # currently just resetting start_time if service was restarted to most current occurance
    # and informing with datetime in report (with the proper format to add --through option)
    more_recent_svc_hup = False
    for logline_str in our_range_logline_str_list:
        if 'Registration succeeded.  Resuming server.' in logline_str:
            service_restart_timestamps.append(logline_str[:23])
            more_recent_svc_hup = True
            new_start_datetime = max(service_restart_timestamps)
    # todo - should probably be less repetition below
    excludes = ['egist', 'public', 'peers', 'Opened', 'EC', 'Bad']
    filetypes = ['ipa', 'epub', 'pkg', 'zip']
    if more_recent_svc_hup:
        for logline_str in our_range_logline_str_list:
            if logline_str[:23] > new_start_datetime:
                if server_vers == 'Five':
                    if 'Served all' in logline_str:
                        bandwidth_lines_list.append(logline_str.split())
                    elif not any(x in logline_str for x in excludes):
                        if any(x in logline_str for x in filetypes):
                            filetype_lines_list.append(logline_str.split())
                else:
                    if 'start:' in logline_str:
                        bandwidth_lines_list.append(logline_str.split())
                    elif not any(x in logline_str for x in excludes):
                        if any(x in logline_str for x in filetypes):
                            filetype_lines_list.append(logline_str.split())
    else:
        new_start_datetime = start_datetime
        for logline_str in our_range_logline_str_list:
            if logline_str[:23] > start_datetime:
                if server_vers == 'Five':
                    if 'Served all' in logline_str:
                        bandwidth_lines_list.append(logline_str.split())
                    elif not any(x in logline_str for x in excludes):
                        if any(x in logline_str for x in filetypes):
                            filetype_lines_list.append(logline_str.split())
                else:
                    if 'start:' in logline_str:
                        bandwidth_lines_list.append(logline_str.split())
                    elif not any(x in logline_str for x in excludes):
                        if any(x in logline_str for x in filetypes):
                            filetype_lines_list.append(logline_str.split())
    return bandwidth_lines_list, filetype_lines_list, more_recent_svc_hup, new_start_datetime
dataset/ETHPy150Open macadmins/sashay/sashay.py/separate_range_build_list