Created
June 14, 2017 02:01
-
-
Save EncodeTheCode/2ded8be9c47774d0ba40911bdeb45c79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys as s | |
import platform as p | |
import subprocess as x | |
import math as m | |
global v | |
def ByteConvert(a): | |
if(a==0): | |
return '0B' | |
z=("B","KB","MB","GB","TB","PB","EB","ZB","YB") | |
i=int(m.floor(m.log(a,1024))) | |
p=m.pow(1024,i) | |
s=round(a/p,2) | |
return '~%s %s'%(s,z[i]) | |
def GetCPU(): | |
if p.system()=="Windows": | |
n=str(x.check_output(["wmic","cpu","get","name"])).replace(" ","").strip() | |
n=n[12:].strip("\\r\\r\\n\\r\\r\\n'") | |
return n | |
def GetMemChip(g): | |
if p.system()=="Windows": | |
n=str(x.check_output(["wmic","memorychip","get",g])).replace(" ","").strip() | |
#n=n[16:].strip("\\r\\r\\n'").replace("\\r\\r\\n",":")[0:10] | |
n=n[16:].strip("\\r\\r\\n'").replace("\\r\\r\\n",":")+n[-1:0]+":" | |
n="Memory:\r\n\r\n"+n.replace(":"," KB\n") | |
#str(ByteConvert(int(n))) | |
return n | |
def SysInfo(): | |
for i in [p.system(),p.version(),p.machine(),p.processor(),GetCPU(),GetMemChip("capacity")]:print(i+"\r") | |
def main(): | |
v=0 # Verbose output | |
if v==1: | |
print("""\ | |
[Arguments] | |
-s <option> View info of option | |
-S View all info of PC | |
[Options] | |
os | |
os_ver | |
processor | |
processor_name | |
arch | |
""") | |
try: | |
if(s.argv[1]=="-s" and len(s.argv)==2): | |
print("Shows info of option.") | |
if v==1:print("\r\n\r\n\t-s <option>") | |
elif(s.argv[1]=="-s" and s.argv[2]=="os"): | |
print(p.system()) | |
elif(s.argv[1]=="-s" and s.argv[2]=="os_ver"): | |
print(p.version()) | |
elif(s.argv[1]=="-s" and s.argv[2]=="processor"): | |
print(p.processor()) | |
elif(s.argv[1]=="-s" and s.argv[2]=="processor_name"): | |
print(GetCPU()) | |
elif(s.argv[1]=="-s" and s.argv[2]=="arch"): | |
print(p.machine()) | |
elif(s.argv[1]=="-S"): | |
SysInfo() | |
except: | |
print('\b ',end="",flush=True) | |
s.stdout.write('\010') | |
s.stderr.write('\010') | |
s.exit() | |
if __name__=="__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment