本文整理汇总了Python中turbogears.update_config函数的典型用法代码示例。如果您正苦于以下问题:Python update_config函数的具体用法?Python update_config怎么用?Python update_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_config函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:pbarton666,项目名称:buzz_bot,代码行数:35,代码来源:commands.py
示例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
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_config.py
示例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"
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_config.py
示例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")
开发者ID:SpectralAngel,项目名称:TurboAffiliate,代码行数:35,代码来源:command.py
示例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())
开发者ID:Affix,项目名称:fas,代码行数:35,代码来源:commands.py
示例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())
开发者ID:bmcfee,项目名称:gordon,代码行数:33,代码来源:commands.py
示例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())
开发者ID:mightymau,项目名称:hubspace,代码行数:59,代码来源:start_hubspace.py
示例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")
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_config.py
示例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
开发者ID:sibiaoluo,项目名称:beaker,代码行数:51,代码来源:__init__.py
示例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())
开发者ID:LamCiuLoeng,项目名称:bossini,代码行数:46,代码来源:commands.py
示例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
开发者ID:TurboGears,项目名称:tgwebsite,代码行数:45,代码来源:service.py
示例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"
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:18,代码来源:test_config.py
示例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())
开发者ID:fedora-infra,项目名称:packagedb,代码行数:18,代码来源:commands.py
示例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
开发者ID:caglar10ur,项目名称:func,代码行数:44,代码来源:commands.py
示例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")
开发者ID:kmcdowell85,项目名称:bodhi,代码行数:20,代码来源:util.py
示例16: start
def start():
cherrypy.lowercase_api = True
# 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:
turbogears.update_config(configfile=sys.argv[1],
modulename="mirrormanager.config")
elif exists(join(os.getcwd(), "setup.py")):
turbogears.update_config(configfile="dev.cfg",
modulename="mirrormanager.config")
else:
turbogears.update_config(configfile="/etc/mirrormanager/prod.cfg",
modulename="mirrormanager.config")
from mirrormanager.controllers import Root
turbogears.start_server(Root())
开发者ID:docent-net,项目名称:mirrormanager,代码行数:19,代码来源:commands.py
示例17: type
if type(nullOrStr) == float : return unicode(int(nullOrStr))
return unicode(nullOrStr).strip()
def formatLC(nullOrStr):
if not nullOrStr or type(nullOrStr) not in [str,unicode] : return ""
return "".join([c for c in nullOrStr if c.isdigit()])
if __name__ == "__main__":
import turbogears,os,re
import win32com.client
from sqlobject import *
from ecrm.util.common import *
from sqlobject.sqlbuilder import *
LIKE.op = "ILIKE"
turbogears.update_config(configfile="dev.cfg",modulename="ecrm.config")
from ecrm import model
from ecrm.model import *
print "=======================start to read the ecxel============================="
pythoncom.CoInitialize()
xls = win32com.client.Dispatch("Excel.Application")
xls.Visible = 0
wb = xls.Workbooks.open(xlsPath)
sheet = wb.Sheets[0]
beginRow = 2
endRow =80
data = []
for row in range(beginRow,endRow+1):
data.append( {
开发者ID:LamCiuLoeng,项目名称:bossini,代码行数:31,代码来源:legacy_import.py
示例18: open
#!/usr/bin/python
import sys
import time
sys.path.append("/usr/lib/controlpanel")
from models.masterdb import *
from models.identitydb import *
from datetime import datetime, date, timedelta
import traceback, urlparse, urllib2
import commands , pickle
import turbogears
turbogears.update_config(configfile="/root/sanity.cfg")
from sqlobject import IN, AND, OR
customer = Customer.get(46443)
customer = Customer.get(28971)
num_servers = 0
num_mps = 0
server_labels = {}
lines = open(sys.argv[1]).readlines()
# IMPORTED UP TO 80
start = 0
end = start+500
print "Importing %s - %s\n\n" % (start,end)
for line in lines[start:end]:
line = line.strip()
fields = line.split('|')
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:31,代码来源:importVic2.py
示例19: len
#!/usr/bin/python
import pkg_resources
pkg_resources.require("TurboGears")
from turbogears import config, update_config, start_server, startup
import cherrypy
cherrypy.lowercase_api = True
from os.path import *
import sys
# 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:
update_config(configfile=sys.argv[1],
modulename="archives.config")
elif exists(join(dirname(__file__), "setup.py")):
update_config(configfile="dev.cfg",modulename="archives.config")
else:
update_config(configfile="prod.cfg",modulename="archives.config")
config.update(dict(package="archives"))
from archives.controllers import Root
from archives import jobs
startup.call_on_startup.append(jobs.schedule)
start_server(Root())
开发者ID:ternus,项目名称:assassin-hexgrid,代码行数:27,代码来源:start-archives.py
示例20: len
from turbogears import update_config, start_server, config
warnings.resetwarnings()
import cherrypy
cherrypy.lowercase_api = True
from os.path import *
import sys
from hardware.featureset import init, config_filename
_cfg_filename = None
if len(sys.argv) > 1:
_cfg_filename = sys.argv[1]
init(_cfg_filename)
update_config(configfile=config_filename(),modulename="hardware.config")
warnings.filterwarnings("ignore")
from hardware.controllers import Root
warnings.resetwarnings()
if config.get('server.environment') == 'production':
pidfile='/var/run/smolt/smolt.pid'
else:
pidfile='smolt.pid'
#--------------- write out the pid file -----------
import os
#pid = file('hardware.pid', 'w')
pid = file(pidfile, 'w')
开发者ID:MythTV,项目名称:smolt,代码行数:31,代码来源:start-hardware.py
注:本文中的turbogears.update_config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论