当前位置: 首页>>代码示例>>Python>>正文


Python rhnLog.log_clean函数代码示例

本文整理汇总了Python中spacewalk.common.rhnLog.log_clean函数的典型用法代码示例。如果您正苦于以下问题:Python log_clean函数的具体用法?Python log_clean怎么用?Python log_clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log_clean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: clone

    def clone(self):
        errata_ids = [e["advisory_name"] for e in self.errata_to_clone]
        if len(errata_ids) == 0:
            return

        msg = 'Cloning Errata into %s (%i):' % (self.to_label, len(errata_ids))
        print msg
        log_clean(0, "")
        log_clean(0, msg)
        for e in self.errata_to_clone:
            log_clean(0, "%s - %s" % (e['advisory_name'], e['synopsis']))

        pb = ProgressBar(prompt="", endTag=' - complete',
                         finalSize=len(errata_ids), finalBarLength=40,
                         stream=sys.stdout)
        pb.printAll(1)
        while(len(errata_ids) > 0):
            errata_set = errata_ids[:self.bunch_size]
            del errata_ids[:self.bunch_size]
            self.remote_api.clone_errata(self.to_label, errata_set)
            pb.addTo(self.bunch_size)
            pb.printIncrement()

        self.reset_new_pkgs()
        pb.printComplete()

        if not self.no_errata_sync:
            log_clean(0, "")
            log_clean(0, "Synchronizing Errata in %s with originals"
                      % self.to_label)
            self.remote_api.sync_errata(self.to_label)
开发者ID:mantel,项目名称:spacewalk,代码行数:31,代码来源:cloneByDate.py

示例2: clone_channel

    def clone_channel(self, original_label, new_label, parent):
        self.auth_check()
        details = {'name': new_label, 'label':new_label, 'summary': new_label}
        if parent and parent != '':
            details['parent_label'] = parent

        msg = "Cloning %s to %s with original package set." % (original_label, new_label)
        log_clean(0, "")
        log_clean(0, msg)
        print(msg)
        self.client.channel.software.clone(self.auth_token, original_label, details, True)
开发者ID:dmacvicar,项目名称:spacewalk,代码行数:11,代码来源:cloneByDate.py

示例3: process_deps

    def process_deps(self, needed_pkgs):
        needed_ids = []
        needed_names = []
        unsolved_deps = []
        for pkg in needed_pkgs:
            found = self.src_pkg_exist([pkg])
            if found:
                needed_ids.append(found['id'])
                needed_names.append(found['nvrea'])
            else:
                unsolved_deps.append(pkg)

        needed_errata = []
        still_needed_pids = []
        for pid in needed_ids:
            if pid not in self.original_pid_errata_map:
                errata_list = self.remote_api.list_providing_errata(pid)
                for erratum in errata_list:
                    if erratum['advisory'] in self.original_errata:
                        self.original_pid_errata_map[pid] = \
                                erratum['advisory']
                        break
                else: # no match found, store so we don't repeat search
                    self.original_pid_errata_map[pid] = None
            if self.original_pid_errata_map[pid] != None:
                needed_errata.append(self.original_pid_errata_map[pid])
            else:
                still_needed_pids.append(pid)
        needed_ids = still_needed_pids

        for name in needed_names:
            log_clean(0, name)
        if len(needed_errata) > 0:
            log_clean(0, "")
            log_clean(0, "Cloning %i errata for dependencies to %s" %
                    (len(needed_errata), self.to_label))
        while(len(needed_errata) > 0):
            errata_set = needed_errata[:self.bunch_size]
            del needed_errata[:self.bunch_size]
            if self.detached:
                self.remote_api.clone_errata_async(self.to_label, errata_set)
            else:
                self.remote_api.clone_errata(self.to_label, errata_set)

        if len(needed_ids) > 0:
            log_clean(0, "")
            log_clean(0, "Adding %i needed dependencies to %s" %
                    (len(needed_ids), self.to_label))
            self.remote_api.add_packages(self.to_label, needed_ids)

        self.reset_new_pkgs()
        return needed_names
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:52,代码来源:cloneByDate.py

示例4: log2disk

