Exemple #1
0
class UploadRemote(actions.Storage):
    def __init__(self, storage, path, name):
        super(UploadRemote, self).__init__(storage)
        self.url = path
        self.name = name
        if not self.url:
            raise ValueError('Please specify repository URL')
        if not self.name:
            rx = re.compile(r'^.*/(?P<name>.*?)(\..*)?$')
            match = rx.match(self.url)
            self.name = match.group('name')

    @coroutine
    def execute(self):
        repositoryPath = tempfile.mkdtemp()
        manifestPath = os.path.join(repositoryPath, 'manifest-start.json')
        packagePath = os.path.join(repositoryPath, 'package.tar.gz')
        self.repositoryDownloader = GitRepositoryDownloader()
        self.moduleInstaller = PythonModuleInstaller(repositoryPath,
                                                     manifestPath)
        print('Repository path: {0}'.format(repositoryPath))
        try:
            yield self.cloneRepository(repositoryPath)
            yield self.installRepository()
            yield self.createPackage(repositoryPath, packagePath)
            yield Upload(
                self.storage, **{
                    'name': self.name,
                    'manifest': manifestPath,
                    'package': packagePath
                }).execute()
        except (RepositoryDownloadError, ModuleInstallError) as err:
            print(err)

    @coroutine
    def cloneRepository(self, repositoryPath):
        self.repositoryDownloader.download(self.url, repositoryPath)

    @coroutine
    def installRepository(self):
        self.moduleInstaller.install()

    @coroutine
    def createPackage(self, repositoryPath, packagePath):
        tar = tarfile.open(packagePath, mode='w:gz')
        tar.add(repositoryPath, arcname='')
class AppUploadFromRepositoryAction(StorageAction):
    def __init__(self, storage, **config):
        super(AppUploadFromRepositoryAction, self).__init__(storage, **config)
        self.name = config.get('name')
        self.url = config.get('url')
        if not self.url:
            raise ValueError('Please specify repository URL')
        if not self.name:
            rx = re.compile(r'^.*/(?P<name>.*?)(\..*)?$')
            match = rx.match(self.url)
            self.name = match.group('name')

    def execute(self):
        return ChainFactory([self.doWork])

    def doWork(self):
        repositoryPath = tempfile.mkdtemp()
        manifestPath = os.path.join(repositoryPath, 'manifest-start.json')
        packagePath = os.path.join(repositoryPath, 'package.tar.gz')
        self.repositoryDownloader = GitRepositoryDownloader()
        self.moduleInstaller = PythonModuleInstaller(repositoryPath, manifestPath)
        print('Repository path: {0}'.format(repositoryPath))
        try:
            yield self.cloneRepository(repositoryPath)
            yield self.installRepository()
            yield self.createPackage(repositoryPath, packagePath)
            yield AppUploadAction(self.storage, **{
                'name': self.name,
                'manifest': manifestPath,
                'package': packagePath
            }).execute()
        except (RepositoryDownloadError, ModuleInstallError) as err:
            print(err)

    @chain.threaded
    def cloneRepository(self, repositoryPath):
        self.repositoryDownloader.download(self.url, repositoryPath)

    @chain.threaded
    def installRepository(self):
        self.moduleInstaller.install()

    @chain.threaded
    def createPackage(self, repositoryPath, packagePath):
        with tarfile.open(packagePath, mode='w:gz') as tar:
            tar.add(repositoryPath, arcname='')
Exemple #3
0
 def execute(self):
     repositoryPath = tempfile.mkdtemp()
     manifestPath = os.path.join(repositoryPath, 'manifest-start.json')
     packagePath = os.path.join(repositoryPath, 'package.tar.gz')
     self.repositoryDownloader = GitRepositoryDownloader()
     self.moduleInstaller = PythonModuleInstaller(repositoryPath, manifestPath)
     print('Repository path: {0}'.format(repositoryPath))
     try:
         yield self.cloneRepository(repositoryPath)
         yield self.installRepository()
         yield self.createPackage(repositoryPath, packagePath)
         yield Upload(self.storage, **{
             'name': self.name,
             'manifest': manifestPath,
             'package': packagePath
         }).execute()
     except (RepositoryDownloadError, ModuleInstallError) as err:
         print(err)
Exemple #4
0
class UploadRemote(actions.Storage):
    def __init__(self, storage, path, name):
        super(UploadRemote, self).__init__(storage)
        self.url = path
        self.name = name
        if not self.url:
            raise ValueError('Please specify repository URL')
        if not self.name:
            rx = re.compile(r'^.*/(?P<name>.*?)(\..*)?$')
            match = rx.match(self.url)
            self.name = match.group('name')

    @coroutine
    def execute(self):
        repositoryPath = tempfile.mkdtemp()
        manifestPath = os.path.join(repositoryPath, 'manifest-start.json')
        packagePath = os.path.join(repositoryPath, 'package.tar.gz')
        self.repositoryDownloader = GitRepositoryDownloader()
        self.moduleInstaller = PythonModuleInstaller(repositoryPath, manifestPath)
        print('Repository path: {0}'.format(repositoryPath))
        try:
            yield self.cloneRepository(repositoryPath)
            yield self.installRepository()
            yield self.createPackage(repositoryPath, packagePath)
            yield Upload(self.storage, **{
                'name': self.name,
                'manifest': manifestPath,
                'package': packagePath
            }).execute()
        except (RepositoryDownloadError, ModuleInstallError) as err:
            print(err)

    @coroutine
    def cloneRepository(self, repositoryPath):
        self.repositoryDownloader.download(self.url, repositoryPath)

    @coroutine
    def installRepository(self):
        self.moduleInstaller.install()

    @coroutine
    def createPackage(self, repositoryPath, packagePath):
        tar = tarfile.open(packagePath, mode='w:gz')
        tar.add(repositoryPath, arcname='')
Exemple #5
0
 def execute(self):
     repositoryPath = tempfile.mkdtemp()
     manifestPath = os.path.join(repositoryPath, 'manifest-start.json')
     packagePath = os.path.join(repositoryPath, 'package.tar.gz')
     self.repositoryDownloader = GitRepositoryDownloader()
     self.moduleInstaller = PythonModuleInstaller(repositoryPath, manifestPath)
     print('Repository path: {0}'.format(repositoryPath))
     try:
         yield self.cloneRepository(repositoryPath)
         yield self.installRepository()
         yield self.createPackage(repositoryPath, packagePath)
         yield Upload(self.storage, **{
             'name': self.name,
             'manifest': manifestPath,
             'package': packagePath
         }).execute()
     except (RepositoryDownloadError, ModuleInstallError) as err:
         print(err)