示例#1
0
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        self.metadata = Metadata(self.metadata.driver_path,
                                 REPODIR + '/marine-integrations')
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # 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 parameter/command string description file if it exists, it is not required
        string_file_path = os.path.join(self.generator.resource_dir(),
                                        self.string_file())
        if os.path.exists(string_file_path):
            self._add_file(string_file_path, 'resource', 'driver string file')

        # 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')
示例#2
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 = None
        self.test_dependency = None
        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
 def save(self):
     driver_file = self.metadata.driver_dir() + '/' + DriverGenerator(
         self.metadata).driver_filename()
     driver_test_file = self.metadata.driver_dir(
     ) + '/test/' + DriverGenerator(self.metadata).driver_test_filename()
     filelist = DriverFileList(self.metadata, self._repo_dir(), driver_file,
                               driver_test_file)
     return self._build_egg(filelist.files())
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        self.metadata = Metadata(self.metadata.driver_path, REPODIR + '/marine-integrations')
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # 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 parameter/command string description file
        self._add_file("%s/%s" % (self.generator.resource_dir(), self.string_file()),
                       'resource', 'driver string file')
        
        # 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 __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 = None
        self.test_dependency = None
        self.driver_dependency = DependencyList(self.driver_file, include_internal_init=True)
        self.test_dependency = DependencyList(self.driver_test_file, include_internal_init=True)
示例#6
0
    def __init__(self, metadata):
        """
        @brief Constructor
        @param metadata IDK Metadata object
        """
        self.metadata = metadata
        self._bdir = None

        if not self._tmp_dir():
            raise InvalidParameters("missing tmp_dir configuration")

        if not self._tmp_dir():
            raise InvalidParameters("missing working_repo configuration")

        self.generator = DriverGenerator(self.metadata)
        test_import = __import__(self._test_module())
