コード例 #1
0
    def __init__(self):
        """
        @brief ctor
        """
        self.metadata = Metadata()
        self._zipfile = None
        self._manifest = None
        self._compression = None
        self.generator = DriverGenerator(self.metadata)

        # Set compression level
        self.zipfile_compression()
コード例 #2
0
ファイル: egg_generator.py プロジェクト: dstuebe/coi-services
    def __init__(self, metadata, basedir, driver_file = None, driver_test_file = None):
        driver_generator = DriverGenerator(metadata)
        
        self.basedir = basedir

        if driver_file:
            self.driver_file = driver_file
        else:
            self.driver_file = driver_generator.driver_path()

        if driver_test_file:
            self.driver_test_file = driver_test_file
        else:
            self.driver_test_file = driver_generator.driver_test_path()
        
        self.driver_dependency = DependencyList(self.driver_file, include_internal_init=True)
        self.test_dependency = DependencyList(self.driver_test_file, include_internal_init=True)
コード例 #3
0
ファイル: package_driver.py プロジェクト: seman/coi-services
    def __init__(self):
        """
        @brief ctor
        """
        self.metadata = Metadata()
        self._zipfile = None
        self._manifest = None
        self._compression = None
        self.generator = DriverGenerator(self.metadata)

        # Set compression level
        self.zipfile_compression()
コード例 #4
0
    def __init__(self,
                 metadata,
                 basedir,
                 driver_file=None,
                 driver_test_file=None):
        driver_generator = DriverGenerator(metadata)

        self.basedir = basedir

        if driver_file:
            self.driver_file = driver_file
        else:
            self.driver_file = driver_generator.driver_path()

        if driver_test_file:
            self.driver_test_file = driver_test_file
        else:
            self.driver_test_file = driver_generator.driver_test_path()

        self.driver_dependency = DependencyList(self.driver_file,
                                                include_internal_init=True)
        self.test_dependency = DependencyList(self.driver_test_file,
                                              include_internal_init=True)
コード例 #5
0
ファイル: nose_test.py プロジェクト: ooici-dm/coi-services
 def _driver_test_module(self):
     generator = DriverGenerator(self.metadata)
     return generator.test_modulename()
コード例 #6
0
ファイル: start_driver.py プロジェクト: dstuebe/coi-services
 def generate_code(self, force = False):
     """
     @brief generate the directory structure, code and tests for the new driver.
     """
     driver = DriverGenerator( self.metadata, force = force )
     driver.generate()
