• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python uuid.uuid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: add_handler

    def add_handler(self, event_name, handler):
        id= uuid()
        if event_name in self.events.keys():
            self.events[event_name][id] = handler
        else: self.events[event_name] = {id: handler}

        return id
开发者ID:Peping,项目名称:Lal,代码行数:7,代码来源:IRC.py


示例17: canvas1

def canvas1(name=None, x=750, y=535):
    """
    creates a new TCanvas 750px wide, usual aspect ratio
    """
    title = name or str(uuid())
    c =  ROOT.TCanvas(title, title, x, y)
    return c
开发者ID:kocolosk,项目名称:analysis,代码行数:7,代码来源:graphics.py


示例18: pre_save_parameter

def pre_save_parameter(sender, **kwargs):

    # the object can be accessed via kwargs 'instance' key.
    parameter = kwargs['instance']

    if parameter.name.units.startswith('image') \
            and parameter.name.data_type == ParameterName.FILENAME:
        if parameter.string_value:
            from base64 import b64decode
            from os import mkdir
            from os.path import exists, join
            from uuid import uuid4 as uuid

            exp_id = parameter.getExpId()

            dirname = join(settings.FILE_STORE_PATH, str(exp_id))
            filename = str(uuid())
            filepath = join(dirname, filename)

            b64 = parameter.string_value
            modulo = len(b64) % 4
            if modulo:
                b64 += (4 - modulo) * '='

            if not exists(dirname):
                mkdir(dirname)
            f = open(filepath, 'w')
            try:
                f.write(b64decode(b64))
            except TypeError:
                f.write(b64)
            f.close()
            parameter.string_value = filename
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:33,代码来源:models.py


示例19: start

    def start(self, process=False, link=None):
        """
        Start a new thread or process that invokes this manager's
        ``run()`` method. The invocation of this method returns
        immediately after the task or process has been started.
        """

        if process:
            # Parent<->Child Bridge
            if link is not None:
                from circuits.net.sockets import Pipe
                from circuits.core.bridge import Bridge

                channels = (uuid(),) * 2
                parent, child = Pipe(*channels)
                bridge = Bridge(parent, channel=channels[0]).register(link)

                args = (child,)
            else:
                args = ()
                bridge = None

            self.__process = Process(target=self.run, args=args, name=self.name)
            self.__process.daemon = True
            self.__process.start()

            return self.__process, bridge
        else:
            self.__thread = Thread(target=self.run, name=self.name)
            self.__thread.daemon = True
            self.__thread.start()

            return self.__thread, None
开发者ID:carriercomm,项目名称:circuits,代码行数:33,代码来源:manager.py


示例20: __init__

 def __init__(self, *args, **kwargs):
     super(YahooContactImporter, self).__init__(*args, **kwargs)
     self.request_token_url = REQUEST_TOKEN_URL
     self.request_auth_url = REQUEST_AUTH_URL
     self.token_url = TOKEN_URL
     self.oauth_timestamp = int(time())
     self.oauth_nonce = md5("%s%s" % (uuid(), self.oauth_timestamp)).hexdigest()
开发者ID:nkunihiko,项目名称:contact_importer,代码行数:7,代码来源:yahoo.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python uuid.uuid1函数代码示例发布时间:2022-05-26
下一篇:
Python uuid.should_receive函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap