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


Python uuid.uuid1函数代码示例

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


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

示例1: build_plentry_adds

    def build_plentry_adds(playlist_id, song_ids):
        """
        :param playlist_id
        :param song_ids
        """

        mutations = []

        prev_id, cur_id, next_id = None, str(uuid1()), str(uuid1())

        for i, song_id in enumerate(song_ids):
            m_details = {
                "clientId": cur_id,
                "creationTimestamp": "-1",
                "deleted": False,
                "lastModifiedTimestamp": "0",
                "playlistId": playlist_id,
                "source": 1,
                "trackId": song_id,
            }

            if song_id.startswith("T"):
                m_details["source"] = 2  # AA track

            if i > 0:
                m_details["precedingEntryId"] = prev_id
            if i < len(song_ids) - 1:
                m_details["followingEntryId"] = next_id

            mutations.append({"create": m_details})
            prev_id, cur_id, next_id = cur_id, next_id, str(uuid1())

        return mutations
开发者ID:virajkanwade,项目名称:Bunkford,代码行数:33,代码来源:mobileclient.py

示例2: recv_announce

    def recv_announce(self, expiration_time=None, traversal_id=None):
        msg = message.Announcement()
        self.guid = str(uuid.uuid1())
        msg.sender_id = self.guid
        msg.traversal_id = traversal_id or str(uuid.uuid1())

        return self.recv_msg(msg, expiration_time=expiration_time)
开发者ID:kowalski,项目名称:feat,代码行数:7,代码来源:common.py

示例3: test

def test():
    import uuid
    login_output = login_cli_by_account('admin', 'password')
    if login_output.find('%s >>>' % ('admin')) < 0:
        test_util.test_fail('zstack-cli is not display correct name for logined account: %s' % (login_output))

    account_name1 = uuid.uuid1().get_hex()
    account_pass1 = hashlib.sha512(account_name1).hexdigest()
    test_account1 = test_account.ZstackTestAccount()
    test_account1.create(account_name1, account_pass1)
    test_obj_dict.add_account(test_account1)
    login_output = login_cli_by_account(account_name1, account_name1)
    if login_output.find('%s >>>' % (account_name1)) < 0:
        test_util.test_fail('zstack-cli is not display correct name for logined account: %s' % (login_output))
    
    account_name2 = uuid.uuid1().get_hex()
    account_pass2 = hashlib.sha512(account_name2).hexdigest()
    test_account2 = test_account.ZstackTestAccount()
    test_account2.create(account_name2, account_pass2)
    test_obj_dict.add_account(test_account2)
    test_account_uuid2 = test_account2.get_account().uuid
    login_output = login_cli_by_account(account_name2, account_name2)
    if login_output.find('%s >>>' % (account_name2)) < 0:
        test_util.test_fail('zstack-cli is not display correct name for logined account %s' % (login_output))

    logout_output = logout_cli()
    if logout_output.find('- >>>') < 0:
        test_util.test_fail('zstack-cli is not display correct after logout: %s' % (login_output))

    test_account1.delete()
    test_account2.delete()
    test_obj_dict.rm_account(test_account1)
    test_obj_dict.rm_account(test_account2)
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:33,代码来源:test_multi_accounts_cli_login.py

示例4: file_upload

def file_upload(request):
    file = request.FILES.get('file', None)
    type = request.DATA.get('type', None)
    if file:
        # TODO: Streaming Video (FLV, F4V, MP4, 3GP) Streaming Audio (MP3, F4A, M4A, AAC)
        file_name = ''
        thumbnail = ''
        convert = Converter()
        if type == u'video/x-flv':
            uuid_string = str(uuid.uuid1())
            file_name = uuid_string + '.flv'
            thumbnail = uuid_string + '.jpg'
        elif type == u'video/mp4':
            uuid_string = str(uuid.uuid1())
            file_name = uuid_string + '.mp4'
            thumbnail = uuid_string + '.jpg'
        if file_name != '':
            file_path = FILE_PATH + file_name
            with open(file_path, 'wb+') as destination:
                for chunk in file.chunks():
                    destination.write(chunk)
                destination.close()
                convert.thumbnail(file_path, 10, FILE_PATH + thumbnail)
            temp_file = TempFile(name=file_name, path=file_path)
            temp_file.save()
            return Response({
                'file_name': file_name,
                'thumbnail': thumbnail
            })
        else:
            return Response({
                'status': 'Current just support .mp4 && .flv.'
            })
