本文整理匯總了Python中Cerebrum.Utils.make_temp_dir方法的典型用法代碼示例。如果您正苦於以下問題:Python Utils.make_temp_dir方法的具體用法?Python Utils.make_temp_dir怎麽用?Python Utils.make_temp_dir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cerebrum.Utils
的用法示例。
在下文中一共展示了Utils.make_temp_dir方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _make_password_document
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import make_temp_dir [as 別名]
def _make_password_document(self, filename, account, password, tpl):
""" Make the password document to print.
:param str filename:
Basename of the document.
:param Cerebrum.Account account:
The account to generate a password document for.
:param str password:
The new password for the account.
:param dict tpl:
The template to use (output from __list_password_print_options).
:return str: The full path to the generated document.
"""
self.logger.debug("make_password_document: Selected template %r", tpl)
th = TemplateHandler(tpl.get('lang'), tpl.get('type'), tpl.get('fmt'))
# TODO: We should use a <prefix>/var/cache/ or <prefix>/tmp/ dir for
# this, NOT a logging dir. Also, we should consider the read access to
# these files.
tmp_dir = Utils.make_temp_dir(dir=cereconf.JOB_RUNNER_LOG_DIR,
prefix="bofh_spool")
self.logger.debug(
"make_password_letter: temp dir=%r template=%r", tmp_dir, filename)
output_file = os.path.join(tmp_dir, filename)
mapping = self._get_mappings(account, tpl)
mapping.update({
'uname': account.account_name,
'password': password,
'account_id': account.entity_id,
'lopenr': ''})
# Barcode
if 'barcode' in mapping:
mapping['barcode'] = os.path.join(tmp_dir, mapping['barcode'])
try:
th.make_barcode(account.entity_id, mapping['barcode'])
except IOError, msg:
self.logger.error(
"make_password_letter: unable to make barcode (%s)", msg)
raise CerebrumError(msg)