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())
Example #2
0
    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
Example #3
0
    def __init__(self, driver_path=None, base_dir=Config().base_dir()):
        """
        @brief Constructor
        """
        self.author = None
        self.email = None
        self.driver_path = driver_path
        self.driver_name = None
        self.notes = None
        self.version = 0
        self.base_dir = base_dir
        self.constructor = None
        self.driver_name_versioned = None
        self.entry_point_group = None
        self.versioned_constructor = None

        log.debug("Constructing platform metadata")

        if (driver_path):
            log.debug("Construct from parameters: %s", self.metadata_path())
            if (os.path.isfile(self.metadata_path())):
                self.read_from_file(self.metadata_path())

        elif (not (driver_path)):
            self.read_from_file()

        else:
            raise InvalidParameters(msg="driver_path must all be specified")
Example #4
0
    def __init__(self,
                 driver_make=None,
                 driver_model=None,
                 driver_name=None,
                 base_dir=Config().base_dir()):
        """
        @brief Constructor
        """
        self.author = None
        self.email = None
        self.driver_make = driver_make
        self.driver_model = driver_model
        self.driver_name = driver_name
        self.notes = None
        self.version = 0
        self.base_dir = base_dir

        if (driver_make and driver_model and driver_name):
            log.debug("Construct from parameters")
            if (os.path.isfile(self.metadata_path())):
                self.read_from_file(self.metadata_path())

        elif (not (driver_make or driver_model or driver_name)):
            self.read_from_file()

        else:
            raise InvalidParameters(
                msg=
                "driver_make, driver_model, driver_name must all be specified")
Example #5
0
    def __init__(self, metadata):
        """
        @brief Constructor
        @param metadata IDK Metadata object
        """
        self.metadata = metadata
        self._bdir = None
        self._repodir = mi.idk.egg_generator.REPODIR
        sys.path.insert(0, self._repodir)
        log.debug(sys.path)

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

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

        self.generator = DriverGenerator(self.metadata)
        log.debug("importing test module: %s", self._test_module())
        test_import = __import__(self._test_module())
Example #6
0
 def get_repackage_version(self, tag_base):
     """
     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)
     # confirm this version has the correct format
     self._verify_version(repkg_version)
     # check to make sure this driver version exists
     tag_name = 'release_' + tag_base + '_' + 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)
     else:
         log.error('No driver version %s found', tag_name)
         raise InvalidParameters('No driver version %s found', tag_name)
Example #7
0
    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')