X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FLimitUtil.py;h=6559f6aeb074349f10d71b82af13e3e7b6243f73;hp=45aeaff5a06b6c19f0c8cd3fe097bb2ee790eac9;hb=HEAD;hpb=390cb24b3945442fba9f84dc292b6a4138d4835e diff --git a/resources/libraries/python/LimitUtil.py b/resources/libraries/python/LimitUtil.py index 45aeaff5a0..6559f6aeb0 100644 --- a/resources/libraries/python/LimitUtil.py +++ b/resources/libraries/python/LimitUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -15,10 +15,10 @@ from resources.libraries.python.ssh import exec_cmd_no_error -__all__ = ["LimitUtil"] +__all__ = [u"LimitUtil"] -class LimitUtil(object): +class LimitUtil: """Class contains methods for getting or setting process resource limits.""" @staticmethod @@ -30,10 +30,8 @@ class LimitUtil(object): :type node: dict :type pid: int """ - command = 'prlimit --noheadings --pid={pid}'.format(pid=pid) - - message = 'Node {host} failed to run: {command}'.\ - format(host=node['host'], command=command) + command = f"prlimit --noheadings --pid={pid}" + message = f"Node {node[u'host']} failed to run: {command}" exec_cmd_no_error(node, command, sudo=True, message=message) @@ -50,11 +48,7 @@ class LimitUtil(object): :type resource: str :type limit: str """ - command = 'prlimit --{resource}={limit} --pid={pid}'.format( - resource=resource, limit=limit, pid=pid) - - message = 'Node {host} failed to run: {command}'.\ - format(host=node['host'], command=command) + command = f"prlimit --{resource}={limit} --pid={pid}" + message = f"Node {node[u'host']} failed to run: {command}" exec_cmd_no_error(node, command, sudo=True, message=message) -