本文整理汇总了Python中spacewalk.common.rhnConfig.initCFG函数的典型用法代码示例。如果您正苦于以下问题:Python initCFG函数的具体用法?Python initCFG怎么用?Python initCFG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了initCFG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, url, name, yumsrc_conf=YUMSRC_CONF):
self.url = url
self.name = name
self.yumbase = yum.YumBase()
self.yumbase.preconf.fn = yumsrc_conf
if not os.path.exists(yumsrc_conf):
self.yumbase.preconf.fn = '/dev/null'
self.configparser = ConfigParser()
# read the proxy configuration in /etc/rhn/rhn.conf
initCFG('server.satellite')
self.proxy_addr = CFG.http_proxy
self.proxy_user = CFG.http_proxy_username
self.proxy_pass = CFG.http_proxy_password
self._authenticate(url)
if name in self.yumbase.repos.repos:
repo = self.yumbase.repos.repos[name]
else:
repo = yum.yumRepo.YumRepository(name)
repo.populate(self.configparser, name, self.yumbase.conf)
self.repo = repo
self.sack = None
self.setup_repo(repo)
self.num_packages = 0
self.num_excluded = 0
开发者ID:hlawatschek,项目名称:spacewalk,代码行数:26,代码来源:yum_src.py
示例2: __init__
def __init__(self, url, name, org=1, channel_label="", ca_cert_file=None, client_cert_file=None,
client_key_file=None):
# pylint: disable=W0613
self.url = url
self.name = name
if org:
self.org = org
else:
self.org = "NULL"
# read the proxy configuration in /etc/rhn/rhn.conf
initCFG('server.satellite')
self.proxy_addr = CFG.http_proxy
self.proxy_user = CFG.http_proxy_username
self.proxy_pass = CFG.http_proxy_password
self.authtoken = None
self.repo = DebRepo(url, os.path.join(CACHE_DIR, self.org, name),
os.path.join(CFG.MOUNT_POINT, CFG.PREPENDED_DIR, self.org, 'stage'),
self.proxy_addr, self.proxy_user, self.proxy_pass)
self.num_packages = 0
self.num_excluded = 0
# keep authtokens for mirroring
(_scheme, _netloc, _path, query, _fragid) = urlparse.urlsplit(url)
if query:
self.authtoken = query
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:28,代码来源:deb_src.py
示例3: getParentsChilds
def getParentsChilds():
initCFG('server')
rhnSQL.initDB()
sql = """
select c1.label, c2.label parent_channel, c1.id
from rhnChannel c1 left outer join rhnChannel c2 on c1.parent_channel = c2.id
order by c2.label desc, c1.label asc
"""
h = rhnSQL.prepare(sql)
h.execute()
d_parents = {}
while 1:
row = h.fetchone_dict()
if not row:
break
if rhnChannel.isCustomChannel(row['id']):
parent_channel = row['parent_channel']
if not parent_channel:
d_parents[row['label']] = []
else:
d_parents[parent_channel].append(row['label'])
return d_parents
开发者ID:cliffy94,项目名称:spacewalk,代码行数:25,代码来源:reposync.py
示例4: getParentsChilds
def getParentsChilds(b_only_custom=False):
initCFG('server.satellite')
rhnSQL.initDB()
sql = """
select c1.label, c2.label parent_channel, c1.id
from rhnChannel c1 left outer join rhnChannel c2 on c1.parent_channel = c2.id
order by c2.label desc, c1.label asc
"""
h = rhnSQL.prepare(sql)
h.execute()
d_parents = {}
while 1:
row = h.fetchone_dict()
if not row:
break
if not b_only_custom or rhnChannel.isCustomChannel(row['id']):
parent_channel = row['parent_channel']
if not parent_channel:
d_parents[row['label']] = []
else:
# If the parent is not a custom channel treat the child like
# it's a parent for our purposes
if parent_channel not in d_parents:
d_parents[row['label']] = []
else:
d_parents[parent_channel].append(row['label'])
return d_parents
开发者ID:u-s-p,项目名称:spacewalk,代码行数:30,代码来源:reposync.py
示例5: headerParserHandler
def headerParserHandler(self, req):
log_setreq(req)
# init configuration options with proper component
options = req.get_options()
# if we are initializing out of a <Location> handler don't
# freak out
if not options.has_key("RHNComponentType"):
# clearly nothing to do
return apache.OK
initCFG(options["RHNComponentType"])
initLOG(CFG.LOG_FILE, CFG.DEBUG)
if req.method == 'GET':
# This is the ping method
return apache.OK
self.servers = rhnImport.load("upload_server/handlers",
interface_signature='upload_class')
if not options.has_key('SERVER'):
log_error("SERVER not set in the apache config files!")
return apache.HTTP_INTERNAL_SERVER_ERROR
server_name = options['SERVER']
if not self.servers.has_key(server_name):
log_error("Unable to load server %s from available servers %s" %
(server_name, self.servers))
return apache.HTTP_INTERNAL_SERVER_ERROR
server_class = self.servers[server_name]
self.server = server_class(req)
return self._wrapper(req, "headerParserHandler")
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:27,代码来源:apacheUploadServer.py
示例6: __init__
def __init__(self):
rhnSQL.initDB()
initCFG('server.satellite')
# Channel families mapping to channels
with open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') as f:
self.families = json.load(f)
# Channel metadata
with open(constants.CHANNEL_DEFINITIONS_PATH, 'r') as f:
self.channel_metadata = json.load(f)
# Dist/Release channel mapping
with open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') as f:
self.channel_dist_mapping = json.load(f)
# Channel to repositories mapping
with open(constants.CONTENT_SOURCE_MAPPING_PATH, 'r') as f:
self.content_source_mapping = json.load(f)
# Map channels to their channel family
self.channel_to_family = {}
for family in self.families:
for channel in self.families[family]['channels']:
self.channel_to_family[channel] = family
# Set already synced channels
h = rhnSQL.prepare("""
select label from rhnChannel where org_id is null
""")
h.execute()
channels = h.fetchall_dict() or []
self.synced_channels = [ch['label'] for ch in channels]
开发者ID:jiridostal,项目名称:spacewalk,代码行数:33,代码来源:cdnsync.py
示例7: __init__
def __init__(self):
jabber_lib.Runner.__init__(self)
initCFG("osa-dispatcher")
self._tcp_server = None
self._poll_interval = None
self._next_poll_interval = None
# Cache states
self._state_ids = {}
开发者ID:mantel,项目名称:spacewalk,代码行数:8,代码来源:osa_dispatcher.py
示例8: setUp
def setUp(self):
initCFG("server")
rhnSQL.initDB(
backend="oracle",
username=DB_SETTINGS["user"],
password=DB_SETTINGS["password"],
database=DB_SETTINGS["database"]
)
开发者ID:m47ik,项目名称:uyuni,代码行数:8,代码来源:test_misc_functions.py
示例9: initDB
def initDB(backend=None, host=None, port=None, username=None,
password=None, database=None, sslmode=None, sslrootcert=None, initsecond=False):
"""
Initialize the database.
Either we get backend and all parameter which means the caller
knows what they are doing, or we populate everything from the
config files.
initsecond: If set to True it initialize a second DB connection.
By default only one DB connection is needed.
"""
if backend is None:
if CFG is None or not CFG.is_initialized():
initCFG('server')
backend = CFG.DB_BACKEND
host = CFG.DB_HOST
port = CFG.DB_PORT
database = CFG.DB_NAME
username = CFG.DB_USER
password = CFG.DB_PASSWORD
sslmode = None
sslrootcert = None
if CFG.DB_SSL_ENABLED:
sslmode = 'verify-full'
sslrootcert = CFG.DB_SSLROOTCERT
if backend not in SUPPORTED_BACKENDS:
raise rhnException("Unsupported database backend", backend)
if port:
port = int(port)
# Hide the password
add_to_seclist(password)
try:
if initsecond == False:
__init__DB(backend, host, port, username, password, database, sslmode, sslrootcert)
else:
__init__DB2(backend, host, port, username, password, database, sslmode, sslrootcert)
# except (rhnException, SQLError):
# raise # pass on, we know those ones
# except (KeyboardInterrupt, SystemExit):
# raise
except SQLConnectError:
e = sys.exc_info()[1]
try:
closeDB()
except NameError:
pass
raise e
except:
raise
#e_type, e_value = sys.exc_info()[:2]
# raise rhnException("Could not initialize Oracle database connection",
# str(e_type), str(e_value))
return 0
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:58,代码来源:__init__.py
示例10: __init__
def __init__(
self,
channel_label,
repo_type,
url=None,
fail=False,
quiet=False,
filters=None,
no_errata=False,
sync_kickstart=False,
latest=False,
):
self.regen = False
self.fail = fail
self.quiet = quiet
self.filters = filters or []
self.no_errata = no_errata
self.sync_kickstart = sync_kickstart
self.latest = latest
initCFG("server")
rhnSQL.initDB()
# setup logging
log_filename = channel_label + ".log"
rhnLog.initLOG(default_log_location + log_filename)
# os.fchown isn't in 2.4 :/
os.system("chgrp apache " + default_log_location + log_filename)
self.log_msg("\nSync started: %s" % (time.asctime(time.localtime())))
self.log_msg(str(sys.argv))
self.channel_label = channel_label
self.channel = self.load_channel()
if not self.channel or not rhnChannel.isCustomChannel(self.channel["id"]):
self.print_msg("Channel does not exist or is not custom.")
sys.exit(1)
if not url:
# TODO:need to look at user security across orgs
h = rhnSQL.prepare(
"""select s.id, s.source_url, s.label
from rhnContentSource s,
rhnChannelContentSource cs
where s.id = cs.source_id
and cs.channel_id = :channel_id"""
)
h.execute(channel_id=int(self.channel["id"]))
source_data = h.fetchall_dict()
if source_data:
self.urls = [(row["id"], row["source_url"], row["label"]) for row in source_data]
else:
self.error_msg("Channel has no URL associated")
sys.exit(1)
else:
self.urls = [(None, u, None) for u in url]
self.repo_plugin = self.load_plugin(repo_type)
开发者ID:jetsaredim,项目名称:spacewalk,代码行数:58,代码来源:reposync.py
示例11: __init__
def __init__(self, channel_label, repo_type, url=None, fail=False,
quiet=False, filters=None, no_errata=False, sync_kickstart=False, latest=False,
strict=0):
self.regen = False
self.fail = fail
self.quiet = quiet
self.filters = filters or []
self.no_errata = no_errata
self.sync_kickstart = sync_kickstart
self.latest = latest
initCFG('server.satellite')
rhnSQL.initDB()
# setup logging
log_filename = channel_label + '.log'
if CFG.DEBUG is not None:
log_level = CFG.DEBUG
rhnLog.initLOG(default_log_location + log_filename, log_level)
# os.fchown isn't in 2.4 :/
if isSUSE():
os.system("chgrp www " + default_log_location + log_filename)
else:
os.system("chgrp apache " + default_log_location + log_filename)
self.log_msg("\nSync started: %s" % (time.asctime(time.localtime())))
self.log_msg(str(sys.argv))
self.channel_label = channel_label
self.channel = self.load_channel()
if not self.channel:
self.print_msg("Channel does not exist.")
sys.exit(1)
if not url:
# TODO:need to look at user security across orgs
h = rhnSQL.prepare("""select s.id, s.source_url, s.label, fm.channel_family_id
from rhnContentSource s,
rhnChannelContentSource cs,
rhnChannelFamilyMembers fm
where s.id = cs.source_id
and cs.channel_id = fm.channel_id
and cs.channel_id = :channel_id""")
h.execute(channel_id=int(self.channel['id']))
source_data = h.fetchall_dict()
if source_data:
self.urls = [(row['id'], row['source_url'], row['label'],
row['channel_family_id']) for row in source_data]
else:
self.error_msg("Channel has no URL associated")
sys.exit(1)
else:
self.urls = [(None, u, None, None) for u in url]
self.repo_plugin = self.load_plugin(repo_type)
self.strict = strict
开发者ID:u-s-p,项目名称:spacewalk,代码行数:57,代码来源:reposync.py
示例12: package_details
def package_details(packageid):
"""displays the details for that package id"""
#db access
import sys
sys.path.append("/usr/share/rhn")
try:
import spacewalk.common.rhnConfig as rhnConfig
import spacewalk.server.rhnSQL as rhnSQL
except ImportError:
try:
import common.rhnConfig as rhnConfig
import server.rhnSQL as rhnSQL
except ImportError:
print "Couldn't load the modules required to connect to the db"
sys.exit(1)
rhnConfig.initCFG()
rhnSQL.initDB()
query="""
select
rp.id as "package_id",
rpn.name||'-'||rpe.version||'-'||rpe.release||'.'||rpa.label as "package",
rc.label as "channel_label",
rc.id as "channel_id",
coalesce((select name from rhnpackageprovider rpp where rpp.id = rpk.provider_id),'Unknown') as "provider"
from rhnpackage rp
inner join rhnpackagename rpn on rpn.id = rp.name_id
inner join rhnpackageevr rpe on rpe.id = rp.evr_id
inner join rhnpackagearch rpa on rpa.id = rp.package_arch_id
left outer join rhnchannelpackage rcp on rcp.package_id = rp.id
left outer join rhnchannel rc on rc.id = rcp.channel_id
left outer join rhnpackagekeyassociation rpka on rpka.package_id = rp.id
left outer join rhnpackagekey rpk on rpk.id = rpka.key_id
where rp.id = :packageid
order by 2, 3
"""
cursor = rhnSQL.prepare(query)
cursor.execute(packageid=packageid)
rows = cursor.fetchall_dict()
if not rows is None:
c = 0
print "Package %d : %s" % (rows[0]['package_id'], rows[0]['package'])
pkg_channels = []
pkg_provider = []
for row in rows:
c += 1
if row.channel_id != None:
pkg_channels[row['channel_id']] = row['channel_label']
pkg_provider[row['channel_id']] = row['provider']
else:
pkg_channels[0] = "Not in a channel"
pkg_provider[0] = row['provider']
print "\r%s of %s" % (str(c), str(len(rows))),
print "Provided by channels : %s" % (', '.join(pkg_channels))
print "With providers (same order): %s" % (', '.join(pkg_provider))
else:
print "no package found for the id %d" % (packageid)
开发者ID:FDewaleyne,项目名称:rhns-utils,代码行数:57,代码来源:rhns-package-infos.py
示例13: __init__
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False):
self.no_packages = no_packages
self.no_errata = no_errata
self.no_rpms = no_rpms
self.no_kickstarts = no_kickstarts
rhnSQL.initDB()
initCFG('server.satellite')
try:
# Channel families mapping to channels
with open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') as f:
self.families = json.load(f)
# Channel metadata
with open(constants.CHANNEL_DEFINITIONS_PATH, 'r') as f:
self.channel_metadata = json.load(f)
# Dist/Release channel mapping
with open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') as f:
self.channel_dist_mapping = json.load(f)
# Channel to repositories mapping
with open(constants.CONTENT_SOURCE_MAPPING_PATH, 'r') as f:
self.content_source_mapping = json.load(f)
# Channel to kickstart repositories mapping
with open(constants.KICKSTART_SOURCE_MAPPING_PATH, 'r') as f:
self.kickstart_source_mapping = json.load(f)
except IOError:
e = sys.exc_info()[1]
# TODO: print only on bigger debug level
print("ERROR: Problem with loading file: %s" % e)
raise CdnMappingsLoadError()
# Map channels to their channel family
self.channel_to_family = {}
for family in self.families:
for channel in self.families[family]['channels']:
self.channel_to_family[channel] = family
# Set already synced channels
h = rhnSQL.prepare("""
select label from rhnChannel where org_id is null
""")
h.execute()
channels = h.fetchall_dict() or []
self.synced_channels = [ch['label'] for ch in channels]
# Set SSL-keys for channel family
self.family_keys = {}
开发者ID:hlawatschek,项目名称:spacewalk,代码行数:52,代码来源:cdnsync.py
示例14: __init__
def __init__(self, url, name, yumsrc_conf=YUMSRC_CONF, org="1", channel_label=""):
self.url = url
self.name = name
self.yumbase = yum.YumBase()
self.yumbase.preconf.fn = yumsrc_conf
if not os.path.exists(yumsrc_conf):
self.yumbase.preconf.fn = '/dev/null'
self.configparser = ConfigParser()
if org:
self.org = org
else:
self.org = "NULL"
# read the proxy configuration in /etc/rhn/rhn.conf
initCFG('server.satellite')
self.proxy_addr = CFG.http_proxy
self.proxy_user = CFG.http_proxy_username
self.proxy_pass = CFG.http_proxy_password
self._authenticate(url)
# Check for settings in yum configuration files (for custom repos/channels only)
if org:
repos = self.yumbase.repos.repos
else:
repos = None
if repos and name in repos:
repo = repos[name]
elif repos and channel_label in repos:
repo = repos[channel_label]
# In case we are using Repo object based on channel config, override it's id to name of the repo
# To not create channel directories in cache directory
repo.id = name
else:
# Not using values from config files
repo = yum.yumRepo.YumRepository(name)
repo.populate(self.configparser, name, self.yumbase.conf)
self.repo = repo
self.setup_repo(repo)
self.num_packages = 0
self.num_excluded = 0
# if self.url is metalink it will be expanded into
# real urls in self.repo.urls and also save this metalink
# in begin of the url list ("for repolist -v ... or anything else wants to know the baseurl")
# Remove it from the list, we don't need it to download content of repo
real_urls = []
for url in self.repo.urls:
if '?' not in url:
real_urls.append(url)
self.repo.urls = real_urls
开发者ID:shastah,项目名称:spacewalk,代码行数:50,代码来源:yum_src.py
示例15: __init__
def __init__(self, retries=3, log_obj=None, force=False):
self.queue = Queue()
initCFG('server.satellite')
try:
self.threads = int(CFG.REPOSYNC_DOWNLOAD_THREADS)
except ValueError:
raise ValueError("Number of threads expected, found: '%s'" % CFG.REPOSYNC_DOWNLOAD_THREADS)
if self.threads < 1:
raise ValueError("Invalid number of threads: %d" % self.threads)
self.retries = retries
self.log_obj = log_obj
self.force = force
self.lock = Lock()
self.exception = None
开发者ID:lhellebr,项目名称:spacewalk,代码行数:14,代码来源:download.py
示例16: initDB
def initDB(backend=None, host=None, port=None, username=None,
password=None, database=None, sslmode=None, sslrootcert=None):
"""
Initialize the database.
Either we get backend and all parameter which means the caller
knows what they are doing, or we populate everything from the
config files.
"""
if backend is None:
if CFG is None or not CFG.is_initialized():
initCFG('server')
backend = CFG.DB_BACKEND
host = CFG.DB_HOST
port = CFG.DB_PORT
database = CFG.DB_NAME
username = CFG.DB_USER
password = CFG.DB_PASSWORD
sslmode = None
sslrootcert = None
if CFG.DB_SSL_ENABLED:
sslmode = 'verify-full'
sslrootcert = CFG.DB_SSLROOTCERT
if backend not in SUPPORTED_BACKENDS:
raise rhnException("Unsupported database backend", backend)
if port:
port = int(port)
# Hide the password
add_to_seclist(password)
try:
__init__DB(backend, host, port, username, password, database, sslmode, sslrootcert)
__init__DB2(backend, host, port, username, password, database, sslmode, sslrootcert)
# except (rhnException, SQLError):
# raise # pass on, we know those ones
# except (KeyboardInterrupt, SystemExit):
# raise
except SQLConnectError, e:
try:
global __DB
global __DB2
del __DB
del __DB2
except NameError:
pass
raise e
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:49,代码来源:__init__.py
示例17: __init__
def __init__(self, url, name):
self.url = url
self.name = name
self._clean_cache(CACHE_DIR + name)
# read the proxy configuration in /etc/rhn/rhn.conf
initCFG('server.satellite')
self.proxy_addr = CFG.http_proxy
self.proxy_user = CFG.http_proxy_username
self.proxy_pass = CFG.http_proxy_password
self.repo = DebRepo(url, CACHE_DIR + name)
self.num_packages = 0
self.num_excluded = 0
开发者ID:lhellebr,项目名称:spacewalk,代码行数:15,代码来源:deb_src.py
示例18: get_rhn_credentials
def get_rhn_credentials(self):
"""
If we're using the rhn authorization module, we get the taskomatic
user's password by importing the spacewalk modules
"""
sys.path.append('/usr/share/rhn')
try:
from spacewalk.common.rhnConfig import initCFG, CFG
except ImportError:
raise ConfigError("This is not a Spacewalk server, but the" +
"configuration says I am.")
initCFG()
self._config['username'] = 'taskomatic_user'
self._config['password'] = CFG.SESSION_SECRET_1
开发者ID:stbenjam,项目名称:cobbler-csv,代码行数:15,代码来源:config.py
示例19: __init__
def __init__(self, username=None, password=None, email=None, dbusername=None, dbpassword=None, dbhostname=None):
#start_init = time.time()
self.filesuploaded = False
self.options = rhnConfig.initCFG( 'server' )
print self.options
mytime = time.time()
self.test_username = username or ("test_username_%.3f" % mytime)
self.test_password = password or ("test_password_%.3f" % mytime)
self.test_email = email or ("%[email protected]_domain.com" % self.test_username)
self.dbusername = dbusername or 'rhnuser'
self.dbpassword = dbpassword or 'rhnuser'
self.dbhostname = dbhostname or 'webdev'
self.channel_arch = 'unittestarch'
self.roles = ['org_admin']
rhnFlags.set( 'outputTransportOptions', UserDictCase() )
self._init_db( self.dbusername, self.dbpassword, self.dbhostname )
self._init_org()
self._init_user(self.roles)
self._init_server()
self._init_channels()
self._init_up2date()
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:27,代码来源:TestServer.py
示例20: __init__
def __init__(self, retries=3, log_obj=None, force=False):
self.queues = {}
initCFG('server.satellite')
try:
self.threads = int(CFG.REPOSYNC_DOWNLOAD_THREADS)
except ValueError:
raise ValueError("Number of threads expected, found: '%s'" % CFG.REPOSYNC_DOWNLOAD_THREADS)
if self.threads < 1:
raise ValueError("Invalid number of threads: %d" % self.threads)
self.retries = retries
self.log_obj = log_obj
self.force = force
self.lock = Lock()
self.exception = None
# WORKAROUND - BZ #1439758 - ensure first item in queue is performed alone to properly setup NSS
self.first_in_queue_done = False
self.first_in_queue_lock = Lock()
开发者ID:m47ik,项目名称:uyuni,代码行数:17,代码来源:download.py
注:本文中的spacewalk.common.rhnConfig.initCFG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论