def write_code(id, pid, language, code):
'''??????????'''
try:
work_path = os.path.join(config.work_dir, str(id))
os.mkdir(work_path)
except OSError, e:
logging.error(e)
return False
real_path = os.path.join(work_path, config.file_name[language])
f = open(real_path, 'w')
try:
f.write(code.encode('utf-8', 'ignore'))
except Exception, e:
logging.error("%s not write code to file\n%s" % (id, e))
f.close()
return False
f.close()
#os.chmod(work_path, stat.S_IRWXO)
#os.chmod(real_path, stat.S_IRWXO)
return True
评论列表
文章目录