本文整理匯總了Python中misc.Misc.random3digit方法的典型用法代碼示例。如果您正苦於以下問題:Python Misc.random3digit方法的具體用法?Python Misc.random3digit怎麽用?Python Misc.random3digit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類misc.Misc
的用法示例。
在下文中一共展示了Misc.random3digit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_ec2_unique_name
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import random3digit [as 別名]
def generate_ec2_unique_name(self, env, puppet_role, num):
"""
This function generates x number of unique ec2 instance names
:param env: Which environment should the names be generated to
:param puppet_role: What is the puppet_role being used
:param num: How many name should be generated
:return: An array of of names generated
"""
ret = []
for i in range(num):
name = None
logger.debug("Arguments are: env: %s, puppet_role: %s" % (env, puppet_role))
while name is None:
name = env + '-' + puppet_role + '-' + Misc.random3digit()
name = self.ec2_instance_name_exist(name=name)
logger.info("Generated instance name is %s" % (name,))
if name and name not in ret:
ret.append(name)
else:
name = None
return ret
示例2: test_random3digit
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import random3digit [as 別名]
def test_random3digit(self):
random = Misc.random3digit()
self.assertRegexpMatches(random,"\d{1,3}")