def log2disk(level, msg, cleanYN=0, notimeYN=0):
    """Log to a log file.
    Arguments: see def _prepLogMsg(...) above.
    """
    if not isinstance(msg, type([])):
        msg = [msg]
    for m in msg:
        try:
            log_clean(level=level, msg=_prepLogMsg(m, cleanYN, notimeYN))
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception, e:  # pylint: disable=E0012, W0703
            sys.stderr.write('ERROR: upon attempt to write to log file: %s' % e)
开发者ID:Bearlock,项目名称:spacewalk,代码行数:13,代码来源:syncLib.py

示例5: log2disk

def log2disk(level, msg, cleanYN=0, notimeYN=0):
    """Log to a log file.
    Arguments: see def _prepLogMsg(...) above.
    """
    if type(msg) != type([]):
        msg = [msg]
    for m in msg:
        try:
            log_clean(level=level, msg=_prepLogMsg(m, cleanYN, notimeYN))
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception, e:
            sys.stderr.write("ERROR: upon attempt to write to log file: %s" % e)
开发者ID:pgervase,项目名称:spacewalk,代码行数:13,代码来源:syncLib.py

示例6: process_deps

    def process_deps(self, needed_pkgs):
        needed_ids = []
        needed_names = []
        for pkg in needed_pkgs:
            found = self.src_pkg_exist([pkg])
            if found:
                needed_ids.append(found['id'])
                needed_names.append(found['nvrea'])

        needed_errata = []
        still_needed_pids = []
        for pid in needed_ids:
            if pid not in self.original_pid_errata_map:
                errata_list = self.remote_api.list_providing_errata(pid)
                for erratum in errata_list:
                    if erratum['advisory'] in self.original_errata:
                        if not self.to_date or (self.to_date and \
    datetime.datetime(*time.strptime(erratum[self.use_update_date], '%Y-%m-%d %H:%M:%S')[0:6]).date() <= \
    self.to_date.date()):
                            self.original_pid_errata_map[pid] = erratum['advisory']
                            break
                else:  # no match found, store so we don't repeat search
                    self.original_pid_errata_map[pid] = None
            if self.original_pid_errata_map[pid] != None:
                needed_errata.append(self.original_pid_errata_map[pid])
            else:
                still_needed_pids.append(pid)
        needed_ids = still_needed_pids

        for name in needed_names:
            log_clean(0, name)
        if len(needed_errata) > 0:
            log_clean(0, "")
            log_clean(0, "Cloning %i errata for dependencies to %s" %
                      (len(needed_errata), self.to_label))
        while(len(needed_errata) > 0):
            errata_set = needed_errata[:self.bunch_size]
            del needed_errata[:self.bunch_size]
            self.remote_api.clone_errata(self.to_label, errata_set)

        if len(needed_ids) > 0:
            log_clean(0, "")
            log_clean(0, "Adding %i needed dependencies to %s" %
                      (len(needed_ids), self.to_label))
            self.remote_api.add_packages(self.to_label, needed_ids)

        self.reset_new_pkgs()
        return needed_names
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:48,代码来源:cloneByDate.py

示例7: clone_channel

    def clone_channel(self, original_label, channel, parent):
        self.auth_check()
        details = {'name': channel[0], 'label': channel[0],
                   'summary': channel[0]}
        if len(channel) > 1:
            details['name'] = channel[1]
        if len(channel) > 2:
            details['summary'] = channel[2]
        if len(channel) > 3:
            details['description'] = channel[3]
        if parent and parent != '':
            details['parent_label'] = parent

        msg = "Cloning %s to %s with original package set." % (original_label,
                                                               details['label'])
        log_clean(0, "")
        log_clean(0, msg)
        print(msg)
        self.client.channel.software.clone(self.auth_token, original_label,
                                           details, True)
开发者ID:mantel,项目名称:spacewalk,代码行数:20,代码来源:cloneByDate.py

