예제 #1
0
파일: __init__.py 프로젝트: yanatan16/disco
    def jobzip(self, job, **jobargs):
        """
        A hook provided by the :class:`Worker` for creating the :term:`job home` zip.

        :return: a :class:`disco.fileutils.DiscoZipFile`.
        """
        from clx import __file__ as clxpath
        from disco import __file__ as discopath
        from disco.fileutils import DiscoZipFile
        jobzip = DiscoZipFile()
        jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', '__pycache__'))
        jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', '__pycache__'))
        jobzip.writesource(job)
        jobzip.writesource(self)
        return jobzip
예제 #2
0
    def jobzip(self, job, **jobargs):
        """
        A hook provided by the :class:`Worker` for creating the :term:`job home` zip.

        :return: a :class:`disco.fileutils.DiscoZipFile`.
        """
        from clx import __file__ as clxpath
        from disco import __file__ as discopath
        from disco.fileutils import DiscoZipFile
        jobzip = DiscoZipFile()
        jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', ))
        jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', ))
        jobzip.writesource(job)
        jobzip.writesource(self)
        return jobzip
예제 #3
0
파일: __init__.py 프로젝트: Cheng--Li/disco
    def jobzip(self, job, **jobargs):
        """
        A hook provided by the :class:`Worker` for creating the
        :term:`job home` zip.  The base implementation creates a
        minimal zip file containing the Disco standard library, and
        any user-specified required files and modules.

        :return: a :class:`disco.fileutils.DiscoZipFile`.
        """
        # First, add the disco standard library.
        from clx import __file__ as clxpath
        from disco import __file__ as discopath
        from disco.fileutils import DiscoZipFile
        jobzip = DiscoZipFile()
        jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', '__pycache__'))
        jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', '__pycache__'))
        jobzip.writesource(job)
        jobzip.writesource(self)
        # Then, add any user-specified required files.
        from disco.util import iskv
        def get(key):
            return self.getitem(key, job, jobargs)
        if isinstance(get('required_files'), dict):
            for path, bytes in get('required_files').items():
                jobzip.writestr(path, bytes)
        else:
            for path in get('required_files'):
                jobzip.write(path, os.path.join('lib', os.path.basename(path)))
        if get('required_modules') is None:
            self['required_modules'] = self.get_modules(job, **jobargs)
        for mod in get('required_modules'):
            if iskv(mod):
                jobzip.writepath(mod[1])
        # Done with basic minimal zip.
        return jobzip
예제 #4
0
    def jobzip(self, job, **jobargs):
        """
        A hook provided by the :class:`Worker` for creating the
        :term:`job home` zip.  The base implementation creates a
        minimal zip file containing the Disco standard library, and
        any user-specified required files and modules.

        :return: a :class:`disco.fileutils.DiscoZipFile`.
        """
        # First, add the disco standard library.
        from clx import __file__ as clxpath
        from disco import __file__ as discopath
        from disco.fileutils import DiscoZipFile
        jobzip = DiscoZipFile()
        jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', '__pycache__'))
        jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', '__pycache__'))
        jobzip.writesource(job)
        jobzip.writesource(self)
        # Then, add any user-specified required files.
        from disco.util import iskv
        def get(key):
            return self.getitem(key, job, jobargs)
        if isinstance(get('required_files'), dict):
            for path, bytes in get('required_files').items():
                jobzip.writestr(path, bytes)
        else:
            for path in get('required_files'):
                jobzip.write(path, os.path.join('lib', os.path.basename(path)))
        if get('required_modules') is None:
            self['required_modules'] = self.get_modules(job, **jobargs)
        for mod in get('required_modules'):
            if iskv(mod):
                jobzip.writepath(mod[1])
        # Done with basic minimal zip.
        return jobzip
예제 #5
0
파일: discocli.py 프로젝트: saa/disco
 def jobzip(*paths):
     jobzip = DiscoZipFile()
     for path in paths:
         jobzip.writepath(path)
     jobzip.close()
     return jobzip