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


Python users.get_user_property函数代码示例

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


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

示例1: get

    def get(self):
        username = self.get_current_user().encode('utf-8')
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            os_code = self.get_argument('os_code', None)
            os_string = self.get_argument('os_string', None)
            if not os_code and not os_string or os_code and not os_string:
                data = get_supported_os_codes()

            elif os_string:
                data = get_supported_os_strings(customer_name)

            results = (
                GenericResults(
                    username, uri, method
                ).information_retrieved(data, len(data))
            )
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke('Get OS Codes', 'Agent', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:35,代码来源:agent.py

示例2: delete

    def delete(self, agent_id):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            agent = AgentManager(agent_id, customer_name=customer_name)
            delete_oper = StorePatchingOperation(username, customer_name, uri, method)
            delete_oper.uninstall_agent(agent_id)
            results = agent.delete_agent(uri, method)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke(agent_id, 'delete agent', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:26,代码来源:agent.py

示例3: put

    def put(self, agent_id):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            operation_id = self.arguments.get('operation_id')
            error = self.arguments.get('error', None)
            success = self.arguments.get('success')
            results = (
                AgentOperationResults(
                    username, agent_id, operation_id,
                    success, error, uri, method
                )
            )
            results_data = results.shutdown()
            self.set_status(results_data['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(dumps(results_data, indent=4))
            send_notifications(username, customer_name, operation_id, agent_id)
        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke(agent_id, 'shutdown results', e)
            )
            logger.exception(results)

            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:33,代码来源:results.py

示例4: get

 def get(self):
     username = self.get_current_user().encode('utf-8')
     customer_name = (
         get_user_property(username, UserKeys.CurrentCustomer)
     )
     uri = self.request.uri
     method = self.request.method
     try:
         app_stats = (
             get_all_app_stats_by_customer(customer_name)
         )
         results = (
             GenericResults(
                 username, uri, method
             ).information_retrieved(app_stats)
         )
         self.set_status(results['http_status'])
         self.set_header('Content-Type', 'application/json')
         self.write(json.dumps(results, indent=4))
     except Exception as e:
         results = (
             GenericResults(
                 username, uri, method
             ).something_broke('widget handler', 'widgets', e)
         )
         logger.exception(results)
         self.set_status(results['http_status'])
         self.set_header('Content-Type', 'application/json')
         self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:29,代码来源:stats_api.py

示例5: delete

    def delete(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            mouse_names = self.arguments.get('names')
            mm = MightyMouse(username, customer_name, uri, method)
            for mouse in mouse_names:
                results = mm.remove(mouse_name)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke(agent_id, 'delete agent', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:26,代码来源:relay_servers.py

示例6: post

    def post(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            mouse_name = self.arguments.get('name')
            address = self.arguments.get('address')
            customers = self.arguments.get('customers', None)
            mm = MightyMouse(username, customer_name, uri, method)
            results = mm.add(mouse_name, address, customers)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke(agent_id, '', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:27,代码来源:relay_servers.py

示例7: get

    def get(self, mouse_name):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            mouse = mouse_exists(mouse_name)
            mouse = [mouse]
            results = (
                GenericResults(
                    username, uri, method
                ).information_retrieved(mouse, len(mouse))
            )

            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke(mouse_name, 'get mouse', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:29,代码来源:relay_servers.py

示例8: delete

    def delete(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            tag_id = self.arguments.get('id', None)
            if tag_id:
                tag = TagsManager(username, customer_name, uri, method)
                results = tag.remove_tag(tag_id)

            else:
                results = (
                    GenericResults(
                        username, uri, method
                    ).incorrect_arguments()
                )

            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke('agentids and tag_id', 'delete agents_in_tagid', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:34,代码来源:tag_api.py

示例9: put

    def put(self, agent_id):
        try:
            username = self.get_current_user()
            customer_name = get_user_property(username, UserKeys.CurrentCustomer)
            uri = self.request.uri
            method = self.request.method
            rebooted = self.arguments.get(AgentKey.Rebooted)
            plugins = self.arguments.get(AgentKey.Plugins)
            system_info = self.arguments.get(AgentKey.SystemInfo)
            hardware = self.arguments.get(AgentKey.Hardware)
            logger.info("data received on startup: %s" % self.request.body)
            agent_data = update_agent(agent_id, system_info, hardware, rebooted, username, customer_name, uri, method)
            uris = get_result_uris(agent_id, username, uri, method)
            uris[AgentOperationKey.Operation] = AgentOperations.REFRESH_RESPONSE_URIS
            agent_data.pop("data")
            agent_data["data"] = [uris]
            self.set_status(agent_data["http_status"])

            if agent_data["http_status"] == 200:
                if "rv" in plugins:
                    RvHandOff(username, customer_name, uri, method).startup_operation(agent_id, plugins["rv"]["data"])

                if "ra" in plugins:
                    RaHandoff.startup(agent_id, plugins["ra"])

            self.set_header("Content-Type", "application/json")
            self.write(dumps(agent_data))

        except Exception as e:
            status = GenericResults(username, uri, method).something_broke(agent_id, "startup", e)

            logger.exception(status["message"])
            self.write(dumps(status))
开发者ID:ttysteale,项目名称:vFense,代码行数:33,代码来源:startup.py

示例10: get

    def get(self):
        username = self.get_current_user().encode('utf-8')
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            results = (
                get_all_notifications(
                    username, customer_name,
                    uri, method
                )
            )
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke('Get list of notifications', 'notifications', e)
            )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:28,代码来源:notification_handler.py

示例11: get

    def get(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        query = self.get_argument('query', None)
        count = int(self.get_argument('count', 30))
        offset = int(self.get_argument('offset', 0))
        uri = self.request.uri
        method = self.request.method
        sort = self.get_argument('sort', 'asc')
        sort_by = self.get_argument('sort_by', TagsKey.TagName)
        tag = (
            TagSearcher(
                username, customer_name, uri, method,
                count, offset, sort, sort_by
            )
        )
        if not query:
            results = tag.get_all()
        else:
            results = tag.search_by_name(query)

        self.set_status(results['http_status'])
        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:26,代码来源:tag_api.py

示例12: get

    def get(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri=self.request.uri
        method=self.request.method
        try:
            results= None
            os_code=self.get_argument('os_code', None)
            tag_id=self.get_argument('tag_id', None)
            results = systems_cpu_details(username=username, customer_name=customer_name,
                    tag_id=tag_id, os_code=os_code,
                    uri=uri, method=method
                    )
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                    GenericResults(
                        username, uri, method
                        ).something_broke('no stats', '', e)
                    )
            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:29,代码来源:reports_api.py

示例13: get

    def get(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        try:
            count = (
                int(
                    self.get_argument(ApiArguments.COUNT,
                        DefaultQueryValues.COUNT
                    )
                )
            )
            offset = (
                int(
                    self.get_argument(
                        ApiArguments.OFFSET,
                        DefaultQueryValues.OFFSET
                    )
                )
            )
            sort = self.get_argument(ApiArguments.SORT, SortValues.DESC)
            sort_by = (
                self.get_argument(
                    ApiArguments.SORT_BY,
                    AgentOperationKey.CreatedTime
                )
            )
            operation = self.get_argument(ApiArguments.OPERATION, None)

            operations = (
                AgentOperationRetriever(
                    customer_name,
                    count, offset, sort, sort_by,
                    username, uri, method
                )
            )

            if operation:
                results = operations.get_all_by_operation(operation)

            else:
                results = operations.get_all()

            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke('operation', 'search by oper type', e)
            )
            logger.exception(results)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:60,代码来源:agent_operations.py

示例14: post

    def post(self):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri = self.request.uri
        method = self.request.method
        name = self.arguments.get('name', None)
        release_date = self.arguments.get('release_date', None)
        severity = self.arguments.get('severity', 'Optional')
        description = self.arguments.get('description', None)
        kb = self.arguments.get('kb', '')
        support_url = self.arguments.get('support_url', '')
        major_version = self.arguments.get('major_version', None)
        minor_version = self.arguments.get('minor_version', None)
        vendor_name = self.arguments.get('vendor_name', None)
        operating_system = self.arguments.get('operating_system', None)
        size = self.arguments.get('size', None)
        md5 = self.arguments.get('md5_hash', None)
        cli_options = self.arguments.get('cli_options', None)
        arch = self.arguments.get('arch', None)
        uuid = self.arguments.get('id', None)

        result = (
            store_package_info_in_db(
                username, customer_name, uri, method,
                size, md5, operating_system, uuid, name,
                severity, arch, major_version, minor_version,
                release_date, vendor_name, description,
                cli_options, support_url, kb
            )
        )

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(result, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:35,代码来源:custom_updates_handler.py

示例15: delete

    def delete(self, jobname):
        username = self.get_current_user()
        customer_name = (
            get_user_property(username, UserKeys.CurrentCustomer)
        )
        uri=self.request.uri
        method=self.request.method
        try:
            self.sched = self.application.scheduler
            results = (
                remove_job(
                    self.sched, jobname,
                    uri=uri,method=method,
                    customer_name=customer_name,
                    username=username
                )
            )
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))

        except Exception as e:
            results = (
                GenericResults(
                    username, uri, method
                ).something_broke('delete schedule', '', e)
            )

            logger.exception(e)
            self.set_status(results['http_status'])
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps(results, indent=4))
开发者ID:akaasjager,项目名称:vFense,代码行数:32,代码来源:scheduler_api.py


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