开发者ID:bcc0421,项目名称:MediaServer_Demo,代码行数:33,代码来源:views.py

示例5: request

    def request(self, view, request_type, callback, location=None):
        """
        Send request to daemon process

        :type view: sublime.View
        :type request_type: str
        :type callback: callabel
        :type location: type of (int, int) or None
        """
        logger.info('Sending request to daemon for "{0}"'.format(request_type))

        if location is None:
            location = view.sel()[0].begin()
        current_line, current_column = view.rowcol(location)
        source = view.substr(sublime.Region(0, view.size()))

        if PY3:
            uuid = uuid1().hex
        else:
            uuid = uuid1().get_hex()

        data = {
            'source': source,
            'line': current_line + 1,
            'offset': current_column,
            'filename': view.file_name() or '',
            'type': request_type,
            'uuid': uuid,
        }
        self.stdin.put_nowait((callback, data))
开发者ID:leiserfg,项目名称:SublimeJEDI,代码行数:30,代码来源:utils.py

示例6: us_classifications

 def us_classifications(self):
     """
     Returns list of dictionaries representing us classification
     main:
       class
       subclass
     """
     classes = []
     i = 0
     main = self.xml.classification_national.contents_of('main_classification')
     data = {'class': main[0][:3].replace(' ', ''),
             'subclass': main[0][3:].replace(' ', '')}
     if any(data.values()):
         classes.append([
             {'uuid': str(uuid.uuid1()), 'sequence': i},
             {'id': data['class'].upper()},
             {'id': "{class}/{subclass}".format(**data).upper()}])
         i = i + 1
     if self.xml.classification_national.further_classification:
         further = self.xml.classification_national.contents_of('further_classification')
         for classification in further:
             data = {'class': classification[:3].replace(' ', ''),
                     'subclass': classification[3:].replace(' ', '')}
             if any(data.values()):
                 classes.append([
                     {'uuid': str(uuid.uuid1()), 'sequence': i},
                     {'id': data['class'].upper()},
                     {'id': "{class}/{subclass}".format(**data).upper()}])
                 i = i + 1
     return classes
开发者ID:Grace,项目名称:patentprocessor,代码行数:30,代码来源:application_handler_v42.py

示例7: crawCompanyNews

def  crawCompanyNews(link):
    filterContext = ThemeNewsSpiderUtils.returnStartContext(link,'<div class="listnews" id="TacticNewsList1" >')
    startContext = ThemeNewsSpiderUtils.filterContextByTarget(filterContext,'<ul>','</ul>')
    len = ThemeNewsSpiderUtils.findAllTarget(startContext,'<li')
    newsFlag = 'good'
    currentList = []
    for  i in range(len):
        targetContext = ThemeNewsSpiderUtils.divisionTarget(startContext, '<li>', '</li>')
        startContext = targetContext['nextContext']
        currentcontext =  targetContext['targetContext']
        keyid = str(uuid.uuid1())
        linkUrl = ThemeNewsSpiderUtils.filterContextByTarget(currentcontext,'<a href="', '">')
        pubDate = ThemeNewsSpiderUtils.filterContextByTarget(currentcontext,'<span>','</span>')
        title = ThemeNewsSpiderUtils.filterContextByTarget(currentcontext,'">','</a>')
        if linkUrl != '':
            currentList.append([keyid,linkUrl,pubDate,title,newsFlag])
    
    currentFilterContext = ThemeNewsSpiderUtils.returnStartContext(link,'<div class="listnews" id="TacticNewsList2"  style="display:none;">')
    currentstartContext = ThemeNewsSpiderUtils.filterContextByTarget(currentFilterContext,'<ul>','</ul>')
    currentlen = ThemeNewsSpiderUtils.findAllTarget(currentstartContext,'<li')
    newsFlag = 'bad'
    for  m in range(currentlen):
        targetContext = ThemeNewsSpiderUtils.divisionTarget(currentstartContext, '<li>', '</li>')
        currentstartContext = targetContext['nextContext']
        currentcontext =  targetContext['targetContext']
        keyid = str(uuid.uuid1())
        linkUrl = ThemeNewsSpiderUtils.filterContextByTarget(currentcontext,'<a href="', '">')
        pubDate = ThemeNewsSpiderUtils.filterContextByTarget(currentcontext,'<span>','</span>')
        title = ThemeNewsSpiderUtils.filterContextByTarget(currentcontext,'">','</a>')
        if linkUrl != '':
            currentList.append([keyid,linkUrl,pubDate,title,newsFlag])
    return currentList
