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


Python syncLib.log函数代码示例

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


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

示例1: endContainerCallback

 def endContainerCallback(self):
     arches = self.arches.keys()
     arches.sort()
     if arches:
         for arch in arches:
             syncLib.log(6, '   parsed arch: %s' % (arch))
     diskImportLib.ChannelPackageArchCompatContainer.endContainerCallback(self)
开发者ID:T-D-Oe,项目名称:spacewalk,代码行数:7,代码来源:sync_handlers.py

示例2: _rpc_call

 def _rpc_call(self, function_name, params):
     get_server_obj = self.login()
     # Try a couple of times
     cfg = config.initUp2dateConfig()
     for i in range(cfg["networkRetries"]):
         try:
             ret = apply(getattr(get_server_obj, function_name), params)
         except rpclib.ProtocolError, e:
             # We have two codes to check: the HTTP error code, and the
             # combination (failtCode, faultString) encoded in the headers
             # of the request.
             http_error_code = e.errcode
             fault_code, fault_string = rpclib.reportError(e.headers)
             if http_error_code == 401 and fault_code == -34:
                 # Login token expired
                 get_server_obj = self.login(force=1)
                 continue
             if http_error_code == 404 and fault_code == -17:
                 # File not found
                 self.extinctErrorYN = 1
                 return None
             log(-1, "ERROR: http error code :%s; fault code: %s; %s" % (http_error_code, fault_code, fault_string))
             # XXX
             raise
         else:
             return ret
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:26,代码来源:xmlWireSource.py

示例3: import_channels

def import_channels(channels, orgid=None, master=None):
    collection = ChannelCollection()
    batch = []
    import satCerts
    orgs = map(lambda a: a['id'], satCerts.get_all_orgs())
    org_map = None
    my_backend = diskImportLib.get_backend()
    if master:
        org_map = my_backend.lookupOrgMap(master)['master-id-to-local-id']
    for c in channels:
        try:
            timestamp = collection.get_channel_timestamp(c)
        except KeyError:
            raise Exception, "Could not find channel %s" % c, sys.exc_info()[2]
        c_obj = collection.get_channel(c, timestamp)
        if c_obj is None:
            raise Exception, "Channel not found in cache: %s" % c

        # Check to see if we're asked to sync to an orgid,
        # make sure the org from the export is not null org,
        # finally if the orgs differ so we might wanna use
        # requested org's channel-family.
        # TODO: Move these checks somewhere more appropriate
        if not orgid and c_obj['org_id'] is not None:
            #If the src org is not present default to org 1
            orgid = DEFAULT_ORG
        if orgid is not None and c_obj['org_id'] is not None and \
            c_obj['org_id'] != orgid:
            #If we know the master this is coming from and the master org
            #has been mapped to a local org, transform org_id to the local
            #org_id. Otherwise just put it in the default org.
            if (org_map and c_obj['org_id'] in org_map.keys()
                    and org_map[c_obj['org_id']]):
                c_obj['org_id'] = org_map[c_obj['org_id']]
            else:
                c_obj['org_id'] = orgid
                if c_obj.has_key('trust_list'):
                    del(c_obj['trust_list'])
            for family in c_obj['families']:
                family['label'] = 'private-channel-family-' + \
                                           str(c_obj['org_id'])
        # If there's a trust list on the channel, transform the org ids to
        # the local ones
        if c_obj.has_key('trust_list') and c_obj['trust_list']:
            trusts = []
            for trust in c_obj['trust_list']:
                if org_map.has_key(trust['org_trust_id']):
                    trust['org_trust_id'] = org_map[trust['org_trust_id']]
                    trusts.append(trust)
            c_obj['trust_list'] = trusts

        syncLib.log(6, "Syncing Channel %s to Org %s " % \
                       (c_obj['label'], c_obj['org_id']))
        batch.append(c_obj)

    importer = channelImport.ChannelImport(batch, my_backend)
    # Don't commit just yet
    importer.will_commit = 0
    importer.run()
    return importer
