本文整理汇总了Python中turbogears.update_config函数的典型用法代码示例。如果您正苦于以下问题:Python update_config函数的具体用法?Python update_config怎么用?Python update_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: boot
def boot(configfile=None, use_argv=False):
"""Boot the environment containing the classes and configurations."""
setupdir = dirname(dirname(__file__))
curdir = getcwd()
if configfile:
pass # Already a string
elif use_argv and len(sys.argv) > 1:
configfile = sys.argv[1]
else:
alternatives = [
join(setupdir, "local.cfg"),
join(setupdir, "dev.cfg"),
join(setupdir, "prod.cfg")
]
for alternative in alternatives:
if exists(alternative):
configfile = alternative
break
if not configfile:
try:
configfile = pkg_resources.resource_filename(
pkg_resources.Requirement.parse("buzzbot"),
"config/default.cfg")
except pkg_resources.DistributionNotFound:
raise ConfigurationError("Could not find default configuration.")
global configuration
configuration = configfile
print "** Booting configuration: %s" % configfile
turbogears.update_config(configfile=configfile,
modulename="buzzbot.config")
示例2: test_update_from_package
def test_update_from_package():
turbogears.update_config(modulename="turbogears.tests.config")
assert turbogears.config.get("foo.bar") == "BAZ!"
print turbogears.config.get("my.static")
assert turbogears.config.get("my.static").endswith(
"turbogears/tests/static")
assert turbogears.config.get("static_filter.on", path="/static") == True
示例3: test_windows_filenames
def test_windows_filenames():
pkg_resources.resource_filename = windows_filename
turbogears.update_config(configfile = testfile,
modulename="turbogears.tests.config")
testdir = turbogears.config.get("test.dir")
print testdir
assert testdir == "c:/foo/bar"
示例4: _read_config
def _read_config(args):
"""Read deployment configuration file.
First looks on the command line for a desired config file, if it's not on
the command line, then looks for 'setup.py' in the parent of the directory
where this module is located.
If 'setup.py' is there, assumes that the application is started from
the project directory and should run in development mode and so loads the
configuration from a file called 'dev.cfg' in the current directory.
If 'setup.py' is not there, the project is probably installed and the code
looks first for a file called 'prod.cfg' in the current directory and, if
this isn't found either, for a default config file called 'default.cfg'
packaged in the egg.
"""
setupdir = dirname(dirname(__file__))
curdir = getcwd()
if args:
configfile = args[0]
elif exists(join(setupdir, "setup.py")):
configfile = join(setupdir, "dev.cfg")
elif exists(join(curdir, "prod.cfg")):
configfile = join(curdir, "prod.cfg")
else:
try:
configfile = pkg_resources.resource_filename(
pkg_resources.Requirement.parse("turboaffiliate"), "config/default.cfg")
except pkg_resources.DistributionNotFound:
raise ConfigurationError("Could not find default configuration.")
turbogears.update_config(configfile=configfile,
modulename="turboaffiliate.config")
示例5: start
def start():
'''Start the CherryPy application server.'''
turbogears.startup.call_on_startup.append(fedora.tg.utils.enable_csrf)
setupdir = os.path.dirname(os.path.dirname(__file__))
curdir = os.getcwd()
# First look on the command line for a desired config file,
# if it's not on the command line, then look for 'setup.py'
# in the current directory. If there, load configuration
# from a file called 'dev.cfg'. If it's not there, the project
# is probably installed and we'll look first for a file called
# 'prod.cfg' in the current directory and then for a default
# config file called 'default.cfg' packaged in the egg.
if len(sys.argv) > 1:
configfile = sys.argv[1]
elif os.path.exists(os.path.join(setupdir, 'setup.py')) \
and os.path.exists(os.path.join(setupdir, 'dev.cfg')):
configfile = os.path.join(setupdir, 'dev.cfg')
elif os.path.exists(os.path.join(curdir, 'fas.cfg')):
configfile = os.path.join(curdir, 'fas.cfg')
elif os.path.exists(os.path.join('/etc/fas.cfg')):
configfile = os.path.join('/etc/fas.cfg')
else:
try:
configfile = pkg_resources.resource_filename(
pkg_resources.Requirement.parse("fas"),
"config/default.cfg")
except pkg_resources.DistributionNotFound:
raise ConfigurationError("Could not find default configuration.")
turbogears.update_config(configfile=configfile,
modulename="fas.config")
from fas.controllers import Root
turbogears.start_server(Root())
示例6: start
def start():
"""Start the CherryPy application server."""
setupdir = dirname(dirname(__file__))
curdir = os.getcwd()
# First look on the command line for a desired config file,
# if it's not on the command line, then look for 'setup.py'
# in the current directory. If there, load configuration
# from a file called 'dev.cfg'. If it's not there, the project
# is probably installed and we'll look first for a file called
# 'prod.cfg' in the current directory and then for a default
# config file called 'default.cfg' packaged in the egg.
if len(sys.argv) > 1:
configfile = sys.argv[1]
elif exists(join(setupdir, "setup.py")):
configfile = join(setupdir, "dev.cfg")
elif exists(join(curdir, "prod.cfg")):
configfile = join(curdir, "prod.cfg")
else:
try:
configfile = pkg_resources.resource_filename(
pkg_resources.Requirement.parse("gordonweb"),
"config/default.cfg")
except pkg_resources.DistributionNotFound:
raise ConfigurationError("Could not find default configuration.")
turbogears.update_config(configfile=configfile,
modulename="gordonweb.config")
from gordonweb.controllers import Root
turbogears.start_server(Root())
示例7: main
def main():
import sys
import pkg_resources
pkg_resources.require("TurboGears")
# first look on the command line for a desired config file,
# if it's not on the command line, then
# look for setup.py in this directory. If it's not there, this script is
# probably installed
if len(sys.argv) > 1:
configfile = sys.argv[1]
elif exists(join(dirname(__file__), "setup.py")):
configfile = "dev.cfg"
else:
configfile = "prod.cfg"
lucene_lock = 'index/en/write.lock'
if exists(lucene_lock):
os.unlink(lucene_lock)
# Patch before you start importing etc.
import patches
import patches.utils
patches.utils.configfile = configfile
updater = patches.Updater()
updater.update()
del updater
del patches
getoutput('./bin/kidc hubspace/templates')
import monkeypatch
import turbogears
import cherrypy
cherrypy.lowercase_api = True
turbogears.update_config(configfile, modulename="hubspace.config")
staic_target = turbogears.config.config.configs['global']['static_target_dir']
static_link = turbogears.config.config.configs['/static']['static_filter.dir']
if os.path.islink(static_link):
os.remove(static_link)
os.symlink(staic_target, static_link)
print "Static link: %s -> %s" % (static_link, staic_target)
def add_sync_filters():
import hubspace.sync.core
cherrypy.root._cp_filters.extend(hubspace.sync.core._cp_filters)
import hubspace.search
turbogears.startup.call_on_startup.append(add_sync_filters)
turbogears.startup.call_on_shutdown.append(hubspace.search.stop)
from hubspace.controllers import Root
turbogears.start_server(Root())
示例8: test_update_from_both
def test_update_from_both():
turbogears.update_config(configfile = testfile,
modulename="turbogears.tests.config")
print turbogears.config.get("foo.bar")
assert turbogears.config.get("foo.bar") == "blurb"
assert turbogears.config.get("tg.something") == 10
print turbogears.config.get("test.dir")
assert turbogears.config.get("test.dir").endswith("turbogears/tests")
示例9: setup_package
def setup_package():
log.info('Loading test configuration from %s', CONFIG_FILE)
assert os.path.exists(CONFIG_FILE), 'Config file %s must exist' % CONFIG_FILE
update_config(configfile=CONFIG_FILE, modulename='bkr.server.config')
# Override loaded logging config, in case we are using the server's config file
# (we really always want our tests' logs to go to stdout, not /var/log/beaker/)
log_to_stream(sys.stdout, level=logging.NOTSET)
from bkr.inttest import data_setup
if not 'BEAKER_SKIP_INIT_DB' in os.environ:
data_setup.setup_model()
with session.begin():
data_setup.create_labcontroller() #always need a labcontroller
data_setup.create_task(name=u'/distribution/install', requires=
u'make gcc nfs-utils wget procmail redhat-lsb ntp '
u'@development-tools @development-libs @development '
u'@desktop-platform-devel @server-platform-devel '
u'libxml2-python expect pyOpenSSL'.split())
data_setup.create_task(name=u'/distribution/reservesys',
requires=u'emacs vim-enhanced unifdef sendmail'.split())
data_setup.create_distro()
if not os.path.exists(turbogears.config.get('basepath.rpms')):
os.mkdir(turbogears.config.get('basepath.rpms'))
setup_slapd()
turbogears.testutil.make_app(Root)
turbogears.testutil.start_server()
if 'BEAKER_SERVER_BASE_URL' not in os.environ:
# need to start the server ourselves
# (this only works from the IntegrationTests dir of a Beaker checkout)
processes.extend([
Process('beaker', args=['../Server/start-server.py', CONFIG_FILE],
listen_port=turbogears.config.get('server.socket_port'),
stop_signal=signal.SIGINT)
])
processes.extend([
Process('slapd', args=['slapd', '-d0', '-F/tmp/beaker-tests-slapd-config',
'-hldap://127.0.0.1:3899/'],
listen_port=3899, stop_signal=signal.SIGINT),
])
try:
for process in processes:
process.start()
except:
for process in processes:
process.stop()
raise
示例10: start
def start():
"""Start the CherryPy application server."""
setupdir = dirname(dirname(__file__))
curdir = getcwd()
# First look on the command line for a desired config file,
# if it's not on the command line, then look for 'setup.py'
# in the current directory. If there, load configuration
# from a file called 'dev.cfg'. If it's not there, the project
# is probably installed and we'll look first for a file called
# 'prod.cfg' in the current directory and then for a default
# config file called 'default.cfg' packaged in the egg.
if len(sys.argv) > 1:
configfile = sys.argv[1]
elif exists(join(setupdir, "setup.py")):
configfile = join(setupdir, "dev.cfg")
elif exists(join(curdir, "prod.cfg")):
configfile = join(curdir, "prod.cfg")
else:
try:
configfile = pkg_resources.resource_filename(
pkg_resources.Requirement.parse("eCRM"),
"config/default.cfg")
except pkg_resources.DistributionNotFound:
raise ConfigurationError("Could not find default configuration.")
turbogears.update_config(configfile = configfile,
modulename = "ecrm.config")
#update the all vendor report
#from ecrm import scheduler
#remvoe the function by cl on 2010-09-30
# turbogears.startup.call_on_startup.append(scheduler.schedule)
#gen the woven label report
#from ecrm import autoOrder
#turbogears.startup.call_on_startup.append(autoOrder.scheduleAM)
#turbogears.startup.call_on_startup.append(autoOrder.schedulePM)
from ecrm.controllers import Root
turbogears.start_server(Root())
示例11: tg_init
def tg_init(self):
""" Checks for the required data and initializes the application. """
if TGWindowsService.code_dir:
os.chdir(TGWindowsService.code_dir)
sys.path.append(TGWindowsService.code_dir)
# Redirect stdout and stderr to avoid buffer crashes.
sys.stdout = open(join(TGWindowsService.log_dir, 'stdout.log'),'a')
sys.stderr = open(join(TGWindowsService.log_dir, 'stderr.log'),'a')
else:
raise ValueError("""The code directory setting is missing.
The Windows Service will not run
without this setting.""")
if not TGWindowsService.root_class:
raise ValueError("""The fully qualified root class name must
be provided.""")
if not TGWindowsService.log_dir:
TGWindowsService.log_dir = '.'
if exists(join(dirname(__file__), "setup.py")):
turbogears.update_config(configfile="dev.cfg",
modulename=TGWindowsService.config_module)
else:
turbogears.update_config(configfile="prod.cfg",
modulename=TGWindowsService.config_module)
# Set environment to production to disable auto-reload.
cherrypy.config.update({'global': {'server.environment': 'production'},})
# Parse out the root class information and set it to self.root
full_class_name = TGWindowsService.root_class
last_mark = full_class_name.rfind('.')
if (last_mark < 1) or (last_mark + 1) == len(full_class_name):
raise ValueError("""The user-defined class name is invalid.
Please make sure to include a fully
qualified class name for the root_class
value (e.g. wiki20.controllers.Root).""")
package_name = full_class_name[:last_mark]
class_name = full_class_name[last_mark+1:]
exec('from %s import %s as Root' % (package_name, class_name))
self.root = Root
示例12: test_update_on_windows
def test_update_on_windows():
"""turbogears.update_config works as we intend on Windows.
"""
# save the original function
orig_resource_fn = pkg_resources.resource_filename
# monkey patch pkg resources to emulate windows
pkg_resources.resource_filename = windows_filename
update_config(configfile=testfile, modulename="turbogears.tests.config")
testdir = cget("test.dir")
# update_config calls os.normpath on package_dir, but this will have no
# effect on non-windows systems, so we call ntpath.normpath on those here
if not sys.platform.startswith("win"):
testdir = ntpath.normpath(testdir)
# restore original function
pkg_resources.resource_filename = orig_resource_fn
assert testdir == "c:\\foo\\bar"
示例13: start
def start():
"""Start the CherryPy application server."""
setupdir = dirname(dirname(__file__))
curdir = getcwd()
# First look on the command line for a desired config file,
# if it's not on the command line then load pkgdb.cfg from the sysconfdir
if len(sys.argv) > 1:
configfile = sys.argv[1]
else:
configfile = pkgdata.get_filename('pkgdb.cfg', 'config')
turbogears.update_config(configfile=configfile, modulename="pkgdb.config")
from pkgdb.controllers import Root
turbogears.start_server(Root())
示例14: start
def start():
"""Start the CherryPy application server."""
global PRODUCTION_ENV
setupdir = dirname(dirname(__file__))
curdir = os.getcwd()
# First look on the command line for a desired config file,
# if it's not on the command line, then look for 'setup.py'
# in the current directory. If there, load configuration
# from a file called 'dev.cfg'. If it's not there, the project
# is probably installed and we'll look first for a file called
# 'prod.cfg' in the current directory and then for a default
# config file called 'default.cfg' packaged in the egg.
if exists("/etc/funcweb/prod.cfg"):
#we work with production settings now !
PRODUCTION_ENV = True
configfile = "/etc/funcweb/prod.cfg"
elif len(sys.argv) > 1:
configfile = sys.argv[1]
elif exists(join(setupdir, "setup.py")):
configfile = join(setupdir, "dev.cfg")
elif exists(join(curdir, "prod.cfg")):
configfile = join(curdir, "prod.cfg")
else:
try:
configfile = pkg_resources.resource_filename(
pkg_resources.Requirement.parse("funcweb"),
"config/default.cfg")
except pkg_resources.DistributionNotFound:
raise ConfigurationError("Could not find default configuration.")
turbogears.update_config(configfile=configfile,
modulename="funcweb.config")
from funcweb.controllers import Root
if PRODUCTION_ENV:
utils.daemonize("/var/run/funcwebd.pid")
#then start the server
try:
turbogears.start_server(Root())
except Exception,e:
print "Debug information from cherrypy server ...: ",e
示例15: load_config
def load_config(configfile=None):
""" Load bodhi's configuration """
setupdir = os.path.dirname(os.path.dirname(__file__))
curdir = os.getcwd()
if configfile and os.path.exists(configfile):
pass
elif os.path.exists(os.path.join(setupdir, 'setup.py')) \
and os.path.exists(os.path.join(setupdir, 'dev.cfg')):
configfile = os.path.join(setupdir, 'dev.cfg')
elif os.path.exists(os.path.join(curdir, 'bodhi.cfg')):
configfile = os.path.join(curdir, 'bodhi.cfg')
elif os.path.exists('/etc/bodhi.cfg'):
configfile = '/etc/bodhi.cfg'
elif os.path.exists('/etc/bodhi/bodhi.cfg'):
configfile = '/etc/bodhi/bodhi.cfg'
else:
log.error("Unable to find configuration to load!")
return
log.debug("Loading configuration: %s" % configfile)
turbogears.update_config(configfile=configfile, modulename="bodhi.config")