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

Python util.get_uuid函数代码示例

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

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



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

示例1: create_file

    def create_file(self, file):

        if self.validate_file(file, action='create') == False:
            raise IOError('validation failed')
        folder = self.session.query(Folder).filter_by(id=file.get('folder_id'), user_id=self.uid).first()
        uuid = get_uuid(str(self.uid), folder.path, file['name'])
        #content = unicode(file.get('content'), "ISO-8859-1")
        content = file.get('content').encode("ISO-8859-1")
        child_files = self.read_folder(folder.path)['files']

        for i in child_files:
            if file['name'] == i['name']:
                return 'file already exists'

        now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        file_rec = File(folder_id=folder.id, name=file['name'], user_id=self.uid, location=uuid,
                        type=self.storage_type, deleted=False, ctime=now)

        try:
            upload_result = self.storage.create_object(content=content, uuid=uuid)
            if upload_result:
                self.session.add(file_rec)
                self.session.commit()
                return file_rec.serialize
            else:
                self.session.rollback()
        except IOError:
            self.session.rollback()
开发者ID:GiamYe,项目名称:StorageOnline,代码行数:28,代码来源:filesystem.py


示例2: _postMetrics

    def _postMetrics(self):

        if len(self._metrics) > 0:
            self._metrics["uuid"] = get_uuid()
            self._metrics["internalHostname"] = get_hostname(self._agentConfig)
            self._metrics["apiKey"] = self._agentConfig["api_key"]
            MetricTransaction(json.dumps(self._metrics), headers={"Content-Type": "application/json"})
            self._metrics = {}
开发者ID:miketheman,项目名称:dd-agent,代码行数:8,代码来源:ddagent.py


示例3: _postMetrics

    def _postMetrics(self):

        if len(self._metrics) > 0:
            self._metrics['uuid'] = get_uuid()
            self._metrics['internalHostname'] = gethostname(self._agentConfig)
            self._metrics['apiKey'] = self._agentConfig['api_key']
            MetricTransaction(self._metrics, {})
            self._metrics = {}
开发者ID:shawnsmith,项目名称:dd-agent,代码行数:8,代码来源:ddagent.py


示例4: _postMetrics

    def _postMetrics(self):

        if len(self._metrics) > 0:
            self._metrics['uuid'] = get_uuid()
            self._metrics['internalHostname'] = get_hostname(self._agentConfig)
            self._metrics['apiKey'] = self._agentConfig['api_key']
            MetricTransaction(json.dumps(self._metrics),
                              headers={'Content-Type': 'application/json'})
            self._metrics = {}
开发者ID:DavidXArnold,项目名称:dd-agent,代码行数:9,代码来源:ddagent.py


示例5: _build_payload

    def _build_payload(self, start_event=True):
        """
        Return an dictionary that contains all of the generic payload data.
        """
        now = time.time()
        payload = {
            'collection_timestamp': now,
            'os' : self.os,
            'python': sys.version,
            'agentVersion' : self.agentConfig['version'],
            'apiKey': self.agentConfig['api_key'],
            'events': {},
            'metrics': [],
            'service_checks': [],
            'resources': {},
            'internalHostname' : get_hostname(self.agentConfig),
            'uuid' : get_uuid(),
            'host-tags': {},
        }

        # Include system stats on first postback
        if start_event and self._is_first_run():
            payload['systemStats'] = self.agentConfig.get('system_stats', {})
            # Also post an event in the newsfeed
            payload['events']['System'] = [{'api_key': self.agentConfig['api_key'],
                                 'host': payload['internalHostname'],
                                 'timestamp': now,
                                 'event_type':'Agent Startup',
                                 'msg_text': 'Version %s' % get_version()
                                 }]

        # Periodically send the host metadata.
        if self._is_first_run() or self._should_send_metadata():
            payload['systemStats'] = get_system_stats()
            payload['meta'] = self._get_metadata()
            self.metadata_cache = payload['meta']
            # Add static tags from the configuration file
            host_tags = []
            if self.agentConfig['tags'] is not None:
                host_tags.extend([unicode(tag.strip()) for tag in self.agentConfig['tags'].split(",")])

            if self.agentConfig['collect_ec2_tags']:
                host_tags.extend(EC2.get_tags())

            if host_tags:
                payload['host-tags']['system'] = host_tags

            GCE_tags = GCE.get_tags()
            if GCE_tags is not None:
                payload['host-tags'][GCE.SOURCE_TYPE_NAME] = GCE_tags

            # Log the metadata on the first run
            if self._is_first_run():
                log.info("Hostnames: %s, tags: %s" % (repr(self.metadata_cache), payload['host-tags']))

        return payload
