当前位置: 首页>>代码示例>>Python>>正文


Python uuid.uuid函数代码示例

本文整理汇总了Python中uuid.uuid函数的典型用法代码示例。如果您正苦于以下问题:Python uuid函数的具体用法?Python uuid怎么用?Python uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_simple_add

    def test_simple_add(self):

        # Add one slot together with a timespan
        allocation = Allocation(raster=15, resource=uuid())
        allocation.start = datetime(2011, 1, 1, 15)
        allocation.end = datetime(2011, 1, 1, 15, 59)
        allocation.group = uuid()

        reservation = uuid()

        slot = ReservedSlot(resource=allocation.resource)
        slot.start = allocation.start
        slot.end = allocation.end
        slot.allocation = allocation
        slot.reservation = reservation
        allocation.reserved_slots.append(slot)

        # Ensure that the same slot cannot be doubly used
        anotherslot = ReservedSlot(resource=allocation.resource)
        anotherslot.start = allocation.start
        anotherslot.end = allocation.end
        anotherslot.allocation = allocation
        anotherslot.reservation = reservation

        Session.add(anotherslot)
        self.assertRaises(IntegrityError, Session.flush)
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:26,代码来源:test_reserved_slot.py

示例2: get_visitor_id

def get_visitor_id():
    prev_visitors= set(os.listdir(results_dir))

    new_id= uuid().hex
    while new_id in prev_visitors: new_id=uuid().hex

    return new_id
开发者ID:johndpope,项目名称:automusica,代码行数:7,代码来源:controllers.py

示例3: __init__

 def __init__(self, *args, **kwargs):
     fk_fs_type = kwargs.get('fk_fs_type', None)
     if fk_fs_type != None:
        self.fk_fs_type = uuid.uuid()
     fs_uuid = kwargs.get('fs_uuid', None)
     if fs_uuid != None:
        self.fs_uuid = uuid.uuid()
开发者ID:osynge,项目名称:pmpman,代码行数:7,代码来源:db_devices.py

示例4: getLock

def getLock(name = None):
	if not name:
		name = str(uuid())
		while name in locks:
			name = str(uuid())
	if not name in locks:
		locks[name] = SingleLock() if name[0] == '#' else ReentLock()
	return locks[name]
开发者ID:mrozekma,项目名称:Rorn,代码行数:8,代码来源:Lock.py

示例5: test_export

 def test_export(self):
     commitish = uuid().hex
     dest = '/home/' + uuid().hex
     self.git.export(commitish, dest)
     self.subprocess.assertExistsCommand(
         lambda c: c.startswith('git archive') and commitish in c)
     self.subprocess.assertExistsCommand(
         lambda c: dest in c)
开发者ID:league,项目名称:yadda,代码行数:8,代码来源:test_git.py

示例6: add_something

def add_something(resource=None):
    resource = resource or uuid()
    allocation = Allocation(raster=15, resource=resource, mirror_of=resource)
    allocation.start = datetime(2011, 1, 1, 15)
    allocation.end = datetime(2011, 1, 1, 15, 59)
    allocation.group = uuid()

    Session.add(allocation)
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:8,代码来源:test_session.py

示例7: _create_allocation

 def _create_allocation(self):
     allocation = Allocation(raster=15, resource=uuid())
     allocation.start = datetime(2011, 1, 1, 15, 00)
     allocation.end = datetime(2011, 1, 1, 16, 00)
     allocation.group = str(uuid())
     allocation.mirror_of = allocation.resource
     Session.add(allocation)
     return allocation
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:8,代码来源:test_allocation.py

示例8: test_local_config

 def test_local_config(self):
     k = uuid().hex
     v = uuid().hex
     self.git.set_local_config(k, v)
     self.subprocess.assertLastCommandStartsWith('git config')
     self.subprocess.assertLastCommandContains(k)
     pred = lambda c: c.startswith('git config') and k in c
     self.subprocess.provideResult(pred, v)
     self.assertEqual(v, self.git.get_local_config(k))
开发者ID:league,项目名称:yadda,代码行数:9,代码来源:test_git.py

示例9: write

 def write(self):
     message_header = ET.Element('MessageHeader')
     self.__add_element_with_text(message_header, "MessageThreadId", str(uuid()))
     self.__add_element_with_text(message_header, "MessageId", str(uuid()))
     message_header.append(self.sender.write())
     message_header.append(self.recipient.write())
     created_date = ET.SubElement(message_header, "MessageCreatedDateTime")
     created_date.text = d.datetime.now().replace(microsecond=0).isoformat()+ "Z" 
     return message_header
开发者ID:citizenTFA,项目名称:DDEXUI,代码行数:9,代码来源:message_header.py

