Пример #1
0
 def test_parse_manifest_invalid(self):
     invalids = [
         # Repeated name
         (b'ccccc/__init__.py \n' + b'ccccc/ddddd/__init__.py \n' +
          b'ccccc/__init__.py \n'),
         # Too many spaces
         b'ccccc/__init__.py foo bar\n',
         # Not enough spaces
         b'\n\n',
     ]
     for invalid in invalids:
         with test_utils.temp_file(invalid) as t:
             with self.assertRaises(error.Error):
                 manifest_parser.parse(t.name)
Пример #2
0
 def test_parse_manifest_invalid(self):
     invalids = [
         # Repeated name
         (b'ccccc/__init__.py \n' +
          b'ccccc/ddddd/__init__.py \n' +
          b'ccccc/__init__.py \n'),
         # Too many spaces
         b'ccccc/__init__.py foo bar\n',
         # Not enough spaces
         b'\n\n',
     ]
     for invalid in invalids:
         with test_utils.temp_file(invalid) as t:
             with self.assertRaises(error.Error):
                 manifest_parser.parse(t.name)
Пример #3
0
    def create(self):
        """Create a .par file on disk

        Raises:
            Error, IOError, SystemError
        """
        logging.info('Compiling under python %s...', sys.version)
        logging.info('Making parfile [%s]...', self.output_filename)
        remove_if_present(self.output_filename)

        # Assemble list of files to include
        logging.debug('Compiling file list from [%s]', self.manifest_filename)
        manifest = manifest_parser.parse(self.manifest_filename)

        # Validate manifest and add various extra files to the list
        stored_resources = self.scan_manifest(manifest)

        # Create parfile in temporary file
        temp_parfile = self.create_temp_parfile()
        try:
            logging.debug('Writing parfile to temp file [%s]...',
                          temp_parfile.name)
            self.write_bootstrap(temp_parfile)
            self.write_zip_data(temp_parfile, stored_resources)
            temp_parfile.close()
            # Flushed and closed tempfile, may now rename it safely
            self.create_final_from_temp(temp_parfile.name)
        finally:
            remove_if_present(temp_parfile.name)
        logging.info('Success!')
Пример #4
0
    def create(self):
        """Create a .par file on disk

        Raises:
            Error, IOError, SystemError
        """
        logging.info('Compiling under python %s...', sys.version)
        logging.info('Making parfile [%s]...', self.output_filename)
        remove_if_present(self.output_filename)

        # Assemble list of files to include
        logging.debug('Compiling file list from [%s]', self.manifest_filename)
        manifest = manifest_parser.parse(self.manifest_filename)

        # Validate manifest and add various extra files to the list
        stored_resources = self.scan_manifest(manifest)

        # Create parfile in temporary file
        temp_parfile = self.create_temp_parfile()
        try:
            logging.debug('Writing parfile to temp file [%s]...',
                          temp_parfile.name)
            self.write_bootstrap(temp_parfile)
            self.write_zip_data(temp_parfile, stored_resources)
            temp_parfile.close()
            # Flushed and closed tempfile, may now rename it safely
            self.create_final_from_temp(temp_parfile.name)
        finally:
            remove_if_present(temp_parfile.name)
        logging.info('Success!')
Пример #5
0
 def test_parse_manifest_valid(self):
     valid = (
         # 1 field, no trailing space
         b'ccccc/__init__.py\n' +
         # 1 field, trailing space
         b'ccccc/ddddd/__init__.py \n' +
         # 2 fields
         b'ccccc/ddddd/eeeee /code/rrrrr/ccccc/ddddd/eeeee\n')
     expected = {
         'ccccc/__init__.py': None,
         'ccccc/ddddd/__init__.py': None,
         'ccccc/ddddd/eeeee': '/code/rrrrr/ccccc/ddddd/eeeee',
     }
     with test_utils.temp_file(valid) as t:
         manifest = manifest_parser.parse(t.name)
         self.assertEqual(manifest, expected)
Пример #6
0
 def test_parse_manifest_valid(self):
     valid = (
         # 1 field, no trailing space
         b'ccccc/__init__.py\n' +
         # 1 field, trailing space
         b'ccccc/ddddd/__init__.py \n' +
         # 2 fields
         b'ccccc/ddddd/eeeee /code/rrrrr/ccccc/ddddd/eeeee\n'
     )
     expected = {
         'ccccc/__init__.py': None,
         'ccccc/ddddd/__init__.py': None,
         'ccccc/ddddd/eeeee': '/code/rrrrr/ccccc/ddddd/eeeee',
     }
     with test_utils.temp_file(valid) as t:
         manifest = manifest_parser.parse(t.name)
         self.assertEqual(manifest, expected)