开发者ID:arthurnn,项目名称:dd-agent,代码行数:56,代码来源:collector.py


示例6: _build_payload

    def _build_payload(self, start_event=True):
        """
        Return an dictionary that contains all of the generic payload data.
        """
        now = time.time()
        payload = {
            "collection_timestamp": now,
            "os": self.os,
            "python": sys.version,
            "agentVersion": self.agentConfig["version"],
            "apiKey": self.agentConfig["api_key"],
            "events": {},
            "metrics": [],
            "resources": {},
            "internalHostname": get_hostname(self.agentConfig),
            "uuid": get_uuid(),
            "host-tags": {},
        }

        # Include system stats on first postback
        if start_event and self._is_first_run():
            payload["systemStats"] = self.agentConfig.get("system_stats", {})
            # Also post an event in the newsfeed
            payload["events"]["System"] = [
                {
                    "api_key": self.agentConfig["api_key"],
                    "host": payload["internalHostname"],
                    "timestamp": now,
                    "event_type": "Agent Startup",
                    "msg_text": "Version %s" % get_version(),
                }
            ]

        # Periodically send the host metadata.
        if self._is_first_run() or self._should_send_metadata():
            payload["systemStats"] = get_system_stats()
            payload["meta"] = self._get_metadata()
            self.metadata_cache = payload["meta"]
            # Add static tags from the configuration file
            host_tags = []
            if self.agentConfig["tags"] is not None:
                host_tags.extend([unicode(tag.strip()) for tag in self.agentConfig["tags"].split(",")])

            if self.agentConfig["collect_ec2_tags"]:
                host_tags.extend(EC2.get_tags())

            if host_tags:
                payload["host-tags"]["system"] = host_tags

            # Log the metadata on the first run
            if self._is_first_run():
                log.info(u"Hostnames: %s, tags: %s" % (repr(self.metadata_cache), payload["host-tags"]))

        return payload
开发者ID:kzw,项目名称:dd-agent,代码行数:54,代码来源:collector.py


示例7: _build_payload

    def _build_payload(self, start_event=True):
        """
        Return an dictionary that contains all of the generic payload data.
        """
        now = time.time()
        payload = {
            'collection_timestamp': now,
            'os' : self.os,
            'python': sys.version,
            'agentVersion' : self.agentConfig['version'],
            'apiKey': self.agentConfig['api_key'],
            'events': {},
            'metrics': [],
            'resources': {},
            'internalHostname' : get_hostname(self.agentConfig),
            'uuid' : get_uuid(),
        }

        # Include system stats on first postback
        if start_event and self._is_first_run():
            payload['systemStats'] = self.agentConfig.get('system_stats', {})
            # Also post an event in the newsfeed
            payload['events']['System'] = [{'api_key': self.agentConfig['api_key'],
                                 'host': payload['internalHostname'],
                                 'timestamp': now,
                                 'event_type':'Agent Startup',
                                 'msg_text': 'Version %s' % get_version()
                                 }]

        # Periodically send the host metadata.
        if self._is_first_run() or self._should_send_metadata():
            payload['systemStats'] = get_system_stats()
            payload['meta'] = self._get_metadata()
            self.metadata_cache = payload['meta']
            # Add static tags from the configuration file
            if self.agentConfig['tags'] is not None:
                payload['tags'] = self.agentConfig['tags']

            # Log the metadata on the first run
            if self._is_first_run():
                if self.agentConfig['tags'] is not None:
                    log.info(u"Hostnames: %s, tags: %s" \
                        % (repr(self.metadata_cache),
                           self.agentConfig['tags']))
                else:
                    log.info(u"Hostnames: %s" % repr(self.metadata_cache))

        return payload
开发者ID:Vinceveve,项目名称:dd-agent,代码行数:48,代码来源:collector.py


