예제 #1
0
파일: detect.py 프로젝트: stg-tud/MUBench
    def _download(self):
        logger = logging.getLogger("detect")
        url = self.detector.jar_url
        logger.info("Loading detector from '%s'...", url)
        file = self.detector.jar_path

        try:
            if not exists(self.detector.md5_path):
                raise FileNotFoundError("Cannot validate download, MD5-checksum file '{}' missing".format(self.detector.md5_path))
            download_file(url, file, self.detector.md5_path)
        except (FileNotFoundError, ValueError, URLError) as e:
            logger.error("Download failed: %s", e)
            exit(1)
예제 #2
0
def exec_util(main: str, args: str = ""):
    base_path = dirname(__file__)
    utils_jar_path = join(base_path, UTILS_JAR_NAME)

    if exists(utils_jar_path) and not is_valid_file(utils_jar_path, UTILS_MD5):
        remove(utils_jar_path)

    if not exists(utils_jar_path):
        try:
            download_file(UTILS_JAR_URL, utils_jar_path, UTILS_MD5)
        except (URLError, ValueError, FileNotFoundError) as e:
            raise ValueError("utils unavailable: {}".format(e))

    return Shell.exec('java -cp "{}" de.tu_darmstadt.stg.mubench.utils.{} {}'.format(utils_jar_path, main, args))
예제 #3
0
 def create(self) -> None:
     makedirs(self.checkout_dir, exist_ok=True)
     bundle_file = join(self.checkout_dir, "bundle.zip")
     download_file(self.url, bundle_file, self.md5_checksum)
     with ZipFile(bundle_file) as zip_file:
         zip_file.extractall(self.checkout_dir)
예제 #4
0
    def test_invalidates_download(self):
        with assert_raises(ValueError):
            download_file(self.url, self.target, ":wrong-md5:")

        assert not exists(self.target)
예제 #5
0
    def test_validates_download(self):
        download_file(self.url, self.target, EMPTY_FILE_MD5)

        assert exists(self.target)
예제 #6
0
 def test_raises_on_unavailable(self):
     with assert_raises(URLError):
         download_file("http://unavailable.sven-amann.de/file", self.target)
예제 #7
0
 def test_raises_on_invalid_url(self):
     with assert_raises(ValueError):
         download_file(":invalid-url:", self.target)
예제 #8
0
    def test_downloads_file(self):
        download_file(self.url, self.target)

        assert exists(self.target)