示例#1
0
    def get_owner(self):
        '''
        Prompts user for overlay owner info and
        then appends the values to the overlay
        being created.
        '''
        self.overlay['owner'] = []
        self.output.notice('')

        msg = 'How many people own this overlay?: '
        owner_amount = int(get_input(msg))

        for i in range(1, owner_amount + 1):
            owner = {}
            extra = ''

            if owner_amount > 1:
                extra = '[%(i)s]\'s' % {'i': str(i)}

            owner['name'] = get_input('Define owner%(extra)s name: '\
                            % {'extra': extra})
            owner['email'] = get_input('Define owner%(extra)s email: '\
                             % {'extra': extra})
            self.overlay['owner'].append(owner)

        self.output.notice('')
示例#2
0
文件: maker.py 项目: dewey/layman
    def get_owner(self):
        '''
        Prompts user for overlay owner info and
        then appends the values to the overlay
        being created.
        '''
        self.overlay['owner'] = []
        self.output.notice('')

        msg = 'How many people own this overlay?: '
        owner_amount = int(get_input(msg))

        for i in range(1, owner_amount + 1):
            owner = {}
            extra = ''

            if owner_amount > 1:
                extra = '[%(i)s]\'s' % {'i': str(i)}

            owner['name'] = get_input('Define owner%(extra)s name: '\
                            % {'extra': extra})
            owner['email'] = get_input('Define owner%(extra)s email: '\
                             % {'extra': extra})
            self.overlay['owner'].append(owner)

        self.output.notice('')
示例#3
0
文件: maker.py 项目: wking/layman
 def get_owner(self):
     '''
     Prompts user for overlay owner info and
     then appends the values to the overlay
     being created.
     '''
     self.output.notice('')
     self.overlay['owner_name'] = get_input('Define owner name: ')
     self.overlay['owner_email'] = get_input('Define owner email: ')
     self.output.notice('')
示例#4
0
 def get_owner(self):
     """
     Prompts user for overlay owner info and
     then appends the values to the overlay
     being created.
     """
     self.output.notice("")
     self.overlay["owner_name"] = get_input("Define owner name: ")
     self.overlay["owner_email"] = get_input("Define owner email: ")
     self.output.notice("")
示例#5
0
    def get_source(self):
        '''
        Prompts user for possible overlay source
        information such as type, url, and branch
        and then appends the values to the overlay
        being created.
        '''
        ovl_type = None

        if self.auto_complete:
            source_amount = 1
        else:
            msg = 'How many different sources, protocols, or mirrors exist '\
                  'for this overlay?: '
            source_amount = int(get_input(msg))

        self.overlay['source'] = []

        for i in range(1, source_amount + 1):
            sources = []
            correct = False
            extra = ''
            if source_amount > 1:
                extra = '[%(i)s]\'s' % {'i': str(i)}

            msg = 'Define source%(extra)s URL: ' % {'extra': extra}
            sources.append(get_input(msg))

            ovl_type = self.guess_overlay_type(sources[0])
            if ovl_type:
                msg = 'Is "%(type)s" the correct overlay type?: '\
                    % ({'type': ovl_type})
                correct = get_ans(msg)
            while not ovl_type or not correct:
                msg = 'Please provide overlay type: '
                ovl_type = self.check_overlay_type(\
                            get_input(msg, color='yellow'))
                correct = True

            sources.append(ovl_type)
            if 'branch' in self.required:
                msg = 'Define source%(extra)s branch (if applicable): '\
                      % {'extra': extra}
                sources.append(get_input(msg))
            else:
                sources.append('')

            if self.auto_complete:
                sources = self._set_additional_info(sources)
                for source in sources:
                    self.overlay['source'].append(source)
            else:
                self.overlay['source'].append(sources)
        self.output.notice('')
