mirror of
https://github.com/markqvist/Sideband.git
synced 2025-08-02 11:36:14 -04:00
Included local plyer
This commit is contained in:
parent
25f0d52260
commit
f23855fb68
166 changed files with 15862 additions and 0 deletions
37
sbapp/plyer/platforms/linux/processors.py
Normal file
37
sbapp/plyer/platforms/linux/processors.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from subprocess import Popen, PIPE
|
||||
from plyer.facades import Processors
|
||||
from plyer.utils import whereis_exe
|
||||
|
||||
from os import environ
|
||||
|
||||
|
||||
class LinuxProcessors(Processors):
|
||||
def _get_state(self):
|
||||
old_lang = environ.get('LANG')
|
||||
environ['LANG'] = 'C'
|
||||
|
||||
status = {"Number_of_Processors": None}
|
||||
|
||||
dev = "--all"
|
||||
nproc_process = Popen(
|
||||
["nproc", dev],
|
||||
stdout=PIPE
|
||||
)
|
||||
output = nproc_process.communicate()[0]
|
||||
|
||||
environ['LANG'] = old_lang
|
||||
|
||||
if not output:
|
||||
return status
|
||||
|
||||
status['Number_of_Processors'] = output.rstrip()
|
||||
|
||||
return status
|
||||
|
||||
|
||||
def instance():
|
||||
import sys
|
||||
if whereis_exe('nproc'):
|
||||
return LinuxProcessors()
|
||||
sys.stderr.write("nproc not found.")
|
||||
return Processors()
|
Loading…
Add table
Add a link
Reference in a new issue