Пример #1
0
    def parse_line_to_module(self, line, current_url, current_url_type):
        """Function that parses a line in the INSTALL_CONFIG file into an InstallModule object

        Parameters
        ----------
        line : str
            line from table in file
        current_url : str
            url at which module is located
        current_url_type : str
            either GIT_URL or WGET_URL
        
        Returns
        -------
        InstallModule
            module parsed from the table line
        """

        # Remove extra whitespace
        line = re.sub('\t', ' ', line)
        line = re.sub(' +', ' ', line)
        module_components = line.split(' ')
        # If a line is read that isn't in the correct format return None
        if len(module_components) < 6:
            return None
        # line will be in format:
        # NAME   VERSION   RELATIVE_PATH   REPOSITORY   CLONE   BUILD   PACKAGE
        name = module_components[0]
        version = module_components[1]
        rel_path = module_components[2]
        repository = module_components[3]
        clone = module_components[4]
        build = module_components[5]
        if name in self.required_in_package:
            package = "YES"
        # Add length check for compatibility with older configure directories - default package to NO
        elif len(module_components) == 7:
            package = module_components[6]
        else:
            package = "NO"
        # create object from line and return it
        LOG.debug('Parsed install module: {}'.format(name))
        install_module = IM.InstallModule(name, version, rel_path,
                                          current_url_type, current_url,
                                          repository, clone, build, package)
        return install_module
"""

__author__ = "Jakub Wlodek"
__copyright__ = "Copyright June 2019, Brookhaven Science Associates"

# unit test include
import pytest

# installSynApps include
import installSynApps.DataModel.install_config as InstallConfig
import installSynApps.DataModel.install_module as InstallModule

# Test install
install_config = InstallConfig.InstallConfiguration('/epics/test', 'configure')
base_module = InstallModule.InstallModule('EPICS_BASE', 'R7.0.2.2',
                                          '$(INSTALL)/base', 'GIT_URL',
                                          'https://github.com/dummyurl/test/',
                                          'base', 'YES', 'YES', 'YES')
support_module = InstallModule.InstallModule(
    'SUPPORT', 'R6-0', '$(INSTALL)/support', 'GIT_URL',
    'https://github.com/dummyurl/test/', 'support', 'YES', 'YES', 'NO')
ad_module = InstallModule.InstallModule('AREA_DETECTOR', 'R3-6',
                                        '$(SUPPORT)/areaDetector', 'GIT_URL',
                                        'https://github.com/dummyurl/test/',
                                        'ad', 'YES', 'YES', 'NO')
core_module = InstallModule.InstallModule('ADCORE', 'R3-6',
                                          '$(AREA_DETECTOR)/ADCore', 'GIT_URL',
                                          'https://github.com/dummyurl/test/',
                                          'ad', 'YES', 'YES', 'YES')

test_module = InstallModule.InstallModule('DUMMY', 'R1-0',
                                          '$(AREA_DETECTOR)/dummy', 'GIT_URL',
def test_version_replace():
    module = Module.InstallModule('TEMP', 'R1-0', '$(SUPPORT)/test',
                                  'WGET_URL', 'https://dummy.url/',
                                  'temp-$(VERSION).tgz', 'YES', 'YES', 'NO')
    assert module.repository == 'temp-R1-0.tgz'
Пример #4
0
    def applyChanges(self):
        """
        Method that reads the contents of the text boxes, and tries to create a new InstallModule object.
        If the new object is valid and is created successfully, the module is added to the install config,
        and the root InstallSynAppsGUI object calls update all references
        """

        name = self.name_box.get('1.0', END).strip()
        version = self.version_box.get('1.0', END).strip()
        rel_path = self.rel_path_box.get('1.0', END).strip()
        url_type = self.url_type_var.get()
        url = self.url_box.get('1.0', END).strip()
        repo = self.repository_box.get('1.0', END).strip()
        clone = self.clone_check.get()
        build = self.build_check.get()
        package = self.package_check.get()
        clone_str = 'NO'
        build_str = 'NO'
        package_str = 'NO'

        if len(name) == 0:
            self.root.showErrorMessage('Add Module Error',
                                       'ERROR - Please enter a valid name.',
                                       force_popup=True)
            return

        name = name.upper()

        if len(version) == 0:
            version = 'master'

        if len(rel_path) == 0:
            self.root.showErrorMessage(
                'Add Module Error',
                'ERROR - Please enter a valid relative path.',
                force_popup=True)
            return

        if len(url) == 0 or len(repo) == 0:
            self.root.showErrorMessage(
                'Add Module Error',
                'ERROR - Please enter a url and repository.',
                force_popup=True)

        if not url.endswith('/'):
            url = url + '/'

        existing_modules = self.install_config.get_module_list()
        for module in existing_modules:
            if module.name == name or module.rel_path == rel_path or (
                    module.url + module.repository) == url + repo:
                self.root.showErrorMessage('Add Module Error',
                                           'ERROR - Module already exists.',
                                           force_popup=True)
                return

        abs_path = self.install_config.convert_path_abs(rel_path)
        if '$(' in abs_path:
            self.root.showErrorMessage(
                'Add Module Error',
                'ERROR - Given path not valid or cannot be parsed',
                force_popup=True)
            return
        if clone:
            clone_str = 'YES'
        if build:
            build_str = 'YES'
        if pakcage:
            package_str = 'YES'
        new_module = Module.InstallModule(name, version, rel_path, url_type,
                                          url, repo, clone_str, build_str,
                                          package_str)
        self.install_config.add_module(new_module)
        self.root.updateAllRefs(self.install_config)
        self.root.updateConfigPanel()
        self.root.showMessage(
            'Info',
            'Added module: {} with version {} to config'.format(name, version))