示例#6
0
文件: maker.py 项目: dewey/layman
    def get_source(self):
        '''
        Prompts user for possible overlay source
        information such as type, url, and branch
        and then appends the values to the overlay
        being created.
        '''
        ovl_type = None

        if self.auto_complete:
            source_amount = 1
        else:
            msg = 'How many different sources, protocols, or mirrors exist '\
                  'for this overlay?: '
            source_amount = int(get_input(msg))

        self.overlay['source'] = []

        for i in range(1, source_amount + 1):
            sources = []
            correct = False
            extra = ''
            if source_amount > 1:
                extra = '[%(i)s]\'s' % {'i': str(i)}

            msg = 'Define source%(extra)s URL: ' % {'extra': extra}
            sources.append(get_input(msg))

            ovl_type = self.guess_overlay_type(sources[0])
            if ovl_type:
                msg = 'Is "%(type)s" the correct overlay type?: '\
                    % ({'type': ovl_type})
                correct = get_ans(msg)
            while not ovl_type or not correct:
                msg = 'Please provide overlay type: '
                ovl_type = self.check_overlay_type(\
                            get_input(msg, color='yellow'))
                correct = True

            sources.append(ovl_type)
            if 'branch' in self.required:
                msg = 'Define source%(extra)s branch (if applicable): '\
                      % {'extra': extra}
                sources.append(get_input(msg))
            else:
                sources.append('')

            if self.auto_complete:
                sources = self._set_additional_info(sources)
                for source in sources:
                    self.overlay['source'].append(source)
            else:
                self.overlay['source'].append(sources)
        self.output.notice('')
示例#7
0
    def get_name(self):
        """
        Prompts user for the overlay name
        and updates the overlay dict.
        """
        name = get_input("Define overlay name: ")

        if not self.sudo:
            while name in self.overlays_available:
                msg = "!!! Overlay name already defined in list of installed" " overlays."
                self.output.warn(msg)
                msg = "Please specify a different overlay name: "
                name = get_input(msg, color="yellow")

        self.overlay["name"] = name
示例#8
0
文件: maker.py 项目: dewey/layman
    def get_name(self):
        '''
        Prompts user for the overlay name
        and updates the overlay dict.
        '''
        name = get_input('Define overlay name: ')

        if not self.sudo:
            while name in self.overlays_available:
                msg = '!!! Overlay name already defined in list of installed'\
                      ' overlays.'
                self.output.warn(msg)
                msg = 'Please specify a different overlay name: '
                name = get_input(msg, color='yellow')

        self.overlay['name'] = name
示例#9
0
    def get_name(self):
        '''
        Prompts user for the overlay name
        and updates the overlay dict.
        '''
        name = get_input('Define overlay name: ')

        if not self.sudo:
            while name in self.overlays_available:
                msg = '!!! Overlay name already defined in list of installed'\
                      ' overlays.'
                self.output.warn(msg)
                msg = 'Please specify a different overlay name: '
                name = get_input(msg, color='yellow')

        self.overlay['name'] = name
示例#10
0
文件: maker.py 项目: wking/layman
    def get_feeds(self):
        '''
        Prompts user for any overlay RSS feeds
        and updates overlay dict with values.
        '''
        msg = 'How many RSS feeds exist for this overlay?: '
        feed_amount = int(get_input(msg))
        feeds = []

        for i in range(1, feed_amount + 1):
            if feed_amount > 1:
                msg = 'Define overlay feed[%(i)s]: ' % ({'i': str(i)})
                feeds.append(get_input(msg))
            else:
                feeds.append(get_input('Define overlay feed: '))

        self.overlay['feeds'] = feeds
        self.output.notice('')
示例#11
0
    def get_feed(self):
        '''
        Prompts user for any overlay RSS feeds
        and updates overlay dict with values.
        '''
        msg = 'How many RSS feeds exist for this overlay?: '
        feed_amount = int(get_input(msg))
        feeds = []

        for i in range(1, feed_amount + 1):
            extra = ''
            if feed_amount > 1:
                extra = '[%(i)s]' % {'i': str(i)}
            feeds.append(get_input('Define overlay%(extra)s feed: '\
                         % {'extra': extra}))

        self.overlay['feed'] = feeds
        self.output.notice('')
