def test_exe(self):
        #setup
        factory = InstallerFactory()
        factory.with_extension('exe')

        #when
        result = factory.find()

        #then
        assert type(result) is CommandRunner
    def test_homebrew(self):
        #setup
        factory = InstallerFactory()
        factory.with_command('brew')

        #when
        result = factory.find()

        #then
        assert type(result) is HomebrewRunner
    def test_choco(self):
        #setup
        factory = InstallerFactory()
        factory.with_command('choco')

        #when
        result = factory.find()

        #then
        assert type(result) is ChocoRunner
    def test_rar(self):
        #setup
        factory = InstallerFactory()
        factory.with_extension('rar')

        #when
        result = factory.find()

        #then
        assert type(result) is RarExtractor
    def test_7z(self):
        #setup
        factory = InstallerFactory()
        factory.with_extension('7z')

        #when
        result = factory.find()

        #then
        assert type(result) is SevenZipExtractor
Пример #6
0
    def install(self, app_id: str) -> None:
        app: Application = self.repo.load_app(app_id)
        if not app:
            raise Exception("Unable to update app that doesn't exist yet")
        url = app.get_source_url()
        app_name = app.get_name()
        install_dir = self.install_dir + '/' + app_name

        if not os.path.exists(install_dir):
            os.makedirs(install_dir)

        if not app.is_package:
            # find the app extension
            url_path: Union[ParseResultBytes, ParseResult] = urlparse(url)
            ext = self.__discover_extension(url_path)

            executable = self.downloader.download(url, app_name, ext)

            runner = InstallerFactory().with_extension(ext).find()

            if re.match(self.exec_pattern, executable) and runner:
                runner.run(executable, install_dir)
        else:
            runner = InstallerFactory().with_command('').find()
            package_manager = self.app_initializer.package_manager
            runner.run_cmd(package_manager, ["install", app_name])

        app.set_installed(True)
        self.repo.update_app(app)
Пример #7
0
 def __init__(self,
              repo: AppRepository = None,
              downloader: ApplicationDownloader = None,
              app_initializer: ApplicationInitializer = None,
              factory: InstallerFactory = InstallerFactory()):
     self.install_dir: str = './working/installation'
     self.repo: AppRepository = repo
     self.downloader: ApplicationDownloader = downloader
     self.factory: InstallerFactory = factory
     self.exec_pattern: str = r'.+\.exe'
     self.app_initializer: ApplicationInitializer = app_initializer