示例8: __remove_packages

    def __remove_packages(self, names_dict, pkg_list, name):
        """Base removal of packages
            names_dict  - dict containing  list of package names, with channel
                          lables as keys
            pkg_list  -  list of package dicts to consider
            name   - name of removal  'blacklist' or 'removelist', for display
        """
        found_ids = []
        found_names = []
        if not names_dict:
            return

        full_pkgs = []
        if names_dict.has_key("ALL"):
            full_pkgs += names_dict["ALL"]
        if names_dict.has_key(self.dest_label()):
            full_pkgs += names_dict[self.dest_label()]

        #add dollar signs to each one, other wise  foo would match foobar
        reg_ex = re.compile("$|".join(full_pkgs) + '$')
        for pkg in pkg_list:
            if reg_ex.match(pkg['name']):
                found_ids.append(pkg['id'])
                found_names.append(pkg['nvrea'])

        log_clean(0, "")
        log_clean(0, "%s: Removing %i packages from %s." %
                  (name, len(found_ids), self.to_label))
        log_clean(0, "\n".join(found_names))

        if len(found_ids) > 0:
            print "%s: Removing %i packages from %s" % (name, len(found_ids),
                                                        self.to_label)
            self.remote_api.remove_packages(self.to_label, found_ids)
开发者ID:mantel,项目名称:spacewalk,代码行数:34,代码来源:cloneByDate.py

示例9: clone

 def clone(self, skip_depsolve=False):
     added_pkgs = []
     for cloner in self.cloners:
         cloner.process()
         pkg_diff = cloner.pkg_diff()
         added_pkgs += pkg_diff
         log_clean(0, "")
         log_clean(0, "%i packages were added to %s as a result of clone:" % (len(pkg_diff), cloner.dest_label()))
         log_clean(0, "\n".join([pkg['nvrea'] for pkg in pkg_diff]))
     if len(added_pkgs) > 0 and not skip_depsolve:
         self.dep_solve([pkg['nvrea'] for pkg in added_pkgs])
开发者ID:dmacvicar,项目名称:spacewalk,代码行数:11,代码来源:cloneByDate.py

示例10: process_deps

    def process_deps(self, needed_pkgs):
        needed_ids = []
        needed_names = []
        unsolved_deps = []
        for pkg in needed_pkgs:
            found = self.src_pkg_exist([pkg])
            if found:
                needed_ids.append(found['id'])
                needed_names.append(found['nvrea'])
            else:
                unsolved_deps.append(pkg)

        if len(needed_ids) > 0:
            log_clean(0, "")
            log_clean(0, "Adding %i needed dependencies to %s" % (len(needed_ids), self.to_label))
            for name in needed_names:
                log_clean(0, name)
            self.remote_api.add_packages(self.to_label, needed_ids)
开发者ID:dmacvicar,项目名称:spacewalk,代码行数:18,代码来源:cloneByDate.py

示例11: print_msg

 def print_msg(self, message):
     rhnLog.log_clean(0, message)
     if not self.quiet:
         print(message)
开发者ID:u-s-p,项目名称:spacewalk,代码行数:4,代码来源:reposync.py

示例12: main