示例#12
0
    def get_feed(self):
        """
        Prompts user for any overlay RSS feeds
        and updates overlay dict with values.
        """
        msg = "How many RSS feeds exist for this overlay?: "
        feed_amount = int(get_input(msg))
        feeds = []

        for i in range(1, feed_amount + 1):
            if feed_amount > 1:
                msg = "Define overlay feed[%(i)s]: " % ({"i": str(i)})
                feeds.append(get_input(msg))
            else:
                feeds.append(get_input("Define overlay feed: "))

        self.overlay["feed"] = feeds
        self.output.notice("")
示例#13
0
文件: maker.py 项目: dewey/layman
    def get_feed(self):
        '''
        Prompts user for any overlay RSS feeds
        and updates overlay dict with values.
        '''
        msg = 'How many RSS feeds exist for this overlay?: '
        feed_amount = int(get_input(msg))
        feeds = []

        for i in range(1, feed_amount + 1):
            extra = ''
            if feed_amount > 1:
                extra = '[%(i)s]' % {'i': str(i)}
            feeds.append(get_input('Define overlay%(extra)s feed: '\
                         % {'extra': extra}))

        self.overlay['feed'] = feeds
        self.output.notice('')
示例#14
0
    def write(self, destination):
        '''
        Writes overlay file to desired location.

        @params destination: path & file to write xml to.
        @rtype bool: reflects success or failure to write xml.
        '''
        if not destination:
            filepath = self.config.get_option('overlay_defs')
            if self.sudo:
                filepath = get_input('Desired file destination dir: ')
            filename = get_input('Desired overlay file name: ')

            if not filename.endswith('.xml'):
                filename += ".xml"

            if not filepath.endswith(os.path.sep):
                filepath += os.path.sep

            destination = filepath + filename

        self.tree = ET.Element('repositories',
                               version='1.1',
                               encoding=_UNICODE)

        if os.path.isfile(destination):
            self.read(destination)

        self._sort_to_tree()
        indent(self.tree)
        self.tree = ET.ElementTree(self.tree)

        try:
            with fileopen(destination, 'w') as xml:
                self.tree.write(xml, encoding=_UNICODE)
            msg = 'Successfully wrote repo(s) to: %(path)s'\
                  % ({'path': destination})
            self.output.info(msg)
            return True

        except IOError as e:
            raise Exception("Writing XML failed: %(error)s" % ({'error': e}))
示例#15
0
    def get_component(self, component, msg):
        '''
        Sets overlay component value.

        @params component: (str) component to be set
        @params msg: (str) prompt message for component
        '''
        if component not in ('branch', 'type'):
            if component in ('description', 'feed', 'name', 'owner', 'source'):
                getattr(self, 'get_%(comp)s' % ({'comp': component}))()
            else:
                self.overlay[component] = get_input(msg)
示例#16
0
文件: maker.py 项目: dewey/layman
    def get_component(self, component, msg):
        '''
        Sets overlay component value.

        @params component: (str) component to be set
        @params msg: (str) prompt message for component
        '''
        if component not in ('branch', 'type'):
            if component in ('description', 'feed', 'name', 'owner', 'source'):
                getattr(self, 'get_%(comp)s' % ({'comp': component}))()
            else:
                self.overlay[component] = get_input(msg)
示例#17
0
    def get_component(self, component, msg):
        """
        Sets overlay component value.

        @params component: (str) component to be set
        @params msg: (str) prompt message for component
        """
        if component not in ("branch", "type"):
            if component in ("description", "feed", "name", "owner", "source"):
                getattr(self, "get_%(comp)s" % ({"comp": component}))()
            else:
                self.overlay[component] = get_input(msg)