开发者ID:timedcy,项目名称:kttspider,代码行数:32,代码来源:ImportantNewsSpider.py

示例8: testCloneModelWithCheckpoint

  def testCloneModelWithCheckpoint(self):
    checkpointMgr = ModelCheckpointMgr()

    modelID = uuid.uuid1().hex
    destModelID = uuid.uuid1().hex

    # Create the source model with meta-info only (no checkpoint)
    modelDef = {'a': 1, 'b': 2, 'c':3}
    checkpointMgr.define(modelID, modelDef)

    # Create a model that we can clone
    model1 = ModelFactory.create(self._getModelParams("variant1"))
    checkpointMgr.save(modelID, model1, attributes="attributes1")

    # Clone the source model
    checkpointMgr.clone(modelID, destModelID)

    # Discard the source model checkpoint
    checkpointMgr.remove(modelID)

    # Verify that the destination model's definition is the same as the
    # source model's
    destModelDef = checkpointMgr.loadModelDefinition(destModelID)
    self.assertDictEqual(destModelDef, modelDef)

    # Verify that the destination model's attributes match the source's
    attributes = checkpointMgr.loadCheckpointAttributes(destModelID)
    self.assertEqual(attributes, "attributes1")

    # Attempt to load the cloned model from checkpoint
    model = checkpointMgr.load(destModelID)
    self.assertEqual(str(model.getFieldInfo()), str(model1.getFieldInfo()))
开发者ID:sergius,项目名称:numenta-apps,代码行数:32,代码来源:model_checkpoint_mgr_test.py

示例9: testRemoveAll

  def testRemoveAll(self):
    """
    Test removeAll
    """
    checkpointMgr = ModelCheckpointMgr()

    # Should be empty at first
    ids = checkpointMgr.getModelIDs()
    self.assertSequenceEqual(ids, [])


    # Create some checkpoints using meta info
    expModelIDs = [uuid.uuid1().hex, uuid.uuid1().hex]
    expModelIDs.sort()
    for modelID in expModelIDs:
      checkpointMgr.define(modelID, definition={'a':1})

    ids = checkpointMgr.getModelIDs()
    self.assertItemsEqual(ids, expModelIDs)

    # Delete checkpoint store
    ModelCheckpointMgr.removeAll()

    ids = checkpointMgr.getModelIDs()
    self.assertSequenceEqual(ids, [])
开发者ID:sergius,项目名称:numenta-apps,代码行数:25,代码来源:model_checkpoint_mgr_test.py

示例10: post

def post():
    try:
    # Get the parsed contents of the form data
      jsonr = request.json
      msg_uuid = uuid.uuid1()
