Browse Source

getformance.getcpu(): if no cpu info, fallback to platform.platform()

pull/888/head
SanderJo 8 years ago
committed by Safihre
parent
commit
31c0c239f9
  1. 11
      sabnzbd/utils/getperformance.py

11
sabnzbd/utils/getperformance.py

@ -3,8 +3,7 @@ import platform, subprocess
def getcpu(): def getcpu():
# find the CPU name (which needs a different method per OS), and return it # find the CPU name (which needs a different method per OS), and return it
# return None if none found # If none found, return platform.platform().
# works on Linux, MacOS (aka OSX), Windows
cputype = None cputype = None
@ -25,15 +24,17 @@ def getcpu():
# model name : Intel(R) Xeon(R) CPU E5335 @ 2.00GHz # model name : Intel(R) Xeon(R) CPU E5335 @ 2.00GHz
cputype = myline.split(":", 1)[1] # get everything after the first ":" cputype = myline.split(":", 1)[1] # get everything after the first ":"
break # we're done break # we're done
except: except:
# An exception, maybe due to a subprocess call gone wrong # An exception, maybe due to a subprocess call gone wrong
cputype = "Unknown"
pass pass
if cputype: if cputype:
# remove unnneeded space: # OK, found. Remove unnneeded spaces:
cputype = " ".join(cputype.split()) cputype = " ".join(cputype.split())
else:
# Not found, so let's fall back to platform()
cputype = platform.platform()
return cputype return cputype

Loading…
Cancel
Save