本文整理汇总了Python中pyasm.common.Environment.get_data_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_data_dir方法的具体用法?Python Environment.get_data_dir怎么用?Python Environment.get_data_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Environment
的用法示例。
在下文中一共展示了Environment.get_data_dir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_data_dir [as 别名]
def execute(self):
self.section = None
# make sure tmp config is unset.
Config.unset_tmp_config()
Config.reload_config()
web = WebContainer.get_web()
# read the current config file.
# copy config to the path
config_path = Config.get_config_path()
if not os.path.exists(config_path):
print "Installing default config file"
dirname = os.path.dirname(config_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
if os.name == 'nt':
osname = 'win32'
else:
osname = 'linux'
install_dir = Environment.get_install_dir()
install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)
shutil.copy(install_config_path, dirname)
try:
self.configure_db()
self.configure_install()
self.configure_mail_services()
self.configure_gen_services()
self.configure_asset_dir()
self.configure_palette()
self.configure_security()
except Exception as e:
raise TacticException('Error in [%s]: %s'%(self.section, e.__str__()))
# FIXME: if this all fails, then revert back
self.save_config()
# after saving the config, test the database
self.load_bootstrap()
# remove the first run file
data_dir = Environment.get_data_dir()
path = "%s/first_run" % data_dir
if os.path.exists(path):
os.unlink(path)
self.restart_program()
示例2: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_data_dir [as 别名]
def execute(my):
# make sure tmp config is unset.
Config.unset_tmp_config()
Config.reload_config()
web = WebContainer.get_web()
# read the current config file.
# copy config to the path
config_path = Config.get_config_path()
if not os.path.exists(config_path):
print "Installing default config file"
dirname = os.path.dirname(config_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
if os.name == 'nt':
osname = 'win32'
else:
osname = 'linux'
install_dir = Environment.get_install_dir()
install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)
shutil.copy(install_config_path, dirname)
my.configure_db()
my.configure_install()
my.configure_services()
my.configure_asset_dir()
my.configure_palette()
# FIXME: if this all fails, then revert back
my.save_config()
# after saving the config, test the database
my.load_bootstrap()
# remove the first run file
data_dir = Environment.get_data_dir()
path = "%s/first_run" % data_dir
if os.path.exists(path):
os.unlink(path)
my.restart_program()
示例3: get_sqlite_wdg
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_data_dir [as 别名]
def get_sqlite_wdg(my):
div = DivWdg()
div.add_class("spt_db_options")
div.add_attr("spt_vendor", "Sqlite")
div.add_style("padding: 20px")
div.add("Database Folder: ")
text = TextInputWdg(name="database/sqlite_db_dir")
div.add(text)
db_dir = Config.get_value("database", "sqlite_db_dir")
if not db_dir:
data_dir = Environment.get_data_dir()
db_dir = "%s/db" % data_dir
text.set_value(db_dir)
return div
示例4: copy_start
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_data_dir [as 别名]
def copy_start(my):
#import pdb; pdb.set_trace()
data_dir = Environment.get_data_dir(manual=True)
# check to see if the data folder already exists
print
print "Data Directory [%s]" % data_dir
install_dir = Environment.get_install_dir()
# find criteria for initializing
initialize = False
if data_dir and not os.path.exists(data_dir):
initialize = True
if data_dir and not os.path.exists("%s/config" % data_dir):
initialize = True
if initialize:
# copy the template over. This should exist even if it is not used
print "... not found: initializing\n"
install_data_path = "%s/src/install/start" % (install_dir)
if os.path.exists(install_data_path):
dirnames = os.listdir(install_data_path)
for dirname in dirnames:
to_dir = "%s/%s" % (data_dir, dirname)
if os.path.exists(to_dir):
print "WARNING: path [%s] exists ... skipping copying" % to_dir
continue
print "Copying to [%s]" % to_dir
from_dir = "%s/%s" % (install_data_path, dirname)
shutil.copytree(from_dir, to_dir)
else:
shutil.copytree(install_data_path, data_dir)
#import pdb; pdb.set_trace()
# copy the appropriate config file
if os.name == 'nt':
filename = 'standalone_win32-conf.xml'
else:
filename = 'standalone_linux-conf.xml'
install_config_path = "%s/src/install/config/%s" % (install_dir,filename)
to_config_path = "%s/config/tactic-conf.xml" % data_dir
if not os.path.exists(to_config_path):
dirname = os.path.dirname(to_config_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
shutil.copy(install_config_path, to_config_path)
# some backwards compatibility issues
old_config_path = "%s/config/tactic_linux-conf.xml" % data_dir
if os.path.exists(old_config_path):
new_config_path = "%s/config/tactic-conf.xml" % data_dir
shutil.move(old_config_path, new_config_path)
config_path = Config.get_config_path()
config_exists = False
if os.path.exists(config_path):
config_exists = True
#import pdb; pdb.set_trace()
asset_dir = Environment.get_asset_dir()
print "Asset Directory [%s]" % asset_dir
tmp_dir = Environment.get_tmp_dir()
print "Temp Directory [%s]" % tmp_dir
# check if there is a config path already exists. If it does,
# then don't do anything further. This is likely a previous
# installation
if config_exists:
print "Config_path [%s]" % config_path
return
else:
# if there is no config, retrieve data_dir in non-manual mode
data_dir = Environment.get_data_dir()
f = open("%s/first_run" % data_dir, 'w')
f.write("")
f.close()
return
示例5: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_data_dir [as 别名]
#.........这里部分代码省略.........
# 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()
if my.quiet:
print "Please refer to the upgrade_output.txt file for any upgrade messages."
print
# handle sthpw database separately. This ensures that the project entry
# gets created if none exists.
#print "sthpw"
#print "-"*30
#upgrade = SthpwUpgrade()
#upgrade.set_project("sthpw")
#Command.execute_cmd(upgrade)
# update the template zip files
data_dir = Environment.get_data_dir(manual=False)
dest_dir = '%s/templates' %data_dir
if os.path.exists(dest_dir):
install_dir = Environment.get_install_dir()
src_code_template_dir = '%s/src/install/start/templates' %install_dir
if os.path.exists(src_code_template_dir):
zip_files = os.listdir(src_code_template_dir)
io_errors = False
for zip_file in zip_files:
if not zip_file.endswith(".zip"):
continue
try:
src_file = '%s/%s' %(src_code_template_dir, zip_file)
dest_file = '%s/%s' %(dest_dir, zip_file)
shutil.copyfile(src_file, dest_file)
except IOError, e:
print e
io_errors = True
if not io_errors:
print "Default project template files have been updated."
else:
print "There was a problem copying the default template files to <TACTIC_DATA_DIR>/templates."