示例#18
0
文件: maker.py 项目: dewey/layman
    def write(self, destination):
        '''
        Writes overlay file to desired location.

        @params destination: path & file to write xml to.
        @rtype bool: reflects success or failure to write xml.
        '''
        if not destination:
            filepath = self.config.get_option('overlay_defs')
            if self.sudo:
                filepath = get_input('Desired file destination dir: ')
            filename = get_input('Desired overlay file name: ')

            if not filename.endswith('.xml'):
                filename += ".xml"

            if not filepath.endswith(os.path.sep):
                filepath += os.path.sep

            destination = filepath + filename

        self.tree = ET.Element('repositories', version='1.1', encoding=_UNICODE)

        if os.path.isfile(destination):
            self.read(destination)

        self._sort_to_tree()
        indent(self.tree)
        self.tree = ET.ElementTree(self.tree)

        try:
            with fileopen(destination, 'w') as xml:
                self.tree.write(xml, encoding=_UNICODE)
            msg = 'Successfully wrote repo(s) to: %(path)s'\
                  % ({'path': destination})
            self.output.info(msg)
            return True

        except IOError as e:
            raise Exception("Writing XML failed: %(error)s" % ({'error': e}))
示例#19
0
文件: maker.py 项目: dewey/layman
    def get_description(self):
        '''
        Prompts user for an overlay's description(s)
        and updates overlay dict with value(s).
        '''
        #TODO: Currently a "stub" function. Add multiple description
        # field support later down the road.
        descriptions = []

        desc = get_input('Define overlay\'s description: ')
        descriptions.append(desc)

        self.overlay['description'] = descriptions
示例#20
0
    def write(self, destination):
        """
        Writes overlay file to desired location.

        @params destination: path & file to write xml to.
        @rtype bool: reflects success or failure to write xml.
        """
        if not destination:
            filepath = self.config.get_option("overlay_defs")
            if self.sudo:
                filepath = get_input("Desired file destination dir: ")
            filename = get_input("Desired overlay file name: ")

            if not filename.endswith(".xml"):
                filename += ".xml"

            if not filepath.endswith(os.path.sep):
                filepath += os.path.sep

            destination = filepath + filename

        self.tree = ET.Element("repositories", version="1.1", encoding=_UNICODE)

        if os.path.isfile(destination):
            self.read(destination)

        self._sort_to_tree()
        indent(self.tree)
        self.tree = ET.ElementTree(self.tree)

        try:
            with fileopen(destination, "w") as xml:
                self.tree.write(xml, encoding=_UNICODE)
            msg = "Successfully wrote repo(s) to: %(path)s" % ({"path": destination})
            self.output.info(msg)
            return True

        except IOError as e:
            raise Exception("Writing XML failed: %(error)s" % ({"error": e}))
示例#21
0
    def get_description(self):
        '''
        Prompts user for an overlay's description(s)
        and updates overlay dict with value(s).
        '''
        #TODO: Currently a "stub" function. Add multiple description
        # field support later down the road.
        descriptions = []

        desc = get_input('Define overlay\'s description: ')
        descriptions.append(desc)

        self.overlay['description'] = descriptions
示例#22
0
    def __call__(self, overlay_package=None, path=None):

        if not overlay_package:
            self.args_parser()
            options = {}
            for key in vars(self.args):
                options[key] = vars(self.args)[key]
            self.config = OptionConfig(options=options)
            reload_config(self.config)

            self.auto_complete = False
            self.list_info = self.config.get_option('list_autocomplete')
            self.no_extra = self.config.get_option('no_extra')
            self.sudo = self.config.get_option('sudo')

            if self.list_info:
                self.list_templates()

            if self.args.set_autocomplete:
                if 'ALL' in self.args.set_autocomplete:
                    self.templates = AUTOCOMPLETE_TEMPLATE.keys()
                    self.auto_complete = True
                else:
                    self.templates = self.args.set_autocomplete
                    self.auto_complete = True

            msg = 'How many overlays would you like to create?: '
            for x in range(1, int(get_input(msg)) + 1):
                self.output.notice('')
                self.output.info('Overlay #%(x)s: ' % ({'x': str(x)}))
                self.output.info('~~~~~~~~~~~~~')

                self.required = copy.deepcopy(COMPONENT_DEFAULTS)

                if not self.no_extra:
                    self.output.notice('')
                    self.update_required()
                    self.output.notice('')

                self.get_overlay_components()
                ovl = Overlay.Overlay(config=self.config,
                                      ovl_dict=self.overlay,
                                      ignore=1)
                self.overlays.append((self.overlay['name'], ovl))
        else:
            ovl_name, ovl = overlay_package
            self.overlays.append((ovl_name, ovl))

        result = self.write(path)
        return result