class PackageDriver(mi.idk.package_driver.PackageDriver):

    def archive_file(self):
        return "%s-%s-driver.zip" % (self.metadata.driver_name,
                                     self.metadata.version)

    ###
    #   Public Methods
    ###
    def __init__(self, test_mode=False):
        """
        @brief ctor
        """
        self.test_mode = test_mode
        self._zipfile = None
        self._manifest = None
        self._compression = None

        # 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()

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

    def update_version(self):
        """
        Update the driver version for this package.  By default increment by one.
        After updating the metadata file, commit the change to git.
        """
        last_dot = self.metadata.version.rfind('.')
        last_version = int(self.metadata.version[last_dot+1:])
        suggest_version = self.metadata.version[:last_dot+1] + str(last_version + 1)
        if self.test_mode:
            new_version = suggest_version
        else:
            new_version = prompt.text('Update Driver Version', suggest_version )
        # make sure the entered version has the correct format
        self._verify_version(new_version)
        if new_version != self.metadata.version:
            # search for the tag for this version, find out if it already exists
            cmd = 'git tag -l ' + 'release_dsd_' + self.metadata.driver_name + '_' + new_version.replace('.', '_')
            # find out if this tag name exists
            output = subprocess.check_output(cmd, shell=True)
            if len(output) > 0:
                # this tag already exists and we are not repackaging
                raise InvalidParameters("Version %s already exists.  To repackage, run package driver with the --repackage option", new_version)

            # set the new driver version in the metadata
            self.metadata.set_driver_version(new_version)
            # commit the changed file to git
            cmd = 'git commit ' + str(self.metadata.metadata_path()) + ' -m \'Updated metadata driver version\''
            os.system(cmd)

        return new_version

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

        # store the original directory since we will be navigating away from it
        original_dir = os.getcwd()

        # first create a temporary clone of ooici to work with
        self.clone_repo()

        # get which dataset agent is selected from the current metadata, use
        # this to get metadata from the cloned repo
        tmp_metadata = Metadata()
        # read metadata from the cloned repo
        self.metadata = Metadata(tmp_metadata.driver_path, REPODIR + '/marine-integrations')

        if self.test_mode:
            #sys.argv.append("--repackage")
            sys.argv.append("--no-push")
        log.debug("test mode: %s, argv: %s", self.test_mode, sys.argv)

        # for now leave out the test option until test are more stable,
        # just build the package driver
        if "--repackage" in sys.argv:
            self.get_repackage_version('dsd_' + self.metadata.driver_name)
            self.package_driver()
        else:
            new_version = self.update_version()
            self.make_branch('dsd_' + self.metadata.driver_name + '_' + new_version.replace('.', '_'))
            self.package_driver()

            if not "--no-push" in sys.argv:
                cmd = 'git push %s' % WRITE_REPO_URL
                output = subprocess.check_output(cmd, shell=True)
                if len(output) > 0:
                    log.debug('git push returned: %s', output)

        # go back to the original directory
        os.chdir(original_dir)

        print "Package Created: " + self.archive_path()

    ###
    #   Private Methods
    ###
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        self.metadata = Metadata(self.metadata.driver_path, REPODIR + '/marine-integrations')
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # 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 parameter/command string description file
        self._add_file("%s/%s" % (self.generator.resource_dir(), self.string_file()),
                       'resource', 'driver string file')
        
        # 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 live in the driver resource dir.
        """
        resource_dir = os.path.join(self.metadata.relative_driver_path(), "resource")
        log.debug(" -- Searching for developer added resource files in dir: %s",
                  resource_dir)
        stringfile = self.string_file()
        if os.path.exists(resource_dir):
            for file in os.listdir(resource_dir):
                if file != stringfile:
                    log.debug("    ++ found: " + file)
                    desc = prompt.text('Describe ' + file)
                    self._add_file(resource_dir + "/" + file, 'resource', desc)
        else:
            log.debug(" --- No resource directory found, skipping...")
示例#8
0
class PackageDriver(mi.idk.package_driver.PackageDriver):
    def archive_file(self):
        return "%s-%s-driver.zip" % (self.metadata.driver_name,
                                     self.metadata.version)

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

        # 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()

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

    def update_version(self):
        """
        Update the driver version for this package.  By default increment by one.
        After updating the metadata file, commit the change to git.
        """
        last_dot = self.metadata.version.rfind('.')
        last_version = int(self.metadata.version[last_dot + 1:])
        suggest_version = self.metadata.version[:last_dot +
                                                1] + str(last_version + 1)
        new_version = prompt.text('Update Driver Version', suggest_version)
        # make sure the entered version has the correct format
        self._verify_version(new_version)
        if new_version != self.metadata.version:
            # search for the tag for this version, find out if it already exists
            cmd = 'git tag -l ' + 'release_dsd_' + self.metadata.driver_name + '_' + new_version.replace(
                '.', '_')
            # find out if this tag name exists
            output = subprocess.check_output(cmd, shell=True)
            if len(output) > 0:
                # this tag already exists and we are not repackaging
                raise InvalidParameters(
                    "Version %s already exists.  To repackage, run package driver with the --repackage option",
                    new_version)

            # set the new driver version in the metadata
            self.metadata.set_driver_version(new_version)
            # commit the changed file to git
            cmd = 'git commit ' + str(self.metadata.metadata_path(
            )) + ' -m \'Updated metadata driver version\''
            os.system(cmd)

        return new_version

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

        # store the original directory since we will be navigating away from it
        original_dir = os.getcwd()

        # first create a temporary clone of ooici to work with
        self.clone_repo()

        # get which dataset agent is selected from the current metadata, use
        # this to get metadata from the cloned repo
        tmp_metadata = Metadata()
        # read metadata from the cloned repo
        self.metadata = Metadata(tmp_metadata.driver_path,
                                 REPODIR + '/marine-integrations')

        # for now leave out the test option until test are more stable,
        # just build the package driver
        if "--repackage" in sys.argv:
            self.get_repackage_version('dsd_' + self.metadata.driver_name)
            self.package_driver()
        else:
            new_version = self.update_version()
            self.make_branch('dsd_' + self.metadata.driver_name + '_' +
                             new_version.replace('.', '_'))
            self.package_driver()

            if not "--no-push" in sys.argv:
                cmd = 'git push --tags'
                output = subprocess.check_output(cmd, shell=True)
                if len(output) > 0:
                    log.debug('git push returned: %s', output)

        # go back to the original directory
        os.chdir(original_dir)

        print "Package Created: " + self.archive_path()

    ###
    #   Private Methods
    ###
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        self.metadata = Metadata(self.metadata.driver_path,
                                 REPODIR + '/marine-integrations')
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # 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 parameter/command string description file if it exists, it is not required
        string_file_path = os.path.join(self.generator.resource_dir(),
                                        self.string_file())
        if os.path.exists(string_file_path):
            self._add_file(string_file_path, 'resource', 'driver string file')

        # 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 live in the driver resource dir.
        """
        resource_dir = os.path.join(self.metadata.relative_driver_path(),
                                    "resource")
        log.debug(
            " -- Searching for developer added resource files in dir: %s",
            resource_dir)
        stringfile = self.string_file()
        if os.path.exists(resource_dir):
            for file in os.listdir(resource_dir):
                if file != stringfile:
                    log.debug("    ++ found: " + file)
                    self._add_file(resource_dir + "/" + file, 'resource',
                                   'test file')
        else:
            log.debug(" --- No resource directory found, skipping...")
示例#9
0
 def _driver_test_filename(self):
     generator = DriverGenerator(self.metadata)
     return generator.driver_test_path()
示例#10
0
 def _data_test_module(self):
     generator = DriverGenerator(self.metadata)
     return generator.data_test_modulename()
示例#11
0
 def _driver_test_filename(self):
     generator = DriverGenerator(self.metadata)
     return generator.driver_test_path()
示例#12
0
 def _data_test_module(self):
     generator = DriverGenerator(self.metadata)
     return generator.data_test_modulename()