开发者ID:T-D-Oe,项目名称:spacewalk,代码行数:60,代码来源:sync_handlers.py

示例4: _rpc_call

 def _rpc_call(self, function_name, params):
     get_server_obj = self.login()
     # Try a couple of times
     fault_count = 0
     expired_token = 0
     cfg = config.initUp2dateConfig()
     while fault_count - expired_token < cfg['networkRetries']:
         try:
             ret = getattr(get_server_obj, function_name)(*params)
         except rpclib.xmlrpclib.ProtocolError:
             e = sys.exc_info()[1]
             # We have two codes to check: the HTTP error code, and the
             # combination (failtCode, faultString) encoded in the headers
             # of the request.
             http_error_code = e.errcode
             fault_code, fault_string = rpclib.reportError(e.headers)
             fault_count += 1
             if http_error_code == 401 and fault_code == -34:
                 # Login token expired
                 get_server_obj = self.login(force=1)
                 # allow exactly one respin for expired token
                 expired_token = 1
                 continue
             if http_error_code == 404 and fault_code == -17:
                 # File not found
                 self.extinctErrorYN = 1
                 return None
             log(-1, 'ERROR: http error code :%s; fault code: %s; %s' %
                 (http_error_code, fault_code, fault_string))
             # XXX
             raise
         else:
             return ret
     raise Exception("Failed after multiple attempts!")
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:34,代码来源:xmlWireSource.py

示例5: download

 def download(self):
     self.setServer(CFG.RHN_XMLRPC_HANDLER)
     #log(2, '   +++ Satellite synchronization tool downloading certificate.')
     try:
         cert = self._xmlrpc("certificate.download", (self.systemid, ))
     except rpclib.xmlrpclib.Fault, e:
         log(-1, '   --- Unable to download the satellite certificate')
         log(-1, '   ERROR: %s' % e, stream=sys.stderr)
         sys.exit(-1)
开发者ID:cliffy94,项目名称:spacewalk,代码行数:9,代码来源:xmlWireSource.py

示例6: purge_extra_channel_families

def purge_extra_channel_families():
    # Get rid of the extra channel families
    try:
        # Purge all unused private channel families with null org
        h = rhnSQL.prepare(_query_purge_private_channel_families)
        h.execute()
    except rhnSQL.SQLError, e:
        # Log it and move on - maybe we missed a FK; no reason to break the
        # sync completely for this.
        syncLib.log(-1, str(e))
开发者ID:T-D-Oe,项目名称:spacewalk,代码行数:10,代码来源:sync_handlers.py

示例7: checkAuth

 def checkAuth(self):
     self.setServer(CFG.RHN_XMLRPC_HANDLER)
     authYN = None
     log(2, "   +++ Satellite synchronization tool checking in.")
     try:
         authYN = self._xmlrpc("authentication.check", (self.systemid,))
     except (rpclib.ProtocolError, rpclib.Fault), e:
         # bug 141197: the logging of all exceptions is handled higher up in
         # the call stack
         #            log2(-1, 1, '   ERROR: %s' % e, stream=sys.stderr)
         raise
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:11,代码来源:xmlWireSource.py

示例8: _xmlrpc

 def _xmlrpc(function, params):
     try:
         retval = getattr(BaseWireSource.serverObj, function)(*params)
     except TypeError:
         e = sys.exc_info()[1]
         log(-1, 'ERROR: during "getattr(BaseWireSource.serverObj, %s)(*(%s))"' % (function, params))
         raise
     except rpclib.xmlrpclib.ProtocolError:
         e = sys.exc_info()[1]
         log2(-1, 2, 'ERROR: ProtocolError: %s' % e, stream=sys.stderr)
         raise
     return retval
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:12,代码来源:xmlWireSource.py

示例9: import_channels

