Example #1
0
def run(argv):
    """This function is the core-function using all the other components to
       do the expected work.

       This includes parsing the commandline, reading "config.ini", parsing
       the input-file and actual downloading of all the files.

       Called by ```run.py``` in base-dir.

    """
    # Parse arguments
    arg_parser = CLI()
    input_path, verbose = arg_parser.parse(argv[1:])  # argv[0] = script-name

    # Read config-file
    output_path = read_config()

    # Create and use input-parser
    parser = InputParser(input_path, output_path, verbose)

    # Create downloader
    downloader = Downloader(output_path, verbose)

    # Use downloader
    for url, filename in parser.get_url_targetname_pairs():
        downloader.download(url, filename)
Example #2
0
    def test_valid_verbose_on(self):
        """Test valid input-file with verbose=on.

        """
        arg_parser = CLI()
        parsed_args = arg_parser.parse(['-i', self.input_file.name, '-v'])
        self.assertEqual(parsed_args[0], self.input_file.name)
        self.assertEqual(parsed_args[1], True)
Example #3
0
    def test_valid_minimal(self):
        """Minimal call with valid input-file.

        """
        arg_parser = CLI()
        parsed_args = arg_parser.parse(['-i', self.input_file.name])
        self.assertEqual(parsed_args[0], self.input_file.name)
        self.assertEqual(parsed_args[1], False)
Example #4
0
    def test_invalid_minimal(self):
        """Minimal call with non-existing input-file.

           This "non-existence" in this test is true with high-probability.

           Will raise UtilsFileDoesNotExistError.

        """
        arg_parser = CLI()
        with self.assertRaises(UtilsFileDoesNotExistError):
            parsed_args = arg_parser.parse(['-i', self.input_file.name + '1'])