class PackageDriver(mi.idk.package_driver.PackageDriver):

    def archive_file(self):
        return "%s-%s-driver.zip" % (self.metadata.driver_name,
                                     self.metadata.version)
    
    ###
    #   Public Methods
    ###
    def __init__(self):
        """
        @brief ctor
        """
        self._zipfile = None
        self._manifest = None
        self._compression = None

        # 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()

        if(test.run_qualification()):
            log.info(" ++ Qualification tests passed")
            return True
        else:
            log.error("Qualification tests have fail!  No package created.")
            return False
        
    def clone_repo(self):
        """
        clone the ooici repository into a temp location and navigate to it
        """
        # make a temp dir to put the clone in
        if not os.path.exists(REPODIR):
            os.mkdir(REPODIR)
        os.chdir(REPODIR)
        # remove an old clone if one exists, start clean
        if os.path.exists(REPODIR + '/marine-integrations'):
            shutil.rmtree(REPODIR + '/marine-integrations')

        # clone the ooici repository into a temporary location
        os.system('git clone [email protected]:ooici/marine-integrations.git')
        log.debug('cloned repository')

        # if the directory doesn't exist, something went wrong with cloning
        if not os.path.exists(REPODIR + '/marine-integrations'):
            raise InvalidParameters('Error creating ooici repository clone')
        # navigate into the cloned repository
        os.chdir(REPODIR + '/marine-integrations')
        log.debug('in cloned repository')

        # get which dataset agent is selected from the current metadata, use
        # this to get metadata from the cloned repo
        tmp_metadata = Metadata()
        # read metadata from the cloned repo
        self.metadata = Metadata(tmp_metadata.driver_path, REPODIR + '/marine-integrations')

    def get_repackage_version(self):
        """
        Get the driver version the user wants to repackage
        """
        # suggest the current driver version as default
        repkg_version = prompt.text( 'Driver Version to re-package', self.metadata.version )
        # check to make sure this driver version exists
        tag_name = 'driver_' + self.metadata.driver_name + '_' + repkg_version.replace('.','_')
        cmd = 'git tag -l ' + tag_name 
        # find out if this tag name exists
        output = subprocess.check_output(cmd, shell=True)
        if len(output) > 0:
            # this tag exists, check it out
            os.system('git checkout tags/' + tag_name)
            # re-read the metadata since version may have changed in metadata.yml file
            self.metadata = Metadata(self.metadata.driver_path, REPODIR + '/marine-integrations')
        else:
            log.error('No driver version %s found', tag_name)
            raise InvalidParameters('No driver version %s found', tag_name)

    def make_branch(self):
        """
        Make a new branch for this release and tag it with the same name so we
        can get back to it
        """
        name = self.metadata.driver_name_versioned
        # create a new branch name and check it out
        cmd = 'git checkout -b ' + name
        output = subprocess.check_output(cmd, shell=True)
        log.debug('created new branch %s: %s', name, output)
        # tag the initial branch so that we can get back to it later
        cmd = 'git tag ' + name
        output = subprocess.check_output(cmd, shell=True)
        log.debug('created new tag %s: %s', name, output)

    def update_version(self):
        """
        Update the driver version for this package.  By default increment by one.
        After updating the metadata file, commit the change to git.
        """
        last_dot = self.metadata.version.rfind('.')
        last_version = int(self.metadata.version[last_dot+1:])
        suggest_version = self.metadata.version[:last_dot+1] + str(last_version + 1)
        new_version = prompt.text('Update Driver Version', suggest_version )
        if new_version != self.metadata.version:
            # set the new driver version in the metadata
            self.metadata.set_driver_version(new_version)
            # commit the changed file to git
            cmd = 'git commit ' + str(self.metadata.metadata_path()) + ' -m \'Updated metadata driver version\''
            os.system(cmd)
            # read metadata again to update the version in our metadata
            self.metadata = Metadata(self.metadata.driver_path, REPODIR + '/marine-integrations')

    def run(self):
        print "*** Starting Driver Packaging Process ***"
        
        # store the original directory since we will be navigating away from it
        original_dir = os.getcwd()

        # first create a temporary clone of ooici to work with
        self.clone_repo()

        # for now comment out the test option until test are more stable,
        # just build the package driver
        if len(sys.argv) == 2 and (sys.argv[1] == "--repackage"):
            self.get_repackage_version()
            self.package_driver()
        else:
            self.update_version()
            self.make_branch()
            self.package_driver()

            if prompt.yes_no('Do you want to push the new release branch to ooici?'):
                cmd = 'git push'
                output = subprocess.check_output(cmd, shell=True)
                if len(output) > 0:
                    log.debug('git push returned: %s', output)

        # go back to the original directory
        os.chdir(original_dir)

        print "Package Created: " + self.archive_path()

    ###
    #   Private Methods
    ###
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # 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 parameter/command string description file
        self._add_file("%s/%s" % (self.generator.resource_dir(), self.string_file()),
                       'resource', 'driver string file')
        
        # 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')