Exemplo n.º 1
0
def run():
    start_time = get_start_time()

    n_people_to_compare_with, max_len_closest_matches, image_name, person_count, image_path = get_user_inputs(
    )

    file_count = get_number_of_pics_to_compare_with(n_people_to_compare_with,
                                                    lfw_path, person_count,
                                                    image_name)

    original_image_encodings = get_image_encodings(image_path)

    closest_matches_sorted = compare_with_other_images(
        lfw_path, file_count, original_image_encodings, image_name,
        max_len_closest_matches, start_time, n_people_to_compare_with)

    print_results(closest_matches_sorted, image_path)

    output_results_csv(closest_matches_sorted, start_time, image_name,
                       max_len_closest_matches, file_count,
                       n_people_to_compare_with)

    output_results_image(closest_matches_sorted, start_time, image_name,
                         max_len_closest_matches, file_count,
                         n_people_to_compare_with)
Exemplo n.º 2
0
def srt2ss(path, is_ass=True):

    timer = utils.Timer()
    timer.start()

    subs = utils.load_sub_file(path)

    start_time = utils.get_start_time(subs, 'ass')
    end_time = utils.get_end_time(subs, 'ass')
    plaintext = utils.get_plaintext(subs)

    sub_block = []
    LAYER = 0
    STYLE = 'Default'
    NAME = ''
    MARGINL = 0
    MARGINV = 0
    EFFECT = ''
    for i in range(len(subs)):
        sub_block.append('Dialogue: %d, %s, %s, %s, %s, %d, %d, %s, %s' %
                         (LAYER, start_time[i], end_time[i], STYLE, NAME,
                          MARGINL, MARGINV, EFFECT, plaintext[i]))
    utils.write_txt('%s.ass' % (output_filename), script_info())
    utils.write_lines('%s.ass' % (output_filename), sub_block, mode='a')

    timer.stop()

    print('转换完成,用时%.2f秒' % (timer.elapsed))
Exemplo n.º 3
0
def main():
    while True:
        faceCon, faceCur = connectDB(db_key)
        bigDataCon, bigDataCur = connectDB(big_data_key)
        lastTime = get_start_time(time_type_key)
        print('lastTime: ', lastTime)
        if not lastTime:
            return

        # 获取最新的更新时间
        now = datetime.now()
        now_time = now.strftime("%Y-%m-%d %H:%M:%S")
        try:
            getFaceInfo(lastTime, faceCon, faceCur, bigDataCon, bigDataCur)
            set_start_time(time_type_key, now_time)
        except Exception as e:
            print(e)
            bigDataCon.rollback()
        else:
            pass
        finally:
            pass

        faceCon.close()
        bigDataCon.close()
        print("begin to sleep 10 seconds")
        print("-----------------------------")
        time.sleep(10)
Exemplo n.º 4
0
def get_AstroRestarts(house_id):
    time = get_start_time()

    rs = RestartsSerializer(Restart.objects.filter(house_id=house_id, restart_time__gt=time).order_by('-restart_time'),
                            many=True)

    return rs.data
Exemplo n.º 5
0
def run(no_journeys, map_configs):

    overall_start_time, runstr = get_start_time()

    logger = configure_logger(runstr)

    journey_files, no_journeys, attempting_all = get_journey_files(no_journeys)

    base_layers = read_in_convert_base_maps(map_configs)

    clear_out_old_folders_and_make_new(map_configs)

    maps_dict = plot_base_map_layers(base_layers, map_configs)

    (
        start_time,
        journey_plots,
        counters,
        text_vars,
    ) = set_up_plot_lists_and_counters(journey_files)

    timestr, timestr_moving_recents, text_vars = make_first_frames(
        counters, journey_files, text_vars, maps_dict, map_configs)

    counters = make_all_other_frames(
        journey_files,
        attempting_all,
        no_journeys,
        start_time,
        maps_dict,
        runstr,
        text_vars,
        timestr,
        journey_plots,
        counters,
        map_configs,
    )

    make_final_by_year_image(runstr, counters, maps_dict, map_configs)

    additional_frames_journeys_fading_out(journey_files, maps_dict,
                                          journey_plots, counters, map_configs)

    make_all_videos(runstr, counters, map_configs)

    clear_out_images_for_video_folder(map_configs)

    overall_finish_time = datetime.datetime.now()

    overall_run_notes(
        runstr,
        attempting_all,
        no_journeys,
        overall_start_time,
        overall_finish_time,
        counters,
        map_configs,
    )