def import_channels(channels, orgid=None):
    collection = ChannelCollection()
    batch = []
    import satCerts
    orgs = map(lambda a: a['id'], satCerts.get_all_orgs())
    for c in channels:
        try:
            timestamp = collection.get_channel_timestamp(c)
        except KeyError:
            raise Exception, "Could not find channel %s" % c
        c_obj = collection.get_channel(c, timestamp)
        if c_obj is None:
            raise Exception, "Channel not found in cache: %s" % c

        # Check to see if we're asked to sync to an orgid,
        # make sure the org from the export is not null org,
        # finally if the orgs differ so we might wanna use
        # requested org's channel-family.
        # TODO: Move these checks somewhere more appropriate
        if not orgid and c_obj['org_id'] is not None:
            #If the src org is not present default to org 1
            orgid = DEFAULT_ORG
        if orgid is not None and c_obj['org_id'] is not None and \
            c_obj['org_id'] != orgid:
            #Only set the channel family if its a custom channel
            c_obj['org_id'] = orgid
            for family in c_obj['families']:
                family['label'] = 'private-channel-family-' + \
                                           str(c_obj['org_id'])

        syncLib.log(6, "Syncing Channel %s to Org %s " % \
                       (c_obj['label'], c_obj['org_id']))
        batch.append(c_obj)

    importer = channelImport.ChannelImport(batch, diskImportLib.get_backend())
    # Don't commit just yet
    importer.will_commit = 0
    importer.run()
    return importer
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:39,代码来源:sync_handlers.py

示例10: _set_ssl_trusted_certs

    def _set_ssl_trusted_certs(self, serverObj):
        if not self.sslYN:
            return None

        # Check certificate
        if CFG.ISS_PARENT:
            caChain = CFG.ISS_CA_CHAIN
        else:
            caChain = CFG.CA_CHAIN
        if caChain:
            # require RHNS-CA-CERT file to be able to authenticate the SSL
            # connections.
            if not os.access(caChain, os.R_OK):
                message = "ERROR: can not find RHN CA file: %s" % caChain
                log(-1, message, stream=sys.stderr)
                raise Exception(message)
            # force the validation of the SSL cert
            serverObj.add_trusted_cert(caChain)
            return caChain

        message = '--- Warning: SSL connection made but no CA certificate used'
        log(1, message, stream=sys.stderr)
        return None
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:23,代码来源:xmlWireSource.py

示例11: import_groups

    def import_groups(self, plug, url):
        groupsfile = plug.get_groups()
        if groupsfile:
            basename = os.path.basename(groupsfile)
            log(0, "Repo %s has comps file %s." % (url, basename))
            relativedir = os.path.join(relative_comps_dir, self.channel_label)
            absdir = os.path.join(CFG.MOUNT_POINT, relativedir)
            if not os.path.exists(absdir):
                os.makedirs(absdir)
            relativepath = os.path.join(relativedir, basename)
            abspath = os.path.join(absdir, basename)
            for suffix in ['.gz', '.bz', '.xz']:
                if basename.endswith(suffix):
                    abspath = abspath.rstrip(suffix)
                    relativepath = relativepath.rstrip(suffix)
            src = fileutils.decompress_open(groupsfile)
            dst = open(abspath, "w")
            shutil.copyfileobj(src, dst)
            dst.close()
            src.close()
            # update or insert
            hu = rhnSQL.prepare("""update rhnChannelComps
                                      set relative_filename = :relpath,
                                          modified = current_timestamp
                                    where channel_id = :cid""")
            hu.execute(cid=self.channel['id'], relpath=relativepath)

            hi = rhnSQL.prepare("""insert into rhnChannelComps
                                  (id, channel_id, relative_filename)
                                  (select sequence_nextval('rhn_channelcomps_id_seq'),
                                          :cid,
                                          :relpath
                                     from dual
                                    where not exists (select 1 from rhnChannelComps
                                                       where channel_id = :cid))""")
            hi.execute(cid=self.channel['id'], relpath=relativepath)
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:36,代码来源:reposync.py