#      pprint.pprint(jsonr)
      kind = jsonr['data']['kind']
      if 'drink_poured' in kind:
	user = jsonr['data']['user']['display_name']
        pour = jsonr['data']['drink']
        beverage = jsonr['data']['keg']['beverage']
	abv = jsonr['data']['keg']['type']['abv']
	style = jsonr['data']['keg']['type']['name']
	left = jsonr['data']['keg']['percent_full']

        producer = beverage['producer']['name']
        img_url = pour['images'][0]['original_url']
        drink = beverage['name']
	volume_ml = pour['volume_ml']
	pints = volume_ml * 0.00211338 

	message = "%s just poured %s pints of %s, a %s %s (%%%s). %%%s remains" % (user, round(pints, 3), drink, producer, style, abv, round(left, 3)) 
	print("Sending to dasher:\n channel: %s\nimg: %s\n message: %s" % (kb_channel_id, img_url, message))
	img_payload = { 'message': img_url, 'uuid': uuid.uuid1() }
        payload = { 'message': message, 'uuid': msg_uuid }
        r = requests.post(kb_post_url, data=img_payload)
        r = requests.post(kb_post_url, data=payload)
      
      # Render template
      return jsonify(jsonr)
    except Exception:
      traceback.print_exc(file=sys.stdout)
开发者ID:ahhdem,项目名称:kegbot-docker,代码行数:32,代码来源:kbdasher.py

示例11: testCloneModelWithDefinitionOnly

  def testCloneModelWithDefinitionOnly(self):
    checkpointMgr = ModelCheckpointMgr()

    modelID = uuid.uuid1().hex
    destModelID = uuid.uuid1().hex

    # Create the source model with meta-info only (no checkpoint)
    modelDef = {'a': 1, 'b': 2, 'c':3}
    checkpointMgr.define(modelID, modelDef)

    # Clone the source model
    checkpointMgr.clone(modelID, destModelID)

    # Verify that the destination model's definition is the same as the
    # source model's
    destModelDef = checkpointMgr.loadModelDefinition(destModelID)
    self.assertDictEqual(destModelDef, modelDef)

    # Calling load when the model checkpoint doesn't exist should raise an
    #  exception
    with self.assertRaises(ModelNotFound):
      checkpointMgr.load(destModelID)

    # Calling clone when the destination model archive already exists should
    # raise an exception
    with self.assertRaises(ModelAlreadyExists):
      checkpointMgr.clone(modelID, destModelID)
开发者ID:sergius,项目名称:numenta-apps,代码行数:27,代码来源:model_checkpoint_mgr_test.py

示例12: create_version_files

def create_version_files ():
    s =''
    s +="#ifndef __TREX_VER_FILE__           \n"
    s +="#define __TREX_VER_FILE__           \n"
    s +="#ifdef __cplusplus                  \n"
    s +=" extern \"C\" {                        \n"
    s +=" #endif                             \n";
    s +='#define  VERSION_USER  "%s"          \n' % os.environ.get('USER', 'unknown')
    s +='extern const char * get_build_date(void);  \n'
    s +='extern const char * get_build_time(void);  \n'
    s +='#define VERSION_UIID      "%s"       \n' % uuid.uuid1()
    s +='#define VERSION_BUILD_NUM "%s"       \n' % get_build_num()
    s +="#ifdef __cplusplus                  \n"
    s +=" }                        \n"
    s +=" #endif                             \n";
    s +="#endif \n"

    write_file (H_VER_FILE ,s)

    s ='#include "version.h"          \n'
    s +='#define VERSION_UIID1      "%s"       \n' % uuid.uuid1()
    s +="const char * get_build_date(void){ \n"
    s +="    return (__DATE__);       \n"
    s +="}      \n"
    s +=" \n"
    s +="const char * get_build_time(void){ \n"
    s +="    return (__TIME__ );       \n"
    s +="}      \n"

    write_file (C_VER_FILE,s)
开发者ID:Meghana-S,项目名称:trex-core,代码行数:30,代码来源:ws_main.py

