本文整理汇总了Python中pyasm.search.DatabaseImpl类的典型用法代码示例。如果您正苦于以下问题:Python DatabaseImpl类的具体用法?Python DatabaseImpl怎么用?Python DatabaseImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: import_bootstrap
def import_bootstrap():
print "Importing bootstrap ..."
vendor = "SQLServer"
impl = DatabaseImpl.get(vendor)
impl.create_database("sthpw")
upgrade_dir = Environment.get_upgrade_dir()
for category in ['bootstrap', 'sthpw', 'config']:
f = open("%s/%s/%s_schema.sql" % (upgrade_dir, vendor.lower(), category) )
data = f.read()
f.close()
data = data.split(";")
cmds = []
for cmd in data:
cmd = cmd.strip()
if cmd == '':
continue
cmds.append(cmd)
from pyasm.search import DbContainer
sql = DbContainer.get("sthpw")
for cmd in cmds:
sql.do_update(cmd)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:28,代码来源:bootstrap_load.py
示例2: database_exists
def database_exists(my):
'''returns whether a database exists for this project'''
if not my.get_value("code"):
return False
db_resource = my.get_project_db_resource()
impl = DatabaseImpl.get()
return impl.database_exists(db_resource)
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:8,代码来源:project.py
示例3: load_bootstrap
def load_bootstrap(my):
impl = DatabaseImpl.get()
exists = impl.database_exists("sthpw")
print "exists: ", exists
vendor = impl.get_database_type()
if not exists:
print "Running bootstrap"
install_dir = Environment.get_install_dir()
python = Config.get_value("services", "python")
if not python:
python = "python"
# create the database and inject the bootstrap data
impl.create_database("sthpw")
cmd = "%s %s/src/pyasm/search/upgrade/%s/bootstrap_load.py" % (python, install_dir, vendor.lower())
os.system(cmd)
开发者ID:blezek,项目名称:TACTIC,代码行数:20,代码来源:db_config_wdg.py
示例4: init_cache
def init_cache(my):
from pyasm.search import DatabaseImpl, DbContainer
my.caches = {}
data = {}
for table in my.tables:
column_data = DatabaseImpl.get().get_column_info(my.database, table)
data[table] = column_data
my.caches['data'] = data
# get the order columns
columns = {}
sql = DbContainer.get(my.database)
for table in my.tables:
column_list = sql.get_columns(table)
columns[table] = column_list
my.caches = {}
my.caches['data'] = data
my.caches['columns'] = columns
开发者ID:0-T-0,项目名称:TACTIC,代码行数:20,代码来源:cache_startup.py
示例5: test_postgres
def test_postgres(my, vendor):
web = WebContainer.get_web()
defaults = DEFAULTS[vendor]
default_server = defaults['server']
default_port = defaults['port']
default_user = defaults['user']
default_password = defaults['password']
server = web.get_form_value("server")
if not server:
server = default_server
port = web.get_form_value("port")
if not port:
port = default_port
else:
port = int(port)
user = web.get_form_value("user")
if not user:
user = default_user
password = web.get_form_value("password")
if not password:
password = default_password
# Need to access remote database
create = False
impl = DatabaseImpl.get(vendor)
exists = impl.database_exists("sthpw", host=server, port=port)
if not create:
if not exists:
my.info['error'] = "Database [sthpw] does not exist. This is required for TACTIC to function."
return
else:
print "Running bootstrap"
install_dir = Environment.get_install_dir()
python = Config.get_value("services", "python")
if not python:
python = "python"
# create the database and inject the bootstrap data
impl.create_database("sthpw", host=server, port=port)
cmd = "%s %s/src/pyasm/search/upgrade/%s/bootstrap_load.py" % (python, install_dir, vendor.lower())
os.system(cmd)
from pyasm.search import Sql
sql = Sql("sthpw", server, user, password=password, vendor=vendor, port=port)
try:
# attempt
sql.connect()
sql.do_query("select id from transaction_log limit 1")
except Exception, e:
my.info['error'] = "Could not connect to database with (vendor=%s, server=%s, user=%s, port=%s)" % (vendor, server, user, port)
my.info['message'] = str(e)
print e
开发者ID:blezek,项目名称:TACTIC,代码行数:64,代码来源:db_config_wdg.py
示例6: InstallException
my.create_temp_directory()
my.change_directory_ownership()
my.install_win32_service()
if install_db == False:
print "TACTIC setup successful. Next, the TACTIC database needs to be configured."
return
# dynamically load modules now that we know where they are
from pyasm.search import DatabaseImpl, DbContainer
# create the sthpw database
database = DatabaseImpl.get()
# check if database exists
print "Creating database '%s' ..." % project_code
print
db_exists = False
from pyasm.search import DatabaseException
try:
if database.database_exists(project_code):
print "... already exists. Please remove first"
raise InstallException("Database '%s' already exists" % project_code)
db_exists = True
except DatabaseException, e:
开发者ID:pombredanne,项目名称:TACTIC,代码行数:31,代码来源:install.py
示例7: get_database_type
def get_database_type(my):
db_resource = my.get_project_db_resource()
impl = DatabaseImpl.get()
return impl.get_database_type()
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:4,代码来源:project.py
示例8: execute
def execute(self):
if not self.sobject.is_insert():
# do nothing
return
project = self.sobject
project_code = project.get_code()
project_type = project.get_base_type()
database = DatabaseImpl.get()
# check if database exists
print "Creating database '%s' ..." % project_code
if database.database_exists(project_code):
print "... already exists"
else:
# create the datbase
database.create_database(project_code)
# import the appropriate schema
database.import_schema(project_code, project_type)
# import the appropriate data
database.import_default_data(project_code, project_type)
# copy files from the default template
site_dir = Environment.get_site_dir()
install_dir = Environment.get_install_dir()
template_dir = "%s/src/tactic_sites/template" % install_dir
template_dir = template_dir.replace("\\","/")
project_dir = "%s/sites/%s" % (site_dir, project_code)
project_dir = project_dir.replace("\\","/")
# set the update of the database to current
project.set_value("last_db_update", Sql.get_timestamp_now(), quoted=False)
project.commit()
# copy all of the files from the template to the template directory
print "Creating project directories [%s]..." % project_dir
if not os.path.exists(template_dir):
print "... skipping: template dir [%s] does not exist" % template_dir
return
if not os.path.exists(project_dir):
for root, dirs, files in os.walk(template_dir):
root = root.replace("\\","/")
# ignore ".svn"
if root.find("/.svn") != -1:
continue
for file in files:
# ignore compiled python files
if file.endswith(".pyc"):
continue
old = "%s/%s" % (root, file)
new = old.replace(template_dir, project_dir)
dirname = os.path.dirname(new)
System().makedirs(dirname)
shutil.copyfile(old,new)
else:
print "... skipping. Already exists."
print "Done."
开发者ID:mincau,项目名称:TACTIC,代码行数:72,代码来源:edit_wdg_action.py
示例9: execute
#.........这里部分代码省略.........
upgrade = eval("%s()" % upgrade_class)
# upgrade config (done for every project but sthpw)
conf_upgrade.set_project(project.get_code())
conf_upgrade.set_to_version(my.to_version)
conf_upgrade.set_forced(my.is_forced)
conf_upgrade.set_quiet(my.quiet)
conf_upgrade.set_confirmed(my.is_confirmed)
conf_upgrade.execute()
# append the errors for each upgrade
key = '%s|%s' %(project.get_code(), conf_upgrade.__class__.__name__)
error_list.append((conf_upgrade.__class__.__name__, project.get_code(), \
Container.get_seq(key)))
# perform the upgrade to the other tables
if upgrade:
upgrade.set_project(project.get_code() )
upgrade.set_to_version(my.to_version)
upgrade.set_forced(my.is_forced)
upgrade.set_quiet(my.quiet)
upgrade.set_confirmed(my.is_confirmed)
#Command.execute_cmd(upgrade)
# put each upgrade function in its own transaction
# carried out in BaseUpgrade
upgrade.execute()
# append the errors for each upgrade
key = '%s|%s' %(project.get_code(), upgrade.__class__.__name__)
error_list.append((upgrade.__class__.__name__, project.get_code(), \
Container.get_seq(key)))
from pyasm.search import DatabaseImpl
project.set_value("last_db_update", DatabaseImpl.get().get_timestamp_now(), quoted=False)
if project.has_value('last_version_update'):
last_version = project.get_value('last_version_update')
if my.to_version > last_version:
project.set_value("last_version_update", my.to_version)
else:
# it should be getting the upgrade now, redo the search
print "Please run upgrade_db.py again, the sthpw db has just been updated"
return
project.commit(triggers=False)
# print the errors for each upgrade
for cls_name, project_code, errors in error_list:
if not my.quiet:
print
print "Errors for %s [%s]:" %(project_code, cls_name)
ofile.write("Errors for %s [%s]:\n" %(project_code, cls_name))
if not my.quiet:
print "*" * 80
ofile.write("*" * 80 + '\n')
for func, error in errors:
if not my.quiet:
print '[%s]' % func
print "-" * 70
print error
ofile.write('[%s]\n' % func)
ofile.write("-" * 70 + '\n')
ofile.write('%s\n' %error)
ofile.close()
开发者ID:blezek,项目名称:TACTIC,代码行数:67,代码来源:upgrade_db.py
示例10: import_template
def import_template(my):
if my.path:
base_dir = os.path.dirname(my.path)
else:
base_dir = Environment.get_template_dir()
version = my.kwargs.get("version")
if version:
template_dir = "%s/%s-%s" % (base_dir, my.template_code, version)
else:
template_dir = "%s/%s" % (base_dir, my.template_code)
template_dir = my.get_template_dir(template_dir)
# if the directory does not exist then look for a zip file
use_zip = False
if not os.path.exists(template_dir):
template_zip = "%s.zip" % (template_dir)
if os.path.exists(template_zip):
use_zip = True
else:
hint = "Please check if you have created the Template already using the Update button in the Template Project view."
if version:
raise TacticException("No template found for [%s] version [%s]. %s" % (my.template_code, version, hint))
else:
raise TacticException("No template found for [%s]. %s" % (my.template_code, hint))
# check to see if the database exists in the default
# database implementation
from pyasm.search import DbContainer, DatabaseImpl
impl = DatabaseImpl.get()
exists = impl.database_exists(my.project_code)
# if the database already exists, then raise an exception
if exists and my.new_project:
msg = "WARNING: Database [%s] already exists" % my.project_code
print msg
raise TacticException(msg)
# this is the overriding factor:
if my.is_template == True:
title = Common.get_display_title(my.project_code)
elif my.is_template == False:
title = Common.get_display_title(my.project_code)
elif my.is_template == None:
# these 2 is for old usage using the command line script create_template.py
if my.template_project_code != my.project_code:
my.is_template = False
title = Common.get_display_title(my.project_code)
else:
my.is_template = True
title = Common.get_display_title(my.template_project_code)
# create a new project if this was desired
if my.new_project == True:
from create_project_cmd import CreateProjectCmd
project_image_path = my.kwargs.get("project_image_path")
# the project_type will get updated properly by the PluginInstaller
# but that break the ties to the project_type entry created though,
# which is ok
creator = CreateProjectCmd(
project_code=my.project_code,
project_title=title,
project_type=my.template_project_code,
is_template=my.is_template,
use_default_side_bar=False,
project_image_path=project_image_path
)
creator.execute()
# set the project
Project.set_project(my.project_code)
# import from a plugin
if use_zip:
kwargs = {
'zip_path': template_zip,
'code': my.project_code
}
else:
kwargs = {
'plugin_dir': template_dir
}
kwargs['filter_line_handler'] = my.filter_line_handler
kwargs['filter_sobject_handler'] = my.filter_sobject_handler
from plugin import PluginCreator, PluginInstaller
installer = PluginInstaller( **kwargs )
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:project_template_cmd.py
示例11: execute
#.........这里部分代码省略.........
from_template_path = "%s/%s" % (base_dir, template_name)
from_data_path = "%s/%s" % (base_dir, data_name)
from_file_path = "%s/%s" % (base_dir, file_name)
to_file_path = from_file_path
# copy the files
# ???? why are we copying here?
shutil.copy(from_template_path, to_template_path)
shutil.copy(from_data_path, to_data_path)
else:
# TEST TEST TEST
ticket = server.get_value("server")
remote_server = TacticServerStub(
protocol='xmlrpc',
server=server,
project=project_code,
#user=user,
#password=password,
ticket=ticket,
)
class_name = 'tactic.ui.sync.SyncCreateTemplateCmd'
kwargs = {
'project_code': project_code
}
remote_server.execute_cmd(class_name, kwargs)
base_url = "http://%s/assets/_temp/" % server
# download and install the files
from_template_path = "%s/%s_template-%s.zip" % (base_url, project_code, version)
from_data_path = "%s/%s_data-%s.zip" % (base_url, project_code, version)
remote_server.download(from_template_path, to_dir)
remote_server.download(from_data_path, to_dir)
# This makes the pretty big assumption that this is an official template
if not os.path.exists(to_template_path):
raise Exception("Path [%s] does not exist" % to_template_path)
template_code = project_code
try:
new_project = False
from tactic.command import ProjectTemplateInstallerCmd
cmd = ProjectTemplateInstallerCmd(project_code=project_code, path=to_template_path,template_code=template_code, new_project=new_project, version=version)
cmd.execute()
Project.set_project(project_code)
project = Project.get()
# NOTE: this avoids breaking on search.py, line 203, where it checks
# for tables. The caching mechanism for what tables are in the
# database need to be refreshed once a template is imported
from pyasm.search import DatabaseImpl, DbContainer
DatabaseImpl.clear_table_cache()
# import from a plugin
kwargs = {
#'base_dir': base_dir,
#'manifest': self.xml.to_string(),
'code': "%s_data" % project_code,
'zip_path': to_data_path,
}
from tactic.command import PluginInstaller
cmd = PluginInstaller(**kwargs)
cmd.execute()
# create zip of the project files
if os.path.exists(to_file_path):
from pyasm.common import ZipUtil
zip_util = ZipUtil()
asset_dir = Environment.get_asset_dir()
to_file_dir = os.path.dirname(to_file_path)
zip_util.extract(to_file_path, base_dir=asset_dir)
except Exception as e:
print("Error: ", str(e))
raise
开发者ID:mincau,项目名称:TACTIC,代码行数:101,代码来源:sync_settings_wdg.py
示例12: get_database_type
def get_database_type(self):
db_resource = self.get_project_db_resource()
impl = DatabaseImpl.get()
return impl.get_database_type()
开发者ID:mincau,项目名称:TACTIC,代码行数:4,代码来源:project.py
注:本文中的pyasm.search.DatabaseImpl类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论