本文整理汇总了Python中treeherder.path函数的典型用法代码示例。如果您正苦于以下问题:Python path函数的具体用法?Python path怎么用?Python path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create_db
def create_db(self, schema_file=None):
"""
Create the database for this source, using given SQL schema file.
If schema file is not given, defaults to
"template_schema/project.sql.tmpl".
"""
import MySQLdb
if schema_file is None:
schema_file = path("model", "sql", "template_schema", "project.sql.tmpl")
filterwarnings('ignore', category=MySQLdb.Warning)
with connection.cursor() as cursor:
cursor.execute("CREATE DATABASE IF NOT EXISTS {0}".format(self.name))
cursor.execute("USE {0}".format(self.name))
try:
with open(schema_file) as f:
# set the engine to use
sql = f.read()
statement_list = sql.split(";")
for statement in statement_list:
cursor.execute(statement)
finally:
cursor.execute("USE {0}".format(
settings.DATABASES['default']['NAME']
))
resetwarnings()
开发者ID:deathping1994,项目名称:treeherder,代码行数:29,代码来源:models.py
示例2: create_db
def create_db(self, schema_file=None):
"""
Create the database for this source, using given SQL schema file.
If schema file is not given, defaults to
"template_schema/schema_<contenttype>.sql.tmpl".
Assumes that the database server at ``self.host`` is accessible, and
that ``DATABASE_USER`` (identified by
``DATABASE_PASSWORD`` exists on it and has permissions to
create databases.
"""
from django.conf import settings
import MySQLdb
DB_USER = settings.DATABASES["default"]["USER"]
DB_PASS = settings.DATABASES["default"]["PASSWORD"]
if self.type.lower().startswith("mysql-"):
engine = self.type[len("mysql-") :]
elif self.type.lower() == "mysql":
engine = "InnoDB"
else:
raise NotImplementedError("Currently only MySQL data source is supported.")
if schema_file is None:
schema_file = path("model", "sql", "template_schema", "project_{0}_1.sql.tmpl".format(self.contenttype))
conn = MySQLdb.connect(host=self.host, user=DB_USER, passwd=DB_PASS)
filterwarnings("ignore", category=MySQLdb.Warning)
cur = conn.cursor()
cur.execute("CREATE DATABASE IF NOT EXISTS {0}".format(self.name))
conn.close()
resetwarnings()
# MySQLdb provides no way to execute an entire SQL file in bulk, so we
# have to shell out to the commandline client.
with open(schema_file) as f:
# set the engine to use
sql = f.read().format(engine=engine)
args = ["mysql", "--host={0}".format(self.host), "--user={0}".format(DB_USER)]
if DB_PASS:
args.append("--password={0}".format(DB_PASS))
args.append(self.name)
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(output, _) = proc.communicate(sql)
if proc.returncode:
raise IOError(
"Unable to set up schema for datasource {0}: "
"mysql returned code {1}, output follows:\n\n{2}".format(self.key, proc.returncode, output)
)
开发者ID:jonasfj,项目名称:treeherder-service,代码行数:51,代码来源:models.py
示例3: create_db
def create_db(self, schema_file=None):
"""
Create the database for this source, using given SQL schema file.
If schema file is not given, defaults to
"template_schema/schema_<contenttype>.sql.tmpl".
Assumes that the database server at ``self.host`` is accessible, and
that ``DATABASE_USER`` (identified by
``DATABASE_PASSWORD`` exists on it and has permissions to
create databases.
"""
import MySQLdb
if self.type.lower().startswith("mysql-"):
engine = self.type[len("mysql-"):]
elif self.type.lower() == "mysql":
engine = "InnoDB"
else:
raise NotImplementedError(
"Currently only MySQL data source is supported.")
if schema_file is None:
schema_file = path(
"model",
"sql",
"template_schema",
"project_{}.sql.tmpl".format(self.contenttype),
)
filterwarnings('ignore', category=MySQLdb.Warning)
with connection.cursor() as cursor:
cursor.execute("CREATE DATABASE IF NOT EXISTS {0}".format(self.name))
cursor.execute("USE {0}".format(self.name))
try:
with open(schema_file) as f:
# set the engine to use
sql = f.read().format(engine=engine)
statement_list = sql.split(";")
for statement in statement_list:
cursor.execute(statement)
finally:
cursor.execute("USE {0}".format(
settings.TREEHERDER_DATABASE_NAME
))
resetwarnings()
开发者ID:TheTeraByte,项目名称:treeherder,代码行数:47,代码来源:models.py
示例4: path
ADMINS = [] # TBD
MANAGERS = ADMINS
SITE_ID = 1
ROOT_URLCONF = "treeherder.webapp.urls"
WSGI_APPLICATION = 'treeherder.webapp.wsgi.application'
TIME_ZONE = "America/Los_Angeles"
LANGUAGE_CODE = "en-us"
USE_I18N = False
USE_L10N = True
USE_TZ = False
SERVE_MINIFIED_UI = os.environ.get("SERVE_MINIFIED_UI") == "True"
WHITENOISE_ROOT = path("..", "dist" if SERVE_MINIFIED_UI else "ui")
STATIC_ROOT = path("webapp", "static")
STATIC_URL = "/static/"
MEDIA_ROOT = path("webapp", "media")
MEDIA_URL = "/media/"
# Additional locations of static files
STATICFILES_DIRS = []
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# "django.contrib.staticfiles.finders.DefaultStorageFinder",
]
开发者ID:EdgarChen,项目名称:treeherder,代码行数:29,代码来源:base.py
示例5: path
ADMINS = [] # TBD
MANAGERS = ADMINS
SITE_ID = 1
ROOT_URLCONF = "treeherder.webapp.urls"
WSGI_APPLICATION = 'treeherder.webapp.wsgi.application'
TIME_ZONE = "America/Los_Angeles"
LANGUAGE_CODE = "en-us"
USE_I18N = False
USE_L10N = True
USE_TZ = False
STATIC_ROOT = path("webapp", "static")
STATIC_URL = "/static/"
MEDIA_ROOT = path("webapp", "media")
MEDIA_URL = "/media/"
# Additional locations of static files
STATICFILES_DIRS = []
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# "django.contrib.staticfiles.finders.DefaultStorageFinder",
]
TEMPLATE_LOADERS = [
"django.template.loaders.filesystem.Loader",
开发者ID:mozfreddyb,项目名称:treeherder,代码行数:30,代码来源:base.py
示例6: path
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
# Django settings for webapp project.
import os
import sys
from datetime import timedelta
from kombu import Exchange, Queue
from treeherder import path
# Insure the vendor libraries are added to the python path
# in production, and before the site-packages entry.
sys.path.insert(1, path('..', 'vendor'))
# These settings can all be optionally set via env vars, or in local.py:
TREEHERDER_DATABASE_NAME = os.environ.get("TREEHERDER_DATABASE_NAME", "")
TREEHERDER_DATABASE_USER = os.environ.get("TREEHERDER_DATABASE_USER", "")
TREEHERDER_DATABASE_PASSWORD = os.environ.get("TREEHERDER_DATABASE_PASSWORD", "")
TREEHERDER_DATABASE_HOST = os.environ.get("TREEHERDER_DATABASE_HOST", "localhost")
TREEHERDER_RO_DATABASE_USER = os.environ.get("TREEHERDER_RO_DATABASE_USER", TREEHERDER_DATABASE_USER)
TREEHERDER_RO_DATABASE_PASSWORD = os.environ.get("TREEHERDER_RO_DATABASE_PASSWORD", TREEHERDER_DATABASE_PASSWORD)
TREEHERDER_RO_DATABASE_HOST = os.environ.get("TREEHERDER_RO_DATABASE_HOST", TREEHERDER_DATABASE_HOST)
TREEHERDER_MEMCACHED = os.environ.get("TREEHERDER_MEMCACHED", "")
TREEHERDER_MEMCACHED_KEY_PREFIX = os.environ.get("TREEHERDER_MEMCACHED_KEY_PREFIX", "treeherder")
DEBUG = os.environ.get("TREEHERDER_DEBUG", False)
开发者ID:klibby,项目名称:treeherder-service,代码行数:30,代码来源:base.py
示例7: env
# cycling data
DATA_CYCLE_CHUNK_SIZE = env.int("DATA_CYCLE_CHUNK_SIZE", default=100)
DATA_CYCLE_SLEEP_TIME = env.int("DATA_CYCLE_SLEEP_TIME", default=0)
# Make this unique, and don't share it with anybody.
SECRET_KEY = env("TREEHERDER_DJANGO_SECRET_KEY")
ROOT_URLCONF = "treeherder.config.urls"
WSGI_APPLICATION = 'treeherder.config.wsgi.application'
TIME_ZONE = "UTC"
USE_I18N = False
USE_L10N = True
# Files in this directory will be served by WhiteNoise at the site root.
WHITENOISE_ROOT = path("..", "dist")
STATIC_ROOT = path("static")
STATIC_URL = "/static/"
# Default minimum regression threshold for perfherder is 2% (otherwise
# e.g. the build size tests will alert on every commit)
PERFHERDER_REGRESSION_THRESHOLD = 2
# Various settings for treeherder's t-test "sliding window" alert algorithm
PERFHERDER_ALERTS_MIN_BACK_WINDOW = 12
PERFHERDER_ALERTS_MAX_BACK_WINDOW = 24
PERFHERDER_ALERTS_FORE_WINDOW = 12
# Only generate alerts for data newer than this time in seconds in perfherder
PERFHERDER_ALERTS_MAX_AGE = timedelta(weeks=2)
开发者ID:rwood-moz,项目名称:treeherder,代码行数:31,代码来源:settings.py
示例8: env
# Default to retaining data for ~4 months.
DATA_CYCLE_DAYS = env.int("DATA_CYCLE_DAYS", default=120)
# Make this unique, and don't share it with anybody.
SECRET_KEY = env("TREEHERDER_DJANGO_SECRET_KEY")
ROOT_URLCONF = "treeherder.config.urls"
WSGI_APPLICATION = 'treeherder.config.wsgi.application'
TIME_ZONE = "UTC"
USE_I18N = False
USE_L10N = True
SERVE_MINIFIED_UI = env.bool("SERVE_MINIFIED_UI", default=False)
# Files in this directory will be served by WhiteNoise at the site root.
WHITENOISE_ROOT = path("..", "dist" if SERVE_MINIFIED_UI else "ui")
STATIC_ROOT = path("static")
STATIC_URL = "/static/"
MEDIA_ROOT = path("media")
MEDIA_URL = "/media/"
# Default minimum regression threshold for perfherder is 2% (otherwise
# e.g. the build size tests will alert on every commit)
PERFHERDER_REGRESSION_THRESHOLD = 2
# Various settings for treeherder's t-test "sliding window" alert algorithm
PERFHERDER_ALERTS_MIN_BACK_WINDOW = 12
PERFHERDER_ALERTS_MAX_BACK_WINDOW = 24
PERFHERDER_ALERTS_FORE_WINDOW = 12
开发者ID:SebastinSanty,项目名称:treeherder,代码行数:31,代码来源:settings.py
示例9: env
# cycling data
DATA_CYCLE_CHUNK_SIZE = env.int("DATA_CYCLE_CHUNK_SIZE", default=100)
DATA_CYCLE_SLEEP_TIME = env.int("DATA_CYCLE_SLEEP_TIME", default=0)
# Make this unique, and don't share it with anybody.
SECRET_KEY = env("TREEHERDER_DJANGO_SECRET_KEY")
ROOT_URLCONF = "treeherder.config.urls"
WSGI_APPLICATION = 'treeherder.config.wsgi.application'
TIME_ZONE = "UTC"
USE_I18N = False
USE_L10N = True
# Files in this directory will be served by WhiteNoise at the site root.
WHITENOISE_ROOT = path("..", "dist")
STATIC_ROOT = path("static")
STATIC_URL = "/static/"
MEDIA_ROOT = path("media")
MEDIA_URL = "/media/"
# Default minimum regression threshold for perfherder is 2% (otherwise
# e.g. the build size tests will alert on every commit)
PERFHERDER_REGRESSION_THRESHOLD = 2
# Various settings for treeherder's t-test "sliding window" alert algorithm
PERFHERDER_ALERTS_MIN_BACK_WINDOW = 12
PERFHERDER_ALERTS_MAX_BACK_WINDOW = 24
PERFHERDER_ALERTS_FORE_WINDOW = 12
开发者ID:SJasoria,项目名称:treeherder,代码行数:31,代码来源:settings.py
注:本文中的treeherder.path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论