def main(options):
    xmlrpc = RemoteApi(options.server, options.username, options.password)
    db = DBApi()
    initCFG('server')
    rhnLog.initLOG(LOG_LOCATION)

    cleansed = vars(options)
    cleansed["password"] = "*****"
    log_clean(0, "")
    log_debug(0, "Started spacewalk-clone-by-date")
    log_clean(0, pprint.pformat(cleansed))

    print "Reading repository information."
    if options.use_update_date:
        options.use_update_date = 'update_date'
    else:
        options.use_update_date = 'issue_date'
    print "Using %s." % options.use_update_date

    cloners = []
    needed_channels = []
    errata = None
    if options.errata:
        errata = set(options.errata)
    for channel_list in options.channels:
        parents = None
        if options.parents:
            # if only the dest parent is specified, look up the src parent
            if len(options.parents) == 1:
                src_parent = xmlrpc.get_original(options.parents[0])
                if not src_parent:
                    print ("Channel %s is not a cloned channel." % options.parents[0])
                    sys.exit(1)
                print "Looking up the original channel for %s, %s found" % (
                    options.parents[0], src_parent)
                options.parents = [src_parent] + options.parents
            # options.parents is only set by command line, this must be the
            # only channel tree
            parents = options.parents

        # Handle the new-style channel specification that uses
        # key value pairs. Transform into channel / parent setup that
        # ChannelTreeCloner expects. This code has to be here now that you can
        # specify parents for multiple trees.
        # TODO: the channel / parents structure needs to be cleaned up throught
        # clone-by-date. Probably best thing would to make everywhere use the
        # dict structure instead of the list structure.
        for src_channel in channel_list.keys():
            dest_channel = channel_list[src_channel]
            # new-style config file channel specification
            if type(dest_channel) == dict:
                if 'label' not in dest_channel:
                    raise UserError("You must specify a label for the clone of %s" % src_channel)
                label = dest_channel['label']
                if 'name' in dest_channel:
                    name = dest_channel['name']
                else:
                    name = label
                if 'summary' in dest_channel:
                    summary = dest_channel['summary']
                else:
                    summary = label
                if 'description' in dest_channel:
                    description = dest_channel['description']
                else:
                    description = label
                # This is the options.parents equivalent for config files.
                # Add channels to parents option and remove from channels.
                if ('existing-parent-do-not-modify' in dest_channel
                        and dest_channel['existing-parent-do-not-modify']):
                    parents = [src_channel, label]
                    del channel_list[src_channel]
                else:  # else tranform channel_list entry to the list format
                    channel_list[src_channel] = [label, name, summary,
                                                 description]

        # before we start make sure we can get repodata for all channels
        # involved.
        channel_labels = channel_list.keys()
        for label in channel_labels:
            if not os.path.exists(repodata(label)):
                raise UserRepoError(label)
        # ensure the parent's channel metadata is available
        if parents:
            for label in parents:
                if not os.path.exists(repodata(label)):
                    raise UserRepoError(label)

        # if cloning specific errata validate that they actually exist
        # in the original channels
        if options.errata:
            for channel in channel_labels:
                channel_errata = set(xmlrpc.list_errata(channel))
                if len(errata - channel_errata) != 0:
                    print ("Error: all errata specified with --errata must "
                           + "exist in every original channel cloned in "
                           + "this operation.")
                    print ("Channel %s does not contain these errata: %s" %
                           (channel, errata - channel_errata))
                    sys.exit(1)
#.........这里部分代码省略.........
开发者ID:mantel,项目名称:spacewalk,代码行数:101,代码来源:cloneByDate.py

示例13: main

def main(options):
    xmlrpc = RemoteApi(options.server, options.username, options.password)
    db = DBApi()
    initCFG('server')
    rhnLog.initLOG(LOG_LOCATION)

    cleansed = vars(options)
    cleansed["password"] = "*****"
    log_clean(0, "")
    log_debug(0, "Started spacewalk-clone-by-date")
    log_clean(0, pprint.pformat(cleansed))


    print "Reading repository information."
    if options.use_update_date:
        options.use_update_date = 'update_date'
    else:
        options.use_update_date = 'issue_date'
    print "Using %s." % options.use_update_date

    cloners = []
    needed_channels = []
    errata = None
    if options.errata:
        errata = set(options.errata)
    for channel_list in options.channels:
        # before we start make sure we can get repodata for all channels
        # involved.
        channel_labels = channel_list.keys()
        for label in channel_labels:
            if not os.path.exists(repodata(label)):
                raise UserRepoError(label)

        # if cloning specific errata validate that they actually exist
        # in the original channels
        if options.errata:
            for channel in channel_labels:
                channel_errata = set(xmlrpc.list_errata(channel))
                if len(errata - channel_errata) != 0:
                    print ("Error: all errata specified with --errata must "
                            + "exist in every original channel cloned in "
                            + "this operation.")
                    print ("Channel %s does not contain these errata: %s" %
                            (channel, errata - channel_errata))
                    sys.exit(1)

        if options.parents:
            tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db,
                    options.to_date, options.blacklist,
                    options.removelist, options.background,
                    options.security_only, options.use_update_date,
                    options.no_errata_sync, errata, options.parents)
        else:
            tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db,
                    options.to_date, options.blacklist,
                    options.removelist, options.background,
                    options.security_only,options.use_update_date,
                    options.no_errata_sync, errata)

        cloners.append(tree_cloner)
        needed_channels += tree_cloner.needing_create().values()


    if options.validate:
        if len(needed_channels) > 0:
            raise UserError("Cannot validate channels that do not exist %s" %
                    ', '.join(map(str, needed_channels)))
        for channel_list in options.channels:
            validate(channel_list.values())
        return


    if len(needed_channels) > 0:
        print "\nBy continuing the following channels will be created: "
        print ", ".join(needed_channels)
        confirm("\nContinue with channel creation (y/n)?", options)
        for cloner in cloners:
            cloner.create_channels(options.skip_depsolve)

    for tree_cloner in cloners:
        tree_cloner.prepare()

    print "\nBy continuing the following will be cloned:"
    total = 0
    for cloner in cloners:
        cloner.pre_summary()
        total += cloner.pending()

    if total == 0:
        print ("\nNo errata to clone, checking removelist.")
        for cloner in cloners:
            cloner.remove_packages()
        sys.exit(0)

    confirm("\nContinue with clone (y/n)?", options)
    for cloner in cloners:
        cloner.clone(options.skip_depsolve)
        cloner.remove_packages()