Exemplo n.º 6
0
 def get(self, request, house_id):
     time = get_start_time()
     restarts = get_AstroRestarts(house_id)
     aviator_disconnections = []
     # AviatorDisconnection.objects.filter(house_id=house_id, time_from__gt=time)
     return render(request, template_name='HouseHealth/restarts.html',
                   context={'restarts': restarts,
                            'house_id': house_id,
                            'aviator_disconnections': aviator_disconnections})
Exemplo n.º 7
0
    def reset(self, path):
        utils.reset(path)
        utils.set_stack(self.quantity)
        utils.set_timer(self.timer)

        self.infos = dict()
        start_time = utils.get_start_time()
        assert start_time != -1
        self.infos["start_time"] = start_time

        for _, agent in self.agents.items():
            agent.update_eps()
Exemplo n.º 8
0
def check_restart_alert(rs):
    try:
        time = get_start_time()
        rscount = Restart.objects.filter(astro_id=rs['astro_id'],
                                         restart_time__gt=time).count()
        if rscount >= RESTART_ALERT_THRESHOLD:
            return str(rs["astro_id"]) + " restarted " + str(
                rscount) + " times in the past " + getConfigValue(
                    DATA_DISPLAY_RANGE
                ) + " hours from the time of this alert.\n"
        return ""
    except Exception as e:
        logger.error("Exception in checking restart alert" + str(e))
        raise e
Exemplo n.º 9
0
def ss2srt(path, chinese_only=False, english_only=False, Tchinese_only=False):

    timer = utils.Timer()
    timer.start()

    subs = utils.load_sub_file(path)

    start_time = utils.get_start_time(subs, 'srt')
    end_time = utils.get_end_time(subs, 'srt')
    plaintext = utils.get_plaintext(subs)
    format_sub = []

    if chinese_only == True:
        pass
    elif english_only == True:
        pass
    elif Tchinese_only == True:
        pass
    else:
        # 简体&英文双语
        for i in range(len(subs)):
            format_sub.append('%s\n' % (i + 1))
            if start_time[i] == start_time[i -
                                           1] and end_time[i] == end_time[i -
                                                                          1]:
                format_sub.append('%s --> %s\n' % (start_time[i], end_time[i]))
                format_sub.append('%s' % (plaintext[i - 1]))
                format_sub.append('%s\n' % (plaintext[i]))
            elif start_time[i] == start_time[i +
                                             1] and end_time[i] == end_time[i +
                                                                            1]:
                format_sub.remove(format_sub[-1])
                pass
            else:
                format_sub.append('%s --> %s\n' % (start_time[i], end_time[i]))
                format_sub.append('%s\n' % (plaintext[i]))

    utils.write_lines('%s.srt' % ("test"), format_sub)

    timer.stop()

    print('转换完成,用时%.2f秒' % (timer.elapsed))
Exemplo n.º 10
0
def main():
    while True:
        carCon, carCur = connectDB(db_key)
        bigDataCon, bigDataCur = connectDB(big_data_key)
        lastTime = get_start_time(time_type_key)
        print('lastTime: ', lastTime)
        if not lastTime:
            return

        # 获取最新的更新时间
        now = datetime.now()
        now_time = now.strftime("%Y-%m-%d %H:%M:%S")

        getTaxiInfo(lastTime, carCon, carCur, bigDataCon, bigDataCur)
        set_start_time(time_type_key, now_time)

        carCon.close()
        bigDataCon.close()
        print("begin to sleep 10 seconds")
        print("-----------------------------")
        time.sleep(10)
Exemplo n.º 11
0
def handle_UpdateHouse():
    """
    Updates the status as well as Counts of all attributes(restarts, long cutoff, quick interrupt) for a House.
    :return:
    """
    try:
        houses = get_house_statuses_from_drona()
        blacklisted = BLACKLISTED
        time = get_start_time()
        for house in houses:
            if house['display_id'] in blacklisted:
                continue
            try:
                h = House.objects.get(house_id=house['display_id'])
            except:
                h = House.objects.create(house_id=house['display_id'])

            if (not house['master_status']) and h.status == 'ACTIVE':
                h.status = 'ERRORED' + " " + datetime.datetime.now(pytz.timezone('Asia/Calcutta')).strftime(
                    "%Y-%m-%d %H:%M:%S")
            if house['master_status']:
                h.status = 'ACTIVE'

            h.house_name = house['name']
            h.restart_count = Restart.objects.filter(house_id=house['display_id'], restart_time__gt=time).count()
            # qis = QuickInterruptSerializer(QuickInterrupt.objects.filter(house_id=key), many=True,
            #                                context={'time_constrain': time})
            # c = 0
            # for q in qis.data:
            #     c += len(q['interrupts'])
            h.qi_count = QuickInterrupt.objects.filter(house_id=house['display_id'], time__gt=time).count()
            h.ld_count = LongDisconnect.objects.filter(house_id=house['display_id'], status="INACTIVE").count()
            h.save()
        return houses
    except Exception as e:
        logger.error("Exception in updating house information from local db. Exception" + str(e))
        raise e