示例#23
0
文件: maker.py 项目: dewey/layman
    def __call__(self, overlay_package=None, path=None):

        if not overlay_package:
            self.args_parser()
            options = {}
            for key in vars(self.args):
                options[key] = vars(self.args)[key]
            self.config = OptionConfig(options=options)
            reload_config(self.config)

            self.auto_complete = False
            self.list_info     = self.config.get_option('list_autocomplete')
            self.no_extra      = self.config.get_option('no_extra')
            self.sudo          = self.config.get_option('sudo')

            if self.list_info:
                self.list_templates()

            if self.args.set_autocomplete:
                if 'ALL' in self.args.set_autocomplete:
                    self.templates = AUTOCOMPLETE_TEMPLATE.keys()
                    self.auto_complete = True
                else:
                    self.templates = self.args.set_autocomplete
                    self.auto_complete = True

            msg = 'How many overlays would you like to create?: '
            for x in range(1, int(get_input(msg))+1):
                self.output.notice('')
                self.output.info('Overlay #%(x)s: ' % ({'x': str(x)}))
                self.output.info('~~~~~~~~~~~~~')

                self.required = copy.deepcopy(COMPONENT_DEFAULTS)

                if not self.no_extra:
                    self.output.notice('')
                    self.update_required()
                    self.output.notice('')

                self.get_overlay_components()
                ovl = Overlay.Overlay(config=self.config, ovl_dict=self.overlay, ignore=1)
                self.overlays.append((self.overlay['name'], ovl))
        else:
            ovl_name, ovl = overlay_package
            self.overlays.append((ovl_name, ovl))

        result = self.write(path)
        return result
示例#24
0
    def get_source(self):
        """
        Prompts user for possible overlay source
        information such as type, url, and branch
        and then appends the values to the overlay
        being created.
        """
        ovl_type = None

        if self.auto_complete:
            source_amount = 1
        else:
            msg = "How many different sources, protocols, or mirrors exist " "for this overlay?: "
            source_amount = int(get_input(msg))

        self.overlay["source"] = []

        for i in range(1, source_amount + 1):
            sources = []
            correct = False
            if source_amount > 1:
                msg = "Define source[%(i)s]'s URL: " % ({"i": str(i)})
                sources.append(get_input(msg))

                ovl_type = self.guess_overlay_type(sources[0])
                if ovl_type:
                    msg = 'Is "%(type)s" the correct overlay type?: ' % ({"type": ovl_type})
                    correct = get_ans(msg)
                while not ovl_type or not correct:
                    msg = "Please provide overlay type: "
                    ovl_type = self.check_overlay_type(get_input(msg, color="yellow"))
                    correct = True

                sources.append(ovl_type)
                if "branch" in self.required:
                    msg = "Define source[%(i)s]'s branch (if applicable): " % ({"i": str(i)})
                    sources.append(get_input(msg))
                else:
                    sources.append("")
            else:
                sources.append(get_input("Define source URL: "))

                ovl_type = self.guess_overlay_type(sources[0])
                if ovl_type:
                    msg = "Is %(type)s the correct overlay type?: " % ({"type": ovl_type})
                    correct = get_ans(msg)
                while not ovl_type or not correct:
                    msg = "Please provide overlay type: "
                    ovl_type = self.check_overlay_type(get_input(msg, color="yellow"))
                    correct = True

                sources.append(ovl_type)
                if "branch" in self.required:
                    msg = "Define source branch (if applicable): "
                    sources.append(get_input(msg))
                else:
                    sources.append("")
            if self.auto_complete:
                sources = self._set_additional_info(sources)
                for source in sources:
                    self.overlay["source"].append(source)
            else:
                self.overlay["source"].append(sources)
        self.output.notice("")