示例10: setUp

    def setUp(self):
        super(TestExternalLedgerEntryWithFullName, self).setUp()
        self.currency = CurrencyModel.query.filter_by(code='USD').first()
        self.fee = FeeModel.query.get(1)

        n = uuid().hex
        self.user = self.create_user(n, '%s %s' % (n[:16], n[16:]))
        self.user_balance = self.create_balance(user=self.user, currency_code='USD')

        self.campaign = self.create_campaign(uuid().hex, uuid().hex)
        self.campaign_balance = self.create_balance(campaign=self.campaign, currency_code='USD')
开发者ID:pooldin,项目名称:pooldlib,代码行数:11,代码来源:test_transact.py

示例11: make_commit

    def make_commit(self):
        """
        Makes a random commit in the current branch.
        """
        fragment = uuid().hex[:8]
        filename = join(self.repodir, fragment)
        with open(filename, 'w') as fh:
            fh.write(uuid().hex)

        self.repo.index.add([basename(filename)])
        self.repo.index.commit('Adding {0}'.format(basename(filename)))
开发者ID:Mondego,项目名称:pyreco,代码行数:11,代码来源:allPythonContent.py

示例12: __init__

    def __init__(self, server, port=6667, nick="", realname=""):
        self.server = server
        self.port = 6667
        self.nickname = nick
        self.realname = nick
        self.conn = None
        self.version = "IRC python generic custom bot 2014"

        self.events= {
                      "ctcp":{
                              uuid(): lambda is_request, origin, command, message: None if command.upper()!="PING" else self.ctcp_reply(origin,command,(message,)),
                              uuid(): lambda is_request, origin, command, message: None if command.upper()!="VERSION" else self.ctcp_reply(origin,command,(self.version,))
                             }
                      }
开发者ID:Peping,项目名称:Lal,代码行数:14,代码来源:IRC.py

示例13: setUp

    def setUp(self):
        self.SMTP_patcher = patch("pooldlib.api.communication.mail.smtplib")
        self.SMTP_patcher.start()
        self.email = email.Email(None, None)
        self.addCleanup(self.SMTP_patcher.stop)

        self.username_a = uuid().hex
        self.name_a = "%s %s" % (self.username_a[:16], self.username_a[16:])
        self.email_a = "%[email protected]" % self.username_a
        self.user_a = self.create_user(self.username_a, self.name_a, self.email_a)

        self.username_b = uuid().hex
        self.name_b = "%s %s" % (self.username_b[:16], self.username_b[16:])
        self.email_b = "%[email protected]" % self.username_b
        self.user_b = self.create_user(self.username_b, self.name_b, self.email_b)
开发者ID:pooldin,项目名称:pooldlib,代码行数:15,代码来源:test_mail.py

示例14: getCounter

def getCounter(name = None, start = 0, unique = False):
	if name:
		base = name
		idx = 1
		while unique and name in counters:
			idx += 1
			name = "%s-%d" % (base, idx)
	else:
		name = str(uuid())
		while name in counters:
			name = str(uuid())

	if not name in counters:
		counters[name] = Counter(start)
	return counters[name]
开发者ID:mrozekma,项目名称:Rorn,代码行数:15,代码来源:Lock.py

示例15: generate

def generate():
    width = 720
    height = 300
    white = (255, 255, 255)

    rexp = ["sin(pi*i/x)","cos(pi*i/x)"][randint(0,1)]
    gexp = ["cos((pi*i*j)/x)","sin((pi*i*j)/x)"][randint(0,1)]
    bexp = ["sin(pi*j/x)","cos(pi*j/x)"][randint(0,1)]
    tileSize = randint(2,5) 
    x = float([3,5,7,11,13,17,19,21][randint(0,7)]) 

    image = Image.new("RGB", (width, height), white)
    draw = ImageDraw.Draw(image)

    for i in xrange(0,720,tileSize):
        for j in xrange(0,480,tileSize):
            r = int(eval(rexp)*1000%255)
            g = int(eval(gexp)*1000%255)
            b = int(eval(bexp)*1000%255)

            tileColor = "#"+hex(r)[2:].zfill(2)+hex(g)[2:].zfill(2)+hex(b)[2:].zfill(2)
            draw.rectangle([(i,j),(i+tileSize,j+tileSize)], tileColor, None)

    path = "static/img/"
    fileName = str(uuid().int)+".jpg"
    image.save(path+fileName, 'JPEG')

    return path+fileName
开发者ID:sas5580,项目名称:Abstract-Art-Generator,代码行数:28,代码来源:imageGenerator.py


注:本文中的uuid.uuid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。