开发者ID:cesan3,项目名称:spacewalk,代码行数:98,代码来源:cloneByDate.py

示例14: process_deps

    def process_deps(self, needed_pkgs):
        needed_ids = []
        needed_names = set()
        for pkg in needed_pkgs:
            found = self.src_pkg_exist([pkg])
            if found:
                needed_ids.append(found['id'])
                needed_names.add(found['nvrea'])

        needed_errata = set() # list, [0] = advisory, [1] = synopsis
        still_needed_pids = []
        for pid in needed_ids:
            if pid not in self.original_pid_errata_map:
                errata_list = self.remote_api.list_providing_errata(pid)
                for erratum in errata_list:
                    if erratum['advisory'] in self.original_errata:
                        self.original_pid_errata_map[pid] = \
                            erratum['advisory']
                        needed_errata.add((self.original_pid_errata_map[pid], erratum['synopsis']))
                        break
                else:  # no match found, store so we don't repeat search
                    self.original_pid_errata_map[pid] = None
                    still_needed_pids.append(pid)
        needed_ids = still_needed_pids

        # Log the RPMs we're adding due to dep-solving
        needed_name_set = sorted(set(needed_names))
        if len(needed_name_set) > 0:
            log_clean(0, "")
            log_clean(0, "Adding %i RPM(s) needed for dependencies to %s" % (len(needed_name_set), self.to_label))
            for name in needed_name_set:
                log_clean(0, name)

        # Clone (and log) the errata we are adding for same
        if len(needed_errata) > 0:
            self.total_added_errata += len(needed_errata)
            log_clean(0, "")
            log_clean(0, "Cloning %i errata for dependencies to %s :" % (len(needed_errata), self.to_label))
            needed_errata_list = sorted(list(needed_errata))
            while(len(needed_errata_list) > 0):
                errata_set = needed_errata_list[:self.bunch_size]
                del needed_errata_list[:self.bunch_size]
                for e in errata_set:
                    log_clean(0, "%s - %s" % e)
                    if not self.skip_errata_depsolve:
                        e_pkgs = self.remote_api.get_erratum_packages(e[0])
                    else:
                        e_pkgs = []

                    for pkg in e_pkgs:
                        if self.from_label in pkg['providing_channels']:
                            pkg['nvrea'] = "%s-%s-%s.%s" % (pkg['name'],
                                                            pkg['version'],
                                                            pkg['release'],
                                                            pkg['arch_label'])
                            needed_names.add(pkg['nvrea'] )
                self.remote_api.clone_errata(self.to_label, [e[0] for e in errata_set])

        if len(needed_ids) > 0:
            self.remote_api.add_packages(self.to_label, needed_ids)

        self.reset_new_pkgs()
        return needed_names
开发者ID:lhellebr,项目名称:spacewalk,代码行数:63,代码来源:cloneByDate.py

示例15: error_msg

 def error_msg(self, message):
     rhnLog.log_clean(0, message)
     if not self.quiet:
         sys.stderr.write(str(message) + "\n")
开发者ID:u-s-p,项目名称:spacewalk,代码行数:4,代码来源:reposync.py


注:本文中的spacewalk.common.rhnLog.log_clean函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。