Python - Core Speed [duplicate] - python

This question already has answers here:
Getting processor information in Python
(10 answers)
Closed 7 years ago.
I'm trying to find out where this value is stored in both windows and osx, in order to do some calculations to make a better task distribution.
Core speed in Hz
Thanks in advance.
Using the platform.process() command only returns the name not the speed
I only managed to get it trough this:
import subprocess
info=subprocess.check_output(["wmic","cpu","get", "name"])
print info.split('#')[1].split(' ')[1]
But for the moment i have no way to tell if it will always return the same result in every machine (no access to other computers right now)

Machine ID
There is currently no cross platform python way of getting a Machine ID, however this has been asked before:
Get a unique computer ID in Python on windows and linux
if you just want the machine name use platform.node()
Number of cores
The multiprocessing module contains the multiprocessing.cpu_count() method
Cores speed in Hz
There is currently no cross platform python way of getting cpu frequency, however this has been asked before: Getting processor information in Python

Related

How to get a report from CPU and RAM usage of a specific user in a period of time using Python?

Is there a Python module to get a report from CPU and RAM usage of a specific user of an Ubuntu system between two dates? If there is no such a tool, I wonder how can I implement such an application using pure Python code? What is the starting point for doing that?
This answer seems to address the way of obtaining current CPU and RAM usage. What I need is to get a history of CPU (for example, in terms of the number of clocks) and RAM (in terms of bytes) usage for each user between two given dates. Are these information logged and stored by Linux? If yes, where are they stored? If not, how can I implement such a monitoring tool in Python?

How to determine machine architecture in Python? [duplicate]

This question already has answers here:
Is there a reliable way to determine the system CPU architecture using Python? [duplicate]
(2 answers)
How to identify which OS Python is running on?
(27 answers)
Closed 10 months ago.
I'm wondering how to find the architecture of the machine python is running on and save it to a string.
The only other example I've been able to find works only on Windows, and doesn't even detect the proper architecture if it's Windows on Arm. Any solutions would be greatly appreciated.
Thanks,
NullUsxr
import platform
print(platform.system())
According to https://docs.python.org/3/library/platform.html#platform.system it says the function would "Returns the system/OS name, such as 'Linux', 'Darwin', 'Java', 'Windows'. An empty string is returned if the value cannot be determined."

How to have a subprogramm in another programming language [duplicate]

This question already has answers here:
How do I run a Python script from C#?
(8 answers)
Run a python script from unity, to use its output (text file) in my game later
(4 answers)
Closed 1 year ago.
I want to make a Unity game that gives data to a subprogram written in Python and this subprogram gives back an answer, that is then processed in the C# game.
I don't really know how to approach this.
Can I run python code from C# somehow or do I let two separate programs running, that exchange data somehow?
Both programs also need access to the same database.
You can make a python server using flask or fastAPI and then access it from C#. I am not sure how to get that done with C#(I dont know C# :( ), but there must be some libraries to call servers. Also, you could save the database on the cloud such as mongoDB.

How to check disk space when running python script? [duplicate]

This question already has answers here:
Find free disk space in python on OS/X
(7 answers)
Closed 3 years ago.
I have a script that is going to download a lot of data from the internet. But, I have no idea how long will it take or how big the data it will be.
To be more precise I want to analyze some live videos and for that I will download the content using youtube-dl. Since I want to leave it running for a week or two, is there a way so that can avoid running into low memory problem, that the computer checks on a specific interval what is my memory status and if it is below a certain value to stop the execution?
Thanks
You can use shutil.disk_usage(path) from the docs:
shutil.disk_usage(path)
Return disk usage statistics about the given path as a named tuple with the attributes total, used and free, which are the amount of
total, used and free space, in bytes. On Windows, path must be a
directory; on Unix, it can be a file or directory.
Use shutil.disk_usage.
total, used, free = shutil.disk_usage("/")

Python limit usage to Linux only [duplicate]

This question already has answers here:
How can I find the current OS in Python? [duplicate]
(5 answers)
Closed 9 years ago.
I have a program I'm thinking through right now and doing tons of investigating on. One of the stipulations with the program is that I want it so it can only run on Linux. I DO NOT want the program to be usable on Windows or Apple...Linux only. I have my reasons.
I know you can use certain modules(tkinter...root.mainloop()), ie, that will cause a program to not run in Windows if you leave certain things out. Is there a way you can accomplish the same task without using any particular module...just 'base code'?
Just test for Linux:
import platform
import sys
if platform.system() != 'Linux':
sys.stderr('Linux required\n')
sys.exit(1)

Categories

Resources