Exemplo n.º 12
0
def get_Quick_Interrupts(house_id):
    time = get_start_time()
    qis = QuickInterruptSerializer(QuickInterrupt.objects.filter(house_id=house_id, time__gt=time).order_by('-time'),
                                   many=True)
    return qis.data
Exemplo n.º 13
0
# scraping.run_repeating(scrape_all_results,
#                        interval=86400,
#                        first=datetime.time(23, 00, 00))

# Get rid of outdated matches too late to play

# def outdated_matches(update, context):
#     outdated_matches = cfg.UPDATER.job_queue
#     outdated_matches.run_repeating(get_rid_outdated_matches,
#                                interval=86400,
#                                first=datetime.time(22, 30, 00))

# Update database
cfg.JOB_QUEUE.run_repeating(jobs.job_update_score,
                            interval=86400,
                            first=utl.get_start_time(hh=18, mm=57, ss=0))

# # Scrape quotes
cfg.JOB_QUEUE.run_repeating(jobs.job_night_quotes,
                            interval=86400,
                            first=utl.get_start_time(hh=18, mm=37, ss=30))

cfg.DISPATCHER.add_handler(start_handler)
# cfg.DISPATCHER.add_handler(info_handler)
cfg.DISPATCHER.add_handler(get_handler)
cfg.DISPATCHER.add_handler(confirm_handler)
cfg.DISPATCHER.add_handler(cancel_handler)
cfg.DISPATCHER.add_handler(delete_handler)
cfg.DISPATCHER.add_handler(play_handler)
cfg.DISPATCHER.add_handler(update_handler)
cfg.DISPATCHER.add_handler(summary_handler)
Exemplo n.º 14
0
def main(npixels):
    """Main function."""
    # Name of the application to run, and a settings file for it.
    app = 'oskar_sim_beam_pattern'
    settings_path = '_temp_settings.ini'

    # Define some basic observation parameters.
    ra0_deg = 0.0
    dec0_deg = -27.0
    length_sec = 1.0

    # Define base settings dictionary.
    common_settings = {
        'observation': {
            'phase_centre_ra_deg': ra0_deg,
            'phase_centre_dec_deg': dec0_deg,
            #'pointing_file': 'station_pointing.txt',
            'start_time_utc': get_start_time(ra0_deg, length_sec, '2000-01-01 00:00:00'),
            'length': length_sec
        },
        'telescope': {
            'normalise_beams_at_phase_centre': False,
            'aperture_array/element_pattern/normalise': False
        },
        'beam_pattern': {
            'coordinate_frame': 'Horizon',
            'beam_image/size': npixels,
            'station_outputs/fits_image/amp': True,
            'station_outputs/fits_image/phase': True,
            'station_outputs/fits_image/auto_power_real': False
        }
    }

    # Define frequencies of interest (in MHz).
    freqs = [50]
    #freqs = [70]

    # Define telescope models to use, and associated overrides for them.
    telescopes = {
        'basefunctions': {
            'telescope/input_directory': 'telescope.tm',
            'telescope/aperture_array/element_pattern/enable_numerical': True,
            'telescope/aperture_array/element_pattern/swap_xy': False,
            'telescope/aperture_array/array_pattern/enable': False
        },
    }

    # Loop over telescope models.
    for tel, tel_params in telescopes.items():

        # Copy the base settings dictionary.
        current_settings = copy.deepcopy(common_settings)

        # Update current settings with telescope model parameters.
        current_settings.update(tel_params)

        # Loop over frequencies.
        for freq in freqs:

            # Create the settings file.
            settings = create_settings(app, settings_path, current_settings)

            # Update output root path and frequency.
            tel_root = re.sub(r'[^\w]', '', tel)  # Strip symbols from tel.
            root_path = tel_root + ('_%03d_MHz' % freq)
            settings['beam_pattern/root_path'] = root_path
            settings['observation/start_frequency_hz'] = 1e6 * freq

            # Run the app with the settings file.
            subprocess.call([app, settings_path])