示例8: submit_events

    def submit_events(self, events):
        headers = {"Content-Type": "application/json"}
        event_chunk_size = self.event_chunk_size

        for chunk in chunks(events, event_chunk_size):
            payload = {
                "apiKey": self.api_key,
                "events": {"api": chunk},
                "uuid": get_uuid(),
                "internalHostname": get_hostname(),
            }
            params = {}
            if self.api_key:
                params["api_key"] = self.api_key
            url = "%s/intake?%s" % (self.api_host, urlencode(params))

            self.submit_http(url, json.dumps(payload), headers)
开发者ID:MinerKasch,项目名称:dd-agent,代码行数:17,代码来源:dogstatsd.py


示例9: submit_events

    def submit_events(self, events):
        headers = {'Content-Type':'application/json'}
        event_chunk_size = self.event_chunk_size

        for chunk in chunks(events, event_chunk_size):
            payload = {
                'apiKey': self.api_key,
                'events': {
                    'api': chunk
                },
                'uuid': get_uuid(),
                'internalHostname': get_hostname()
            }
            params = {}
            if self.api_key:
                params['api_key'] = self.api_key
            url = '%s/intake?%s' % (self.api_host, urlencode(params))

            self.submit_http(url, json.dumps(payload), headers)
开发者ID:Shopify,项目名称:dd-agent,代码行数:19,代码来源:dogstatsd.py


示例10: _build_payload

    def _build_payload(self, payload):
        """
        Build the payload skeleton, so it contains all of the generic payload data.
        """
        now = time.time()

        payload["collection_timestamp"] = now
        payload["os"] = self.os
        payload["python"] = sys.version
        payload["agentVersion"] = self.agentConfig["version"]
        payload["apiKey"] = self.agentConfig["api_key"]
        payload["events"] = {}
        payload["metrics"] = []
        payload["service_checks"] = []
        payload["resources"] = {}
        payload["internalHostname"] = self.hostname
        payload["uuid"] = get_uuid()
        payload["host-tags"] = {}
        payload["external_host_tags"] = {}
开发者ID:pvfkb,项目名称:dd-agent,代码行数:19,代码来源:collector.py


示例11: create_file

    def create_file(self, folder_id, file_name):

        folder = self.session.query(Folder).filter_by(id=folder_id, user_id=self.uid).first()
        uuid = get_uuid(folder.path, file_name)

        child_files = self.read_folder(folder_id)['files']

        for i in child_files:
            if file_name == i['name']:
                return 'file already exists'

        file = File(folder_id=folder.id, name=file_name, user_id=self.uid, location=uuid, type='sheepdog', deleted=False)

        upload_result = self.storage.create_object(file=file_name, uuid=uuid)

        if upload_result:
            self.session.add(file)
            self.session.commit()
        else:
            self.session.rollback()
开发者ID:GiamYe,项目名称:StorageOnline,代码行数:20,代码来源:filesystem_backup.py


示例12: _build_payload

    def _build_payload(self):
        """
        Return an dictionary that contains all of the generic payload data.
        """

        payload = {
            'collection_timestamp': time.time(),
            'os' : self.os,
            'python': sys.version,
            'agentVersion' : self.agentConfig['version'],
            'apiKey': self.agentConfig['api_key'],
            'events': {},
            'metrics': [],
            'resources': {},
            'internalHostname' : gethostname(self.agentConfig),
            'uuid' : get_uuid(),
        }

        # Include system stats on first postback
        if self._is_first_run():
            payload['systemStats'] = self.agentConfig.get('system_stats', {})
            # Also post an event in the newsfeed
            payload['events']['System'] = [{'api_key': self.agentConfig['api_key'],
                                 'host': payload['internalHostname'],
                                 'timestamp': int(time.mktime(datetime.datetime.now().timetuple())),
                                 'event_type':'Agent Startup',
                                 'msg_text': 'Version %s' % get_version()
                                 }]

        # Periodically send the host metadata.
        if self._is_first_run() or self._should_send_metadata():
            payload['meta'] = self._get_metadata()
            self.metadata_cache = payload['meta']
            # Add static tags from the configuration file
            if self.agentConfig['tags'] is not None:
                payload['tags'] = self.agentConfig['tags']

        return payload
开发者ID:potto007,项目名称:dd-agent,代码行数:38,代码来源:collector.py