示例12: checkAuth

 def checkAuth(self):
     self.setServer(CFG.RHN_XMLRPC_HANDLER)
     authYN = None
     log(2, '   +++ SUSE Manager Server synchronization tool checking in.')
     try:
         authYN = self._xmlrpc('authentication.check', (self.systemid,))
     except (rpclib.xmlrpclib.ProtocolError, rpclib.xmlrpclib.Fault):
         raise
     if authYN:
         log(2, '   +++ Entitled SUSE Manager Server validated.', stream=sys.stderr)
     elif authYN is None:
         log(-1, '   --- An error occurred upon authentication of this SUSE Manager Server -- '
                 'review the pertinent log file (%s) and/or submit a service request.' % CFG.LOG_FILE,
             stream=sys.stderr)
         sys.exit(-1)
     elif authYN == 0:
         log(-1, '   --- This server is not entitled.', stream=sys.stderr)
         sys.exit(-1)
     return authYN
开发者ID:m47ik,项目名称:uyuni,代码行数:19,代码来源:xmlWireSource.py

示例13: upload_updates

    def upload_updates(self, notices):
        batch = []
        typemap = {
            'security': 'Security Advisory',
            'recommended': 'Bug Fix Advisory',
            'bugfix': 'Bug Fix Advisory',
            'optional': 'Product Enhancement Advisory',
            'feature': 'Product Enhancement Advisory',
            'enhancement': 'Product Enhancement Advisory'
        }
        for notice in notices:
            notice = self.fix_notice(notice)
            advisory = notice['update_id'] + '-' + notice['version']
            existing_errata = self.get_errata(notice['update_id'])

            e = Erratum()
            e['errata_from'] = notice['from']
            e['advisory'] = advisory
            e['advisory_name'] = notice['update_id']
            e['advisory_rel'] = notice['version']
            e['advisory_type'] = typemap.get(notice['type'], 'Product Enhancement Advisory')
            e['product'] = notice['release'] or 'Unknown'
            e['description'] = notice['description']
            e['synopsis'] = notice['title'] or notice['update_id']
            if (notice['type'] == 'security' and notice['severity'] and
                    not e['synopsis'].startswith(notice['severity'] + ': ')):
                e['synopsis'] = notice['severity'] + ': ' + e['synopsis']
            if 'summary' in notice and not notice['summary'] is None:
                e['topic'] = notice['summary']
            else:
                e['topic'] = ' '
            if 'solution' in notice and not notice['solution'] is None:
                e['solution'] = notice['solution']
            else:
                e['solution'] = ' '
            e['issue_date'] = self._to_db_date(notice['issued'])
            if notice['updated']:
                e['update_date'] = self._to_db_date(notice['updated'])
            else:
                e['update_date'] = self._to_db_date(notice['issued'])
            e['org_id'] = self.channel['org_id']
            e['notes'] = ''
            e['channels'] = []
            e['packages'] = []
            e['files'] = []
            if existing_errata:
                e['channels'] = existing_errata['channels']
                e['packages'] = existing_errata['packages']
            e['channels'].append({'label': self.channel_label})

            for pkg in notice['pkglist'][0]['packages']:
                param_dict = {
                    'name': pkg['name'],
                    'version': pkg['version'],
                    'release': pkg['release'],
                    'arch': pkg['arch'],
                    'channel_id': int(self.channel['id']),
                }
                if pkg['epoch'] == '0':
                    epochStatement = "(pevr.epoch is NULL or pevr.epoch = '0')"
                elif pkg['epoch'] is None or pkg['epoch'] == '':
                    epochStatement = "pevr.epoch is NULL"
                else:
                    epochStatement = "pevr.epoch = :epoch"
                    param_dict['epoch'] = pkg['epoch']
                if self.channel['org_id']:
                    param_dict['org_id'] = self.channel['org_id']
                    orgStatement = "= :org_id"
                else:
                    orgStatement = "is NULL"

                h = rhnSQL.prepare("""
                    select p.id, pevr.epoch, c.checksum, c.checksum_type
                      from rhnPackage p
                      join rhnPackagename pn on p.name_id = pn.id
                      join rhnpackageevr pevr on p.evr_id = pevr.id
                      join rhnpackagearch pa on p.package_arch_id = pa.id
                      join rhnArchType at on pa.arch_type_id = at.id
                      join rhnChecksumView c on p.checksum_id = c.id
                      join rhnChannelPackage cp on p.id = cp.package_id
                     where pn.name = :name
                       and p.org_id %s
                       and pevr.version = :version
                       and pevr.release = :release
                       and pa.label = :arch
                       and %s
                       and at.label = 'rpm'
                       and cp.channel_id = :channel_id
                """ % (orgStatement, epochStatement))
                h.execute(**param_dict)
                cs = h.fetchone_dict() or None

                if not cs:
                    if 'epoch' in param_dict:
                        epoch = param_dict['epoch'] + ":"
                    else:
                        epoch = ""
                    log(2, "No checksum found for %s-%s%s-%s.%s."
                           " Skipping Package" % (param_dict['name'],
                                                  epoch,
#.........这里部分代码省略.........
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:101,代码来源:reposync.py

示例14: _xmlrpc

 def _xmlrpc(function, params):
     try:
         retval = getattr(BaseWireSource.serverObj, function)(*params)
     except TypeError, e:
         log(-1, 'ERROR: during "getattr(BaseWireSource.serverObj, %s)(*(%s))"' % (function, params))
         raise
开发者ID:cliffy94,项目名称:spacewalk,代码行数:6,代码来源:xmlWireSource.py

示例15: sync

    def sync(self, update_repodata=False):
        """Trigger a reposync"""
        start_time = datetime.now()
        for (repo_id, url, repo_label, channel_family_id) in self.urls:
            log(0, "Repo URL: %s" % url)
            plugin = None

            # If the repository uses a uln:// URL, switch to the ULN plugin, overriding the command-line
            if url.startswith("uln://"):
                self.repo_plugin = self.load_plugin("uln")

            # pylint: disable=W0703
            try:
                # use modified relative_url as name of repo plugin, because
                # it used as name of cache directory as well

                relative_url = '_'.join(url.split('://')[1].split('/')[1:])
                plugin_name = relative_url.replace("?", "_").replace("&", "_").replace("=", "_")

                plugin = self.repo_plugin(url, plugin_name)

                if update_repodata:
                    plugin.clear_cache()

                if repo_id is not None:
                    keys = rhnSQL.fetchone_dict("""
                        select k1.key as ca_cert, k2.key as client_cert, k3.key as client_key
                        from rhncontentssl
                                join rhncryptokey k1
                                on rhncontentssl.ssl_ca_cert_id = k1.id
                                left outer join rhncryptokey k2
                                on rhncontentssl.ssl_client_cert_id = k2.id
                                left outer join rhncryptokey k3
                                on rhncontentssl.ssl_client_key_id = k3.id
                        where rhncontentssl.content_source_id = :repo_id
                        or rhncontentssl.channel_family_id = :channel_family_id
                        """, repo_id=int(repo_id), channel_family_id=int(channel_family_id))
                    if keys and ('ca_cert' in keys):
                        plugin.set_ssl_options(keys['ca_cert'], keys['client_cert'], keys['client_key'])

                if not self.no_packages:
                    self.import_packages(plugin, repo_id, url)
                    self.import_groups(plugin, url)

                if not self.no_errata:
                    self.import_updates(plugin, url)

                # only for repos obtained from the DB
                if self.sync_kickstart and repo_label:
                    try:
                        self.import_kickstart(plugin, repo_label)
                    except:
                        rhnSQL.rollback()
                        raise
            except Exception:
                e = sys.exc_info()[1]
                log2stderr(0, "ERROR: %s" % e)
            if plugin is not None:
                plugin.clear_ssl_cache()
        if self.regen:
            taskomatic.add_to_repodata_queue_for_channel_package_subscription(
                [self.channel_label], [], "server.app.yumreposync")
            taskomatic.add_to_erratacache_queue(self.channel_label)
        self.update_date()
        rhnSQL.commit()
        elapsed_time = datetime.now() - start_time
        log(0, "Sync of channel completed in %s." % str(elapsed_time).split('.')[0])
        return elapsed_time
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:68,代码来源:reposync.py


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