コード例 #7
0
ファイル: package_driver.py プロジェクト: seman/coi-services
class PackageDriver():
    """
    Main class for running the package driver process.
    """

    ###
    #   Configuration
    ###
    def log_file(self):
        return "qualification.log"

    def log_path(self):
        return "%s/%s" % (self.metadata.idk_dir(), self.log_file())

    def archive_path(self):
        return "%s/%s_%02d_driver.zip" % (os.environ['HOME'], self.metadata.name.lower(), self.metadata.version)


    ###
    #   Public Methods
    ###
    def __init__(self):
        """
        @brief ctor
        """
        self.metadata = Metadata()
        self._zipfile = None
        self._manifest = None
        self._compression = None
        self.generator = DriverGenerator(self.metadata)

        # Set compression level
        self.zipfile_compression()

    def run_qualification_tests(self):
        """
        @brief Run all qualification tests for the driver and store the results for packaging
        """
        log.info("-- Running qualification tests")

        test = NoseTest(self.metadata, log_file=self.log_path())
        test.report_header()

        result = test.run_qualification()

        if(test.run_qualification()):
            log.info(" ++ Qualification tests passed")
            return True
        else:
            log.error("Qualification tests have fail!  No package created.")
            return False

    def package_driver(self):
        """
        @brief Store driver files in a zip package
        """
        log.info("-- Building driver package")
        self._store_package_files()

    def run(self):
        print "*** Starting Driver Packaging Process***"

        if( self.run_qualification_tests() ):
            self.package_driver()
            print "Package Created: " + self.archive_path()
        else:
            sys.exit()

    def zipfile(self):
        """
        @brief Return the ZipFile object.  Create the file if it isn't already open
        @retval ZipFile object
        """
        if(not self._zipfile):
            self._zipfile = zipfile.ZipFile(self.archive_path(), mode="w")

        return self._zipfile

    def zipfile_compression(self):
        """
        @brief What type of compression should we use for the package file.  If we have access to zlib, we will compress
        @retval Compression type
        """

        if(self._compression): return self._compression

        try:
            import zlib
            self._compression = zipfile.ZIP_DEFLATED
            log.info("Setting compression level to deflated")
        except:
            log.info("Setting compression level to store only")
            self._compression = zipfile.ZIP_STORED

    def manifest(self):
        """
        @brief Return the PackageManifest object.  Create it if it doesn't already exist
        @retval PackageManifest object
        """
        if(not self._manifest):
            self._manifest = PackageManifest(self.metadata)

        return self._manifest


    ###
    #   Private Methods
    ###
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """

        # Add python source files
        self._add_file(self.generator.driver_full_name(), 'src', 'driver source code')
        self._add_file(self.generator.driver_test_full_name(), 'src/test', 'driver test code')

        # Add the package metadata file
        self._add_file(self.metadata.metadata_path(), description = 'package metadata')

        # Add the qualification test log
        self._add_file(self.log_path(), description = 'qualification tests results')

        # Store additional resource files
        self._store_resource_files()

        # Finally save the manifest file.  This must be last of course
        self._add_file(self.manifest().manifest_path(), description = 'package manifest file')


    def _store_resource_files(self):
        """
        @brief Store additional files added by the driver developer.  These files life in the driver resource dir.
        """
        log.debug( " -- Searching for developer added resource files." )

        for file in os.listdir(self.generator.resource_dir()):
            log.debug("    ++ found: " + file)
            desc = prompt.text( 'Describe ' + file )
            self._add_file(self.generator.resource_dir() + "/" + file, 'resource', desc)


    def _add_file(self, source, destdir=None, description=None):
        """
        @brief Add a file to the zip package and store the file in the manifest.
        """
        filename = os.path.basename(source)
        dest = filename
        if(destdir):
            dest = "%s/%s" % (destdir, filename)

        log.debug( "archive %s to %s" % (filename, dest) )

        self.manifest().add_file(dest, description);
        self.zipfile().write(source, dest, self.zipfile_compression())
コード例 #8
0
ファイル: nose_test.py プロジェクト: dstuebe/coi-services
 def _driver_test_module(self):
     generator = DriverGenerator(self.metadata)
     return generator.test_modulename()
コード例 #9
0
ファイル: start_driver.py プロジェクト: ooici-dm/coi-services
 def generate_code(self, force=False):
     """
     @brief generate the directory structure, code and tests for the new driver.
     """
     driver = DriverGenerator(self.metadata, force=force)
     driver.generate()
コード例 #10
0
class PackageDriver(object):
    """
    Main class for running the package driver process.
    """

    ###
    #   Configuration
    ###
    def log_file(self):
        return "qualification.log"

    def log_path(self):
        return "%s/%s" % (self.metadata.idk_dir(), self.log_file())

    def archive_path(self):
        return "%s/%s_%02d_driver.zip" % (os.environ['HOME'],
                                          self.metadata.name.lower(),
                                          self.metadata.version)

    ###
    #   Public Methods
    ###
    def __init__(self):
        """
        @brief ctor
        """
        self.metadata = Metadata()
        self._zipfile = None
        self._manifest = None
        self._compression = None
        self.generator = DriverGenerator(self.metadata)

        # Set compression level
        self.zipfile_compression()

    def run_qualification_tests(self):
        """
        @brief Run all qualification tests for the driver and store the results for packaging
        """
        log.info("-- Running qualification tests")

        test = NoseTest(self.metadata, log_file=self.log_path())
        test.report_header()

        result = test.run_qualification()

        if (test.run_qualification()):
            log.info(" ++ Qualification tests passed")
            return True
        else:
            log.error("Qualification tests have fail!  No package created.")
            return False

    def package_driver(self):
        """
        @brief Store driver files in a zip package
        """
        log.info("-- Building driver package")
        self._store_package_files()

    def run(self):
        print "*** Starting Driver Packaging Process***"

        if (self.run_qualification_tests()):
            self.package_driver()
            print "Package Created: " + self.archive_path()
        else:
            sys.exit()

    def zipfile(self):
        """
        @brief Return the ZipFile object.  Create the file if it isn't already open
        @retval ZipFile object
        """
        if (not self._zipfile):
            self._zipfile = zipfile.ZipFile(self.archive_path(), mode="w")

        return self._zipfile

    def zipfile_compression(self):
        """
        @brief What type of compression should we use for the package file.  If we have access to zlib, we will compress
        @retval Compression type
        """

        if (self._compression): return self._compression

        try:
            import zlib
            self._compression = zipfile.ZIP_DEFLATED
            log.info("Setting compression level to deflated")
        except:
            log.info("Setting compression level to store only")
            self._compression = zipfile.ZIP_STORED

    def manifest(self):
        """
        @brief Return the PackageManifest object.  Create it if it doesn't already exist
        @retval PackageManifest object
        """
        if (not self._manifest):
            self._manifest = PackageManifest(self.metadata)

        return self._manifest

    ###
    #   Private Methods
    ###
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """

        # Add python source files
        self._add_file(self.generator.driver_full_name(), 'src',
                       'driver source code')
        self._add_file(self.generator.driver_test_full_name(), 'src/test',
                       'driver test code')

        # Add the package metadata file
        self._add_file(self.metadata.metadata_path(),
                       description='package metadata')

        # Add the qualification test log
        self._add_file(self.log_path(),
                       description='qualification tests results')

        # Store additional resource files
        self._store_resource_files()

        # Finally save the manifest file.  This must be last of course
        self._add_file(self.manifest().manifest_path(),
                       description='package manifest file')

    def _store_resource_files(self):
        """
        @brief Store additional files added by the driver developer.  These files life in the driver resource dir.
        """
        log.debug(" -- Searching for developer added resource files.")

        for file in os.listdir(self.generator.resource_dir()):
            log.debug("    ++ found: " + file)
            desc = prompt.text('Describe ' + file)
            self._add_file(self.generator.resource_dir() + "/" + file,
                           'resource', desc)

    def _add_file(self, source, destdir=None, description=None):
        """
        @brief Add a file to the zip package and store the file in the manifest.
        """
        filename = os.path.basename(source)
        dest = filename
        if (destdir):
            dest = "%s/%s" % (destdir, filename)

        log.debug("archive %s to %s" % (filename, dest))

        self.manifest().add_file(dest, description)
        self.zipfile().write(source, dest, self.zipfile_compression())