コード例 #1
0
    def __init__(self, args=None):
        start_logger(self.project_name)

        self.probes_grid = defaultdict(list)

        args_parser = self.get_args_parser()
        args = self.args = args_parser.parse_args(args)

        logger.info('Target: %s', args.target)

        if args.filename is None:
            args.filename = '%s_%s' % (args.target, self.project_name)

        probes_features = dict()
        if args.country is not None:
            probes_features['country_code'] = args.country

        self.pings = PingMeasure(args.target,
                                 args.key,
                                 protocol=args.protocol,
                                 probes_features=probes_features,
                                 measurements_list=args.msms,
                                 probe_number=args.probe_number,
                                 timeout=args.timeout)
        self.pings.run()
コード例 #2
0
def run_test(args, expected_results, test_name):
    """
    Using the input arguments (args) run the test and compare
    agains expected results (expected_results)
    :param  args               Simulated command line arguments
    :param  expected_results   Expected output results
    :param  test_name          Name of this test
    """
    app_name = __file__.split('.')[0]
    test_logger = util.start_logger(app_name, test_name)

    reader_obj = BookFileReader(test_logger, util.FILE_META_DATA, args)

    # Read input files & filter
    books = reader_obj.read_files()

    # 2 books should be returned
    assert len(books) == len(expected_results)

    # we want to check the order along with the contents
    # so, need to iterate over range-len
    for i, _ in enumerate(books):
        book = books[i]
        result = '{0}, {1}, {2}, {3}'.format(book['last_name'],
                                             book['first_name'], book['title'],
                                             book['publication_date'])

        assert result == expected_results[i]
コード例 #3
0
def do_ip_test(args=None):
    start_logger(project_name)

    failed_countries_size = 10
    failed_countries = False

    args_parser = get_args_parser()
    args = args_parser.parse_args(args)

    logger.info('Target: %s', args.target)

    if args.filename is None:
        args.filename = 'failed_traces_to_%s' % args.target

    probes_features = dict()
    if args.country is not None:
        probes_features['country_code'] = args.country

    pings = PingMeasure(args.target,
                        args.key,
                        protocol=args.protocol,
                        probes_features=probes_features,
                        probe_number=args.probe_number,
                        timeout=args.timeout)
    pings.run()

    log_pings(pings, failed_countries, failed_countries_size)

    if len(pings.probes_data) > 9000 or len(pings.failed_probes) > 1000:
        time.sleep(420)

    probes_data = {
        probe_id: pings.probes_data[probe_id]
        for probe_id in pings.failed_probes
    }

    logger.info('Tracing target with ping-failed probes')

    traces = TraceMeasure(args.target,
                          args.key,
                          protocol=args.protocol,
                          probes_data=probes_data,
                          timeout=args.timeout)
    traces.run()

    log_traces(traces, pings.failed_probes, args.filename)
コード例 #4
0
ファイル: client.py プロジェクト: rcoh/Rally
 def __init__(self, server, port):
   start_logger('client') 
   self.user_name = raw_input('user name?')
   self.client = ReliableChatClient(self.user_name, (server, port))
   self.ui = RallyCursesUI()
   #bind methods:
   self.ui.new_outgoing_message = self.new_outgoing_message 
   self.client.data_changed = self.ui.render_chats
   self.client.new_content_message = self.ui.new_content_message
   #start-er-up:
   try:
     self.client.start()
     self.ui.start()
   except KeyboardInterrupt:
     pass
   finally:
     self.ui.close()
     print 'closed'
コード例 #5
0
def main():
    """
    Main entry point
    """
    # Start logger
    app_name = __file__.split('.')[0]
    module_logger = util.start_logger(app_name, 'controller')

    # Get command line args
    cmd_line_args = cmd_line_parse()

    # Move command line args to dictionary so other methods don't need to import argparse
    args = {
        'filter': cmd_line_args.filter,
        'year_sort': cmd_line_args.year_sort,
        'reverse_sort': cmd_line_args.reverse_sort
    }

    # Log command line args
    for key, value in args.items():
        msg = '{0} : {1}'.format(key, value)
        module_logger.info(msg)

    # Create book file reader object
    reader_obj = BookFileReader(module_logger, util.FILE_META_DATA, args)

    # Read input files & filter
    books = reader_obj.read_files()

    # display results to log file
    msg = ' '.join(sys.argv)
    module_logger.info(msg)
    print(msg)

    for book in books:
        msg = '{0}, {1}, {2}, {3}'.format(book['last_name'],
                                          book['first_name'], book['title'],
                                          book['publication_date'])
        module_logger.info(msg)
        print(msg)

    module_logger.info('<<<<< Done >>>>>')