示例13: submit_events

    def submit_events(self, events):
        headers = {'Content-Type':'application/json'}
        method = 'POST'

        events_len = len(events)
        event_chunk_size = self.event_chunk_size

        for chunk in chunks(events, event_chunk_size):
            payload = {
                'apiKey': self.api_key,
                'events': {
                    'api': chunk
                },
                'uuid': get_uuid(),
                'internalHostname': get_hostname()
            }
            params = {}
            if self.api_key:
                params['api_key'] = self.api_key
            url = '/intake?%s' % urlencode(params)

            status = None
            conn = self.http_conn_cls(self.api_host)
            try:
                start_time = time()
                conn.request(method, url, json.dumps(payload), headers)

                response = conn.getresponse()
                status = response.status
                response.close()
                duration = round((time() - start_time) * 1000.0, 4)
                log.debug("%s %s %s%s (%sms)" % (
                                status, method, self.api_host, url, duration))

            finally:
                conn.close()
开发者ID:dhapgood4thscreen,项目名称:dd-agent,代码行数:36,代码来源:dogstatsd.py


示例14: handler

def handler(event, context):
    log.debug("Received event {}".format(json.dumps(event)))
    
    if "Records" in event:
        # from SNS/CFN
        snsData = json.loads(event["Records"][0]["Sns"]["Message"]["message"])
        log.debug("From SNS: %s" % snsData)
        message = snsData["message"]
    else:
        # from APIG or CLI call
        if "httpMethod" in event:
            log.debug("Context: %s" % event['httpMethod'])
            if event["httpMethod"] == "POST":
                # create
                #env_name = event['params']['path']['envname']
                env_name = "dev"
                
                config_path = os.path.join(here, ENV_CONFIG_FILENAME)
                with open(config_path) as json_file:
                    config_dict = json.load(json_file)
                env_dict = config_dict[env_name]
                app_name = config_dict['app_name']
                app_env = '%s-%s' % (app_name, env_name)

                table = dynamodb.Table('BlargotronJobs')
                jobId = get_uuid()
                timestamp = int(time.time())
                log.debug("timestamp: %s" % timestamp)
                table.put_item(
                    Item={
                        'jobId': jobId,
                        'timestamp': timestamp,
                        'env_name': env_name,
                        'steps': [
                            {
                                'name': 'createEnvironment',
                                'template': ENV_CONFIG_FILENAME,
                                'status': 'WAITING'
                            },
                            {
                                'name': 'deployBeanstalkApp',
                                'template': 'ebapp.json',
                                'status': 'WAITING'
                            }
                        ]
                    }
                )

                # now, actually do work
                template_body = generate_application_template(config_dict)
                apply_template(app_name, template_body, wait=True)
#
#                template_body = generate_env_template(app_env, env_dict)
#                apply_template(app_env, template_body, notify=True)


                
            elif event["httpMethod"] == "PUT":
                # update
                log.debug("APIG call: PUT")
        else:
            # CLI call
            log.debug("CLI call")

    return {}
开发者ID:matthewbga,项目名称:blargotron,代码行数:65,代码来源:handler.py


示例15: upload_crop

def upload_crop(image_path, ext):
    response = {}
    pin_width = 0
    pin_height = 0
    if not os.path.exists(image_path):
        response["status"] = True
        response["message"] = "Not found: %s" % image_path
        return response

    image_ext = ext[1:].upper()
    if image_ext == "JPG": image_ext = "JPEG"

    store_dir = _get_image_dir(PHOTO_PATH)
    base_name = get_uuid()
    source_name = "%s_source%s" % (base_name, ext)
    source_path = os.path.join(store_dir, source_name)
    thumb_name = "%s_thumb%s" % (base_name, ext)
    thumb_path = os.path.join(store_dir, thumb_name)
    middle_name = "%s_mid%s" % (base_name, ext)
    middle_path = os.path.join(store_dir, middle_name)

    # source
    try:
        os.rename(image_path, source_path)
    except Exception:
        Log.error("Save source error: %s" % image_path)
        response["status"] = False
        response["message"] = "Save source error: %s" % image_path
        return response

    img = Image.open(source_path)
    # middle
    dest_width = MIDDLE_WIDTH
    width, height = img.size
    if width < dest_width or height < dest_width:
        response["status"] = False
        response["message"] = "Image size too small"
        return response
    dest_height = int(float(dest_width) * float(height) / float(width))
    img_mid = img.resize((dest_width, dest_height), Image.ANTIALIAS)
    img_mid.save(middle_path, image_ext, quality=150)

    pin_width, pin_height = (dest_width, dest_height)

    # thumb
    dest_width, dest_height = THUMB_SIZE
    left, upper, right, lowwer = 0, 0, dest_width, dest_height
    crop_width, crop_height = dest_width, dest_height
    if float(dest_width)/float(dest_height) < float(width)/float(height):
        crop_height = height
        crop_width = int(height * (float(dest_width) / float(dest_height)))
        left = int((width - crop_width) / 2)
        right = left + crop_width
        lowwer = height
    else:
        crop_width = width
        crop_height = int(width * (float(dest_height) / float(dest_width)))
        upper = int((height - crop_height) / 2)
        lowwer = upper + crop_height
        right = width

    box = (left, upper, right, lowwer)
    img_thumb = img.crop(box)
    img_thumb = img_thumb.resize((dest_width, dest_height), Image.ANTIALIAS)
    img_thumb.save(thumb_path, image_ext, quality=150)

    response["status"] = True
    response["source_path"] = source_path
    response["thumb_path"] = thumb_path
    response["middle_path"] = middle_path
    response["height"] = pin_height
    response["width"] = pin_width
    return response
