How to get method name in python?
The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects. For example, it can help you examine the contents of a class, retrieve the source code of a method, extract and format the argument list for a function, or get all the information you need to display a detailed traceback.
You can use
 
A sample code for the
 
  The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects. For example, it can help you examine the contents of a class, retrieve the source code of a method, extract and format the argument list for a function, or get all the information you need to display a detailed traceback.
You can use
inspect module to do exactly this job:curframe = inspect.currentframe()The part that you are interested in, is
calframe = inspect.getouterframes(curframe, 2)
caller_method = calframe[0][3]
calframe[0][3]. It returns function name of the current method. If this method is called     from a parent method (caller method), you have to get that method name using calframe[1][3].A sample code for the
inspect module:import inspect#python #inspect #calframe #method_name
class PDFtoJPG:
def _internal_conversion(self):
self.convert_to_jpg()
def convert_to_jpg(self):
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
print calframe[0][3]
print calframe[1][3]
print calframe[2][3]
def convert(self):
self._internal_conversion()
snd = PDFtoJPG()
snd.convert()
  Tech C**P
How to get method name in python?  The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects. For example, it can help you examine…
You can also use 
 
#python #inspect #stack
  inspect.stack()[2][3] instead of getting current frame and then getting its outer frames:inspect.stack returns a list of frame records for the caller’s stack. The first entry in the returned list represents the caller;    the last entry represents the outermost call on the stack.#python #inspect #stack
Some useful 
 
List stacks or apps
 
Run the specified Compose file
 
List running services associated with an app
 
List tasks associated with an app
 
Inspect task or container
 
List container IDs
 
Tear down an application
 
Take down a single node swarm from the manager
#docker #cheatsheet #inspect #stack #swarm #service
  docker commands:docker stack lsList stacks or apps
docker stack deploy -c <composefile> <appname>Run the specified Compose file
docker service lsList running services associated with an app
docker service ps <service>List tasks associated with an app
docker inspect <task or container>Inspect task or container
docker container ls -qList container IDs
docker stack rm <appname>Tear down an application
docker swarm leave --forceTake down a single node swarm from the manager
#docker #cheatsheet #inspect #stack #swarm #service
How to get IP address of a docker container?
First you need to issue the following command to get the container id (first column):
 
Use the container ID to run:
 
At the bottom,under
#docker #ip_address #container #ps #ip #inspect
  First you need to issue the following command to get the container id (first column):
docker ps
Use the container ID to run:
docker inspect <container ID>
At the bottom,under
NetworkSettings, you can find IPAddress.#docker #ip_address #container #ps #ip #inspect
What is a HAR file?The HAR file format is an evolving standard and the information contained within it is both flexible and extensible. You can expect a HAR file to include a breakdown of timings including:
- How long it takes to fetch DNS information
- How long each object takes to be requested
- How long it takes to connect to the server
- How long it takes to transfer assets from the server to the browser of each object
How To Get A HAR File?By using chrome inspect element it is easy as pie. Just open inpect element, right click on one of the requests sent to server and click on
Save as HAR with content and save the file on your system.Now you need a tool to analyze the result. There is an online tool for that head over to link below:
- https://toolbox.googleapps.com/apps/har_analyzer/
In the website load your
HAR file and click on Choose file and open your HAR file. It will give an insight on your request        times, DNS response, etc.#HAR #inspect_element