示例13: test_package_serialization

    def test_package_serialization(self):
        items = [
            self.request_delivery_factory.factory_item(
                ware_key=uuid.uuid1().get_hex()[:10],
                cost=Decimal(450.0 * 30),
                payment=Decimal(450.0),
                weight=500,
                weight_brutto=600,
                amount=4,
                comment=u'Комментарий на русском',
                link=u'http://shop.ru/item/44'
            ),
            self.request_delivery_factory.factory_item(
                ware_key=uuid.uuid1().get_hex()[:10],
                cost=Decimal(250.0 * 30),
                payment=Decimal(250.0),
                weight=500,
                weight_brutto=600,
                amount=4,
                comment=u'Комментарий на русском',
                link=u'http://shop.ru/item/42'
            )
        ]

        package = self.request_delivery_factory.factory_package(
            number=uuid.uuid1().hex[:10],
            weight=3000,
            items=items
        )
        self.assertIsInstance(package, PackageRequestObject)
        tostring(package.to_xml_element(u'Package'), encoding='UTF-8').replace("'", "\"")
开发者ID:rebranch,项目名称:rebranch-cdek-api,代码行数:31,代码来源:tests.py

示例14: test_time_to_uuid

    def test_time_to_uuid(self):
        key = 'key1'
        timeline = []

        timeline.append(time.time())
        time1 = uuid1()
        col1 = {time1:'0'}
        self.cf_time.insert(key, col1)
        time.sleep(0.1)

        timeline.append(time.time())
        time2 = uuid1()
        col2 = {time2:'1'}
        self.cf_time.insert(key, col2)
        time.sleep(0.1)

        timeline.append(time.time())

        cols = {time1:'0', time2:'1'}

        assert_equal(self.cf_time.get(key, column_start=timeline[0])                            , cols)
        assert_equal(self.cf_time.get(key,                           column_finish=timeline[2]) , cols)
        assert_equal(self.cf_time.get(key, column_start=timeline[0], column_finish=timeline[2]) , cols)
        assert_equal(self.cf_time.get(key, column_start=timeline[0], column_finish=timeline[2]) , cols)
        assert_equal(self.cf_time.get(key, column_start=timeline[0], column_finish=timeline[1]) , col1)
        assert_equal(self.cf_time.get(key, column_start=timeline[1], column_finish=timeline[2]) , col2)
开发者ID:enki,项目名称:pycassa,代码行数:26,代码来源:test_autopacking.py

示例15: start_format

    def start_format(self, **kwargs):
        account = kwargs['account']
        self.balance = account.balance
        self.coming = account.coming

        self.output(u'OFXHEADER:100')
        self.output(u'DATA:OFXSGML')
        self.output(u'VERSION:102')
        self.output(u'SECURITY:NONE')
        self.output(u'ENCODING:USASCII')
        self.output(u'CHARSET:1252')
        self.output(u'COMPRESSION:NONE')
        self.output(u'OLDFILEUID:NONE')
        self.output(u'NEWFILEUID:%s\n' % uuid.uuid1())
        self.output(u'<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0<SEVERITY>INFO</STATUS>')
        self.output(u'<DTSERVER>%s113942<LANGUAGE>ENG</SONRS></SIGNONMSGSRSV1>' % datetime.date.today().strftime('%Y%m%d'))
        self.output(u'<BANKMSGSRSV1><STMTTRNRS><TRNUID>%s' % uuid.uuid1())
        self.output(u'<STATUS><CODE>0<SEVERITY>INFO</STATUS><CLTCOOKIE>null<STMTRS>')
        self.output(u'<CURDEF>%s<BANKACCTFROM>' % (account.currency or 'EUR'))
        self.output(u'<BANKID>null')
        self.output(u'<BRANCHID>null')
        self.output(u'<ACCTID>%s' % account.id)
        try:
            account_type = self.TYPES_ACCTS[account.type]
        except IndexError:
            account_type = ''
        self.output(u'<ACCTTYPE>%s' % (account_type or 'CHECKING'))
        self.output(u'<ACCTKEY>null</BANKACCTFROM>')
        self.output(u'<BANKTRANLIST>')
        self.output(u'<DTSTART>%s' % datetime.date.today().strftime('%Y%m%d'))
        self.output(u'<DTEND>%s' % datetime.date.today().strftime('%Y%m%d'))
开发者ID:ngrislain,项目名称:weboob,代码行数:31,代码来源:boobank.py


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