本文整理汇总了Python中pyasm.common.Environment.get_tmp_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_tmp_dir方法的具体用法?Python Environment.get_tmp_dir怎么用?Python Environment.get_tmp_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Environment
的用法示例。
在下文中一共展示了Environment.get_tmp_dir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def execute(self):
tmp_dir = Environment.get_tmp_dir()
# remove the sidebar cache
sidebar_cache_dir = "%s/cache/side_bar" % tmp_dir
if os.path.exists(sidebar_cache_dir):
import shutil
shutil.rmtree(sidebar_cache_dir)
示例2: startup
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def startup(port, server=""):
from tactic.startup import FirstRunInit
cmd = FirstRunInit()
cmd.execute()
log_dir = "%s/log" % Environment.get_tmp_dir()
if not os.path.exists(log_dir):
os.makedirs(log_dir)
try:
file = open("%s/pid.%s" % (log_dir,port), "w")
pid = os.getpid()
file.write(str(pid))
file.close()
except IOError, e:
if e.errno == 13:
print
print "Permission error opening the file [%s/pid.%s]." % (log_dir,port)
print
if os.name=='nt':
print "You may need to run this shell as the Administrator."
else:
print "The file should be owned by the same user that runs this startup.py process."
sys.exit(2)
示例3: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def execute(my):
SearchType.set_project(my.project)
# multiple layers can get rendered
for search_key in my.search_keys:
f = file('%s/temp/render_exec.jsfl' % Environment.get_tmp_dir(), 'w')
render_command = my.get_render_command(search_key, my.cam_search_key)
f.write(render_command)
f.write(my.get_render_log_command())
f.close()
os.startfile( "\"%s\"" %f.name)
my.remove_file(my.get_render_log_path())
# check if the render is done
sys.stdout.write("\nRendering")
while not os.path.isfile(my.get_render_log_path()):
sys.stdout.write('. ')
time.sleep(2)
print
f = file(my.get_render_log_path(), 'a')
now = time.localtime(time.time())
f.write(' at %s' %time.asctime(now))
f.close()
#my.convert_images()
print("Checking in Render. . .")
my.checkin_render()
示例4: _check
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def _check(self):
# This will kill the TACTIC process
# This is very harsh and should be used sparingly if at all
use_restart = Config.get_value("services", "use_periodic_restart")
if use_restart in [True, 'true']:
if self.num_checks and self.num_checks % self.kill_interval == 0:
# read pid file
log_dir = "%s/log" % Environment.get_tmp_dir()
file = open("%s/pid.%s" % (log_dir,self.port), "r")
pid = file.read()
file.close()
Common.kill(pid)
#self.run()
self.num_checks += 1
return
self.num_checks += 1
start = time.clock()
try:
response = self.check()
except IOError, e:
pid = self._get_pid()
if pid:
Common.kill(pid)
示例5: final_kill
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def final_kill(self):
'''Kill the startup, startup_queue, watch_folder processes. This is used primarily in Windows Service.
Linux service should have actively killed the processes already'''
log_dir = "%s/log" % Environment.get_tmp_dir()
files = os.listdir(log_dir)
ports = []
watch_folders = []
queues = []
for filename in files:
base, ext = os.path.splitext(filename)
if base == 'pid':
ports.append(ext[1:])
elif base == 'watch_folder':
watch_folders.append(ext[1:])
elif base == 'startup_queue':
queues.append(ext[1:])
for port in ports:
try:
file_name = "%s/pid.%s" % (log_dir,port)
file = open(file_name, "r")
pid = file.readline().strip()
file.close()
Common.kill(pid)
except IOError, e:
continue
示例6: get_side_bar_cache
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def get_side_bar_cache(my, left_nav_wdg):
project = Project.get()
project_code = project.get_code()
# do it with sobject
#key = "%s_side_bar" % project.get_code()
#cache = Search.get("sthpw/widget_cache")
#cache.add_filter("key", key)
#sobject = cache.get_sobject()
#value = sobject.get_value("cache")
login = Environment.get_user_name()
tmp_dir = "%s/cache/side_bar" % Environment.get_tmp_dir()
filename = "%s__%s.html" % (project_code, login)
path = "%s/%s" % (tmp_dir, filename)
# use files
import os
if os.path.exists(path):
f = open(path, "r")
html = f.read()
f.close()
else:
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname)
f = open(path, "w")
html = left_nav_wdg.get_buffer_display()
f.write(html)
f.close()
return html
示例7: handle_encrypted
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def handle_encrypted(my, base_dir, transaction_code, encrypted):
key = my.ticket
from_path = "%s/%s" % (base_dir, encrypted)
tmp_dir = Environment.get_tmp_dir(include_ticket=True)
if encrypted.endswith(".enc"):
to_path = "%s/%s" % (tmp_dir, encrypted)
to_path = to_path.replace(".enc", "")
encrypt_util = EncryptUtil(key)
encrypt_util.decrypt_file(from_path, to_path)
zip_util = ZipUtil()
to_dir = os.path.dirname(to_path)
zip_util.extract(to_path)
else:
to_path = from_path
to_dir = tmp_dir
zip_util = ZipUtil()
zip_util.extract(to_path, to_dir)
dirname = encrypted.replace(".enc", "")
dirname = dirname.replace(".zip", "")
print "Running transaction: [%s]" % transaction_code
my.handle_transaction(to_dir, transaction_code, dirname)
示例8: get_render_dir
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def get_render_dir(my):
ticket = Environment.get_security().get_ticket_key()
tmpdir = Environment.get_tmp_dir()
render_dir = "%s/temp/%s" % (tmpdir, ticket)
System().makedirs(render_dir)
return render_dir
示例9: convert_file
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def convert_file(self, src_path, dst_path):
upgrade_dir = Environment.get_upgrade_dir()
tmp_dir = Environment.get_tmp_dir()
dir = os.path.dirname(dst_path)
if dir and not os.path.exists(dir):
os.makedirs(dir)
f = open(src_path, 'r')
f2 = open(dst_path, 'w')
# prepend lines
lines = self.get_prepend_lines()
for line in lines:
f2.write(line)
for line in f.xreadlines():
line = self.handle_line(line)
if line == None:
continue
f2.write(line)
f.close()
f2.close()
return dst_path
示例10: write_log
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def write_log(self, msg):
'''for debugging only'''
log_dir = "%s/log" % Environment.get_tmp_dir()
f = open('%s/monitor.log' % log_dir,'a')
import datetime
f.write('\nTime: %s\n\n' %datetime.datetime.now())
f.write('%s\n'%msg)
示例11: start
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def start(cls):
print "Running Watch Folder ..."
# Check whether the user define the drop folder path.
# Default dop folder path: /tmp/drop
parser = OptionParser()
parser.add_option("-p", "--project", dest="project", help="Define the project_name.")
parser.add_option("-d", "--drop_path", dest="drop_path", help="Define drop folder path")
parser.add_option("-s", "--search_type", dest="search_type", help="Define search_type.")
parser.add_option("-P", "--process", dest="process", help="Define process.")
parser.add_option("-S", "--script_path",dest="script_path", help="Define script_path.")
(options, args) = parser.parse_args()
if options.project != None :
project_code= options.project
else:
project_code= 'jobs'
if options.drop_path!=None :
drop_path= options.drop_path
else:
tmp_dir = Environment.get_tmp_dir()
drop_path = "%s/drop" % tmp_dir
print " using [%s]" % drop_path
if not os.path.exists(drop_path):
os.makedirs(drop_path)
if options.search_type!=None :
search_type = options.search_type
else:
search_type = 'jobs/media'
if options.process!=None :
process = options.process
else:
process= 'publish'
if options.script_path!=None :
script_path = options.script_path
else:
script_path="None"
task = WatchDropFolderTask(base_dir=drop_path, project_code=project_code,search_type=search_type, process=process,script_path=script_path)
scheduler = Scheduler.get()
scheduler.add_single_task(task, delay=1)
scheduler.start_thread()
return scheduler
示例12: _get_pid
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def _get_pid(self):
'''Get PID from a file'''
log_dir = "%s/log" % Environment.get_tmp_dir()
pid_path = "%s/pid.%s" % (log_dir, self.port)
pid = 0
if os.path.exists(pid_path):
file = open(pid_path, "r")
pid = file.read()
file.close()
return pid
示例13: write_stop_monitor
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def write_stop_monitor():
'''write a stop.monitor file to notify TacticMonitor to exit'''
log_dir = "%s/log" % Environment.get_tmp_dir()
if not os.path.exists(log_dir):
os.makedirs(log_dir)
file = open("%s/stop.monitor" % log_dir, "w")
pid = os.getpid()
file.write(str(pid))
file.close()
示例14: convert_upgrade
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def convert_upgrade(self, namespace):
self.namespace = namespace
upgrade_dir = Environment.get_upgrade_dir()
tmp_dir = Environment.get_tmp_dir()
src_path ="%s/project/%s_upgrade.py" % (upgrade_dir, namespace)
dst_path = "%s/upgrade/%s/%s_upgrade.py" % (tmp_dir, self.vendor, namespace)
self.convert_file(src_path, dst_path)
return dst_path
示例15: postprocess
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_tmp_dir [as 别名]
def postprocess(my):
if my.sobject.is_general_asset():
return
# check to see if there are any snapshots
# context is specified here to ignore any icon snapshots
snapshot = Snapshot.get_latest_by_sobject(my.sobject, context='publish')
if snapshot:
return
column = "snapshot"
new_file_paths = []
file_paths = []
# copy the default file to /tmp
template_code = my.get_default_code()
template = my.get_template_obj()
if template:
template_code = template.get_value('code')
tmpl_snapshot = Snapshot.get_latest_by_sobject(template)
file_paths = tmpl_snapshot.get_all_lib_paths()
else:
file_types = ['.fla','.png','_icon.png','.swf']
# TODO: this is a web depedency we don't need
from pyasm.web import WebContainer
web = WebContainer.get_web()
for type in file_types:
file_paths.append('%s/template/%s%s' % (web.get_context_dir(), \
template_code, type))
for file_path in file_paths:
# rename and copy each file to /tmp
base_name = os.path.basename(file_path)
base_name = File.remove_file_code(base_name)
base_name = base_name.replace(template_code, \
my.get_naming().get_current_code(my.sobject) )
# do a straight copy : No undo
tmp_dir = Environment.get_tmp_dir()
new_file_path = "%s/download/%s" % (tmp_dir,base_name)
shutil.copyfile(file_path, new_file_path)
new_file_paths.append(new_file_path)
file_types = [".fla", ".png", "icon",".swf"]
checkin = FileCheckin( my.sobject, new_file_paths, file_types, \
snapshot_type="flash", column=column )
checkin.execute()