开发者ID:zixiao,项目名称:diggit,代码行数:73,代码来源:image.py


示例16: _build_payload

    def _build_payload(self, start_event=True):
        """
        Return an dictionary that contains all of the generic payload data.
        """
        now = time.time()
        payload = {
            'collection_timestamp': now,
            'os' : self.os,
            'python': sys.version,
            'agentVersion' : self.agentConfig['version'],
            'apiKey': self.agentConfig['api_key'],
            'events': {},
            'metrics': [],
            'service_checks': [],
            'resources': {},
            'internalHostname' : self.hostname,
            'uuid' : get_uuid(),
            'host-tags': {},
            'external_host_tags': {}
        }

        # Include system stats on first postback
        if start_event and self._is_first_run():
            payload['systemStats'] = self.agentConfig.get('system_stats', {})
            # Also post an event in the newsfeed
            payload['events']['System'] = [{'api_key': self.agentConfig['api_key'],
                                 'host': payload['internalHostname'],
                                 'timestamp': now,
                                 'event_type':'Agent Startup',
                                 'msg_text': 'Version %s' % get_version()
                                 }]

        # Periodically send the host metadata.
        if self._should_send_additional_data('metadata'):
            # gather metadata with gohai
            try:
                if get_os() != 'windows':
                    command = "gohai"
                else:
                    command = "gohai\gohai.exe"
                gohai_metadata = subprocess.Popen(
                    [command], stdout=subprocess.PIPE
                ).communicate()[0]
                payload['gohai'] = gohai_metadata
            except OSError as e:
                if e.errno == 2:  # file not found, expected when install from source
                    log.info("gohai file not found")
                else:
                    raise e
            except Exception as e:
                log.warning("gohai command failed with error %s" % str(e))

            payload['systemStats'] = get_system_stats()
            payload['meta'] = self._get_metadata()

            self.metadata_cache = payload['meta']
            # Add static tags from the configuration file
            host_tags = []
            if self.agentConfig['tags'] is not None:
                host_tags.extend([unicode(tag.strip()) for tag in self.agentConfig['tags'].split(",")])

            if self.agentConfig['collect_ec2_tags']:
                host_tags.extend(EC2.get_tags(self.agentConfig))

            if host_tags:
                payload['host-tags']['system'] = host_tags

            GCE_tags = GCE.get_tags(self.agentConfig)
            if GCE_tags is not None:
                payload['host-tags'][GCE.SOURCE_TYPE_NAME] = GCE_tags

            # Log the metadata on the first run
            if self._is_first_run():
                log.info("Hostnames: %s, tags: %s" % (repr(self.metadata_cache), payload['host-tags']))

        # Periodically send extra hosts metadata (vsphere)
        # Metadata of hosts that are not the host where the agent runs, not all the checks use
        # that
        external_host_tags = []
        if self._should_send_additional_data('external_host_tags'):
            for check in self.initialized_checks_d:
                try:
                    getter = getattr(check, 'get_external_host_tags')
                    check_tags = getter()
                    external_host_tags.extend(check_tags)
                except AttributeError:
                    pass

        if external_host_tags:
            payload['external_host_tags'] = external_host_tags

        return payload
开发者ID:AirbornePorcine,项目名称:dd-agent,代码行数:92,代码来源:collector.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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