Python commands.getoutput() Examples

The following are 30 code examples of commands.getoutput(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module commands , or try the search function .
Example #1
Source File: Airodump-ng.py    From Airvengers with GNU General Public License v2.0 7 votes vote down vote up
def mycallback(self):
        listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname
         
        listoutput=commands.getoutput("airodump-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+format(self.var7.get())+" "+(self.t7.get(1.0, 'end')).strip()+" "+format(self.var8.get())+" "+(self.t8.get(1.0, 'end')).strip()+" "+\
                            format(self.var9.get())+" "+(self.t9.get(1.0, 'end')).strip()+" "+format(self.var10.get())+" "+(self.t10.get(1.0, 'end')).strip()+" "+format(self.var11.get())+" "+(self.t11.get(1.0, 'end')).strip()+" "+format(self.var12.get())+" "+(self.t12.get(1.0, 'end')).strip()+" "+\
                            format(self.var13.get())+" "+(self.t13.get(1.0, 'end')).strip()+" "+format(self.var14.get())+" "+(self.t14.get(1.0, 'end')).strip()+" "+format(self.var15.get())+" "+(self.t15.get(1.0, 'end')).strip()+" "+format(self.var16.get())+" "+(self.t16.get(1.0, 'end')).strip()+" "+\
                            format(self.var17.get())+" "+(self.t17.get(1.0, 'end')).strip()+" "+format(self.var18.get())+" "+(self.t18.get(1.0, 'end')).strip()+" "+format(self.var19.get())+" "+(self.t19.get(1.0, 'end')).strip()+" "+format(self.var20.get())+" "+(self.t20.get(1.0, 'end')).strip()+" "+\
                            format(self.var21.get())+" "+ (self.t21.get(1.0, 'end')).strip()+" "+format(self.var22.get())+" "+(self.t22.get(1.0, 'end')).strip()+" "+format(self.var23.get())+" "+(self.t23.get(1.0, 'end')).strip()+" "+format(self.var24.get())+" "+(self.t24.get(1.0, 'end')).strip()+" "+\
                            format(self.var25.get())+" "+(self.t25.get(1.0, 'end')).strip()+" "+format(self.var26.get())+" "+(self.t26.get(1.0, 'end')).strip()+" "+listselection+" "+self.fname)
       
      
        self.output.insert(INSERT,listoutput) 
Example #2
Source File: Airdecloak-ng.py    From Airvengers with GNU General Public License v2.0 6 votes vote down vote up
def mycallback(self):
         
        listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname

        listoutput=commands.getoutput("airdecloak-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+format(self.var7.get())+" "+(self.t7.get(1.0, 'end')).strip()+" "+format(self.var8.get())+" "+(self.t8.get(1.0, 'end')).strip()+" "+listselection+" "+self.fname)

        self.output.insert(INSERT,listoutput) 
Example #3
Source File: main.py    From vulscan with MIT License 6 votes vote down vote up
def portScan(ip,user,password):
	try:
		result={}
		with open("result.json","r") as fn:
			data=fn.readlines()
			fn.close()
			result=json.loads(data[0])
		result[u"ip"]=ip
		result[u"username"]=user
		result[u"password"]=password
		#进行端口扫描
		print u"[*]对主机%s进行端口扫描......"%ip
		commandResult=commands.getoutput("python port_scan.py %s"%ip)
		result[u"端口详情"]=ast.literal_eval(commandResult)
		#将主机信息,端口扫描信息保存到json中
		with open("result.json",'w') as fn:
			json.dump(result,fn,ensure_ascii=False)
			fn.close()
		print u"[+]本次端口扫描结束"
	except Exception as e:
		print u"[-]端口扫描失败,请重新扫描"
		print e 
Example #4
Source File: email.py    From pipeline with MIT License 6 votes vote down vote up
def detect_desktop_environment():
        '''Checks for known desktop environments

        Return the desktop environments name, lowercase (kde, gnome, xfce)
        or "generic"

        '''

        desktop_environment = 'generic'

        if os.environ.get('KDE_FULL_SESSION') == 'true':
            desktop_environment = 'kde'
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            desktop_environment = 'gnome'
        else:
            try:
                info = commands.getoutput('xprop -root _DT_SAVE_MODE')
                if ' = "xfce4"' in info:
                    desktop_environment = 'xfce'
            except (OSError, RuntimeError):
                pass

        return desktop_environment 
Example #5
Source File: raster.py    From pizza with GNU General Public License v2.0 6 votes vote down vote up
def show(self,ntime):
    data = self.data
    which = data.findtime(ntime)
    time,box,atoms,bonds,tris,lines = data.viz(which)
    if self.boxflag == 2: box = data.maxbox()
    self.distance = compute_distance(box)

    self.xtrans = self.ytrans = self.ztrans = 0.0
    output = self.single(1,self.file,box,atoms,bonds,tris,lines)
    print output
    nums = re.findall("translation to:\s*(\S*)\s*(\S*)\s*(\S*)\s",output)
    self.xtrans = float(nums[0][0])
    self.ytrans = float(nums[0][1])
    self.ztrans = float(nums[0][2])
    
    self.single(0,self.file,box,atoms,bonds,tris,lines)
    cmd = "%s %s.png" % (PIZZA_DISPLAY,self.file)
    commands.getoutput(cmd)

  # -------------------------------------------------------------------- 
Example #6
Source File: airmode.py    From airmode with GNU General Public License v2.0 6 votes vote down vote up
def slot_autoload_victim_clients(self):
        
        # clear
        self.combo_wep_mac_cfrag.clear()
        self.combo_wpa_mac_hand.clear()

        # check *.csv files
        if not glob.glob(config_dir + "*.csv"):
            self.output("no csv files in " + config_dir, 1)
            return
        
        # open dump file
        dump_file = commands.getoutput("cat " + config_dir + "*.csv | egrep -e '^[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}.+[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2},' | grep " + self.ac + " | tr ',' ' ' | awk ' { print $1 } '")
        dump_file = dump_file.split('\n')        
        
        for mac in dump_file:
            self.combo_wep_mac_cfrag.insertItem(0, mac)
            self.combo_wpa_mac_hand.insertItem(0, mac)

    #
    # Add cracked key to database
    # 
Example #7
Source File: airmode.py    From airmode with GNU General Public License v2.0 6 votes vote down vote up
def slot_autoload_victim_clients(self):
        
        # clear
        self.combo_wep_mac_cfrag.clear()
        self.combo_wpa_mac_hand.clear()

        # check *.csv files
        if not glob.glob(config_dir + "*.csv"):
            self.output("no csv files in " + config_dir, 1)
            return
        
        # open dump file
        dump_file = commands.getoutput("cat " + config_dir + "*.csv | egrep -e '^[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}.+[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2},' | grep " + self.ac + " | tr ',' ' ' | awk ' { print $1 } '")
        dump_file = dump_file.split('\n')        
        
        for mac in dump_file:
            self.combo_wep_mac_cfrag.insertItem(0, mac)
            self.combo_wpa_mac_hand.insertItem(0, mac)

    #
    # Add cracked key to database
    # 
Example #8
Source File: bitleaker.py    From bitleaker with GNU General Public License v2.0 6 votes vote down vote up
def replay_pcr_data(pcr_list):
    info_print('Replay TPM data.\n')
    check_and_run_resource_manager()

    for pcr_data in pcr_list:
        info_print('    [>>] PCR %s, SHA256 = %s\n' % (pcr_data[0], pcr_data[1]))
        output = commands.getoutput('tpm2_extendpcrs -g 0x0b -P %s -i %s' % (pcr_data[0], pcr_data[1]))
        print output + '\n'

    # Last one for PCR #7
    info_print('    [>>] Last PCR 7, SHA256 = %s\n' % (sha256_bootmgfw_cert))
    output = commands.getoutput('tpm2_extendpcrs -g 0x0b -P 7 -i %s' % sha256_bootmgfw_cert)
    print output + '\n'

    os.system('sudo killall resourcemgr')
    
# 
# Extract TPM encoded blob from Dislocker tool
# 
Example #9
Source File: Airtun-ng.py    From Airvengers with GNU General Public License v2.0 6 votes vote down vote up
def mycallback(self):
         
	listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname

        listoutput=commands.getoutput("airtun-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+format(self.var7.get())+" "+(self.t7.get(1.0, 'end')).strip()+" "+format(self.var8.get())+" "+(self.t8.get(1.0, 'end')).strip()+" "+format(self.var9.get())+" "+(self.t9.get(1.0, 'end')).strip()+" "+format(self.var10.get())+" "+(self.t10.get(1.0, 'end')).strip()+" "+format(self.var11.get())+" "+(self.t11.get(1.0, 'end')).strip()+" "+format(self.var12.get())+" "+(self.t12.get(1.0, 'end')).strip()+" "+listselection+" "+self.fname)

        self.output.insert(INSERT,listoutput) 
Example #10
Source File: Aircrack-ng.py    From Airvengers with GNU General Public License v2.0 6 votes vote down vote up
def mycallback(self):
         
        listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname
         
        listoutput=commands.getoutput("aircrack-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+format(self.var7.get())+" "+(self.t7.get(1.0, 'end')).strip()+" "+format(self.var8.get())+" "+(self.t8.get(1.0, 'end')).strip()+" "+\
                            format(self.var9.get())+" "+(self.t9.get(1.0, 'end')).strip()+" "+format(self.var10.get())+" "+(self.t10.get(1.0, 'end')).strip()+" "+format(self.var11.get())+" "+(self.t11.get(1.0, 'end')).strip()+" "+format(self.var12.get())+" "+(self.t12.get(1.0, 'end')).strip()+" "+\
                            format(self.var13.get())+" "+(self.t13.get(1.0, 'end')).strip()+" "+format(self.var14.get())+" "+(self.t14.get(1.0, 'end')).strip()+" "+format(self.var15.get())+" "+(self.t15.get(1.0, 'end')).strip()+" "+format(self.var16.get())+" "+(self.t16.get(1.0, 'end')).strip()+" "+\
                            format(self.var17.get())+" "+(self.t17.get(1.0, 'end')).strip()+" "+format(self.var18.get())+" "+(self.t18.get(1.0, 'end')).strip()+" "+format(self.var19.get())+" "+(self.t19.get(1.0, 'end')).strip()+" "+format(self.var20.get())+" "+(self.t20.get(1.0, 'end')).strip()+" "+\
                            format(self.var21.get())+" "+ (self.t21.get(1.0, 'end')).strip()+" "+format(self.var22.get())+" "+(self.t22.get(1.0, 'end')).strip()+" "+format(self.var23.get())+" "+(self.t23.get(1.0, 'end')).strip()+" "+format(self.var24.get())+" "+(self.t24.get(1.0, 'end')).strip()+" "+\
                            format(self.var25.get())+" "+(self.t25.get(1.0, 'end')).strip()+" "+format(self.var26.get())+" "+(self.t26.get(1.0, 'end')).strip()+" "+format(self.var27.get())+" "+(self.t27.get(1.0, 'end')).strip()+" "+format(self.var28.get())+" "+(self.t28.get(1.0, 'end')).strip()+" "+format(self.var29.get())+" "+(self.t29.get(1.0, 'end')).strip()+" "+format(self.var30.get())+" "+(self.t30.get(1.0, 'end')).strip()+" "+format(self.var31.get())+" "+(self.t31.get(1.0, 'end')).strip()+" "+format(self.var32.get())+" "+(self.t32.get(1.0, 'end')).strip()+" "+format(self.var33.get())+" "+(self.t33.get(1.0, 'end')).strip()+" "+format(self.var34.get())+" "+(self.t34.get(1.0, 'end')).strip()+" "+listselection+" "+self.fname)  

        self.output.insert(INSERT,listoutput) 
Example #11
Source File: Airbase-ng.py    From Airvengers with GNU General Public License v2.0 6 votes vote down vote up
def mycallback(self):
         
        listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname
         
        listoutput=commands.getoutput("airbase-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+format(self.var7.get())+" "+(self.t7.get(1.0, 'end')).strip()+" "+format(self.var8.get())+" "+(self.t8.get(1.0, 'end')).strip()+" "+\
                            format(self.var9.get())+" "+(self.t9.get(1.0, 'end')).strip()+" "+format(self.var10.get())+" "+(self.t10.get(1.0, 'end')).strip()+" "+format(self.var11.get())+" "+(self.t11.get(1.0, 'end')).strip()+" "+format(self.var12.get())+" "+(self.t12.get(1.0, 'end')).strip()+" "+\
                            format(self.var13.get())+" "+(self.t13.get(1.0, 'end')).strip()+" "+format(self.var14.get())+" "+(self.t14.get(1.0, 'end')).strip()+" "+format(self.var15.get())+" "+(self.t15.get(1.0, 'end')).strip()+" "+format(self.var16.get())+" "+(self.t16.get(1.0, 'end')).strip()+" "+\
                            format(self.var17.get())+" "+(self.t17.get(1.0, 'end')).strip()+" "+format(self.var18.get())+" "+(self.t18.get(1.0, 'end')).strip()+" "+format(self.var19.get())+" "+(self.t19.get(1.0, 'end')).strip()+" "+format(self.var20.get())+" "+(self.t20.get(1.0, 'end')).strip()+" "+\
                            format(self.var21.get())+" "+ (self.t21.get(1.0, 'end')).strip()+" "+format(self.var22.get())+" "+(self.t22.get(1.0, 'end')).strip()+" "+format(self.var23.get())+" "+(self.t23.get(1.0, 'end')).strip()+" "+format(self.var24.get())+" "+(self.t24.get(1.0, 'end')).strip()+" "+\
                            format(self.var25.get())+" "+(self.t25.get(1.0, 'end')).strip()+" "+format(self.var26.get())+" "+(self.t26.get(1.0, 'end')).strip()+" "+format(self.var27.get())+" "+(self.t27.get(1.0, 'end')).strip()+" "+format(self.var28.get())+" "+(self.t28.get(1.0, 'end')).strip()+" "+format(self.var29.get())+" "+(self.t29.get(1.0, 'end')).strip()+" "+format(self.var30.get())+" "+(self.t30.get(1.0, 'end')).strip()+" "+format(self.var31.get())+" "+(self.t31.get(1.0, 'end')).strip()+" "+format(self.var32.get())+" "+(self.t32.get(1.0, 'end')).strip()+" "+format(self.var33.get())+" "+(self.t33.get(1.0, 'end')).strip()+" "+format(self.var34.get())+" "+(self.t34.get(1.0, 'end')).strip()+" "+listselection+" "+self.fname)  
      
        self.output.insert(INSERT,listoutput) 
Example #12
Source File: Airolib-ng.py    From Airvengers with GNU General Public License v2.0 6 votes vote down vote up
def mycallback(self):
         
        listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname

        listoutput=commands.getoutput("airolib-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+format(self.var7.get())+" "+(self.t7.get(1.0, 'end')).strip()+" "+format(self.var8.get())+" "+(self.t8.get(1.0, 'end')).strip())

        self.output.insert(INSERT,listoutput) 
Example #13
Source File: Airdecap-ng.py    From Airvengers with GNU General Public License v2.0 6 votes vote down vote up
def mycallback(self):
         
        listselection=""
	try:
		listselection=self.lilnew1.get(self.lilnew1.curselection()[0])
	except:
		listselection=""
		
	h1="mon0"
	print listselection
	print self.fname

        listoutput=commands.getoutput("airdecap-ng"+" "+format(self.var1.get())+" "+(self.t1.get(1.0, 'end')).strip()+" "+format(self.var2.get())+" "+(self.t2.get(1.0, 'end')).strip()+" "+format(self.var3.get())+" "+(self.t3.get(1.0, 'end')).strip()+" "+format(self.var4.get())+" "+(self.t4.get(1.0, 'end')).strip()+" "+\
                            format(self.var5.get())+" "+(self.t5.get(1.0, 'end')).strip()+" "+format(self.var6.get())+" "+(self.t6.get(1.0, 'end')).strip()+" "+listselection+" "+self.fname)

        self.output.insert(INSERT,listoutput) 
Example #14
Source File: commands.py    From meddle with MIT License 5 votes vote down vote up
def getoutput(cmd):
    """Return output (stdout or stderr) of executing cmd in a shell."""
    return getstatusoutput(cmd)[1]


# Ditto but preserving the exit status.
# Returns a pair (sts, output)
# 
Example #15
Source File: monitor.py    From lokun-record with GNU Affero General Public License v3.0 5 votes vote down vote up
def creategraphs():
    graph_sh = os.path.join(rrdroot, "graph.sh")
    graph = getoutput("/usr/bin/bash {0}".format(graph_sh))
    if "-v" in sys.argv: print graph_sh
    return graph 
Example #16
Source File: monitor.py    From lokun-record with GNU Affero General Public License v3.0 5 votes vote down vote up
def rrdupdate(ts, usercount, bw):
    rrdupdate = "rrdtool update {0} --template bandwidth:usercount {1}:{2}:{3}"
    r = rrdupdate.format(os.path.join(rrdroot, rrddb), ts, bw, usercount) 
    if "-v" in sys.argv: print r
    rrd = getoutput(r)
    return rrd 
Example #17
Source File: replication_tool.py    From community-edition-setup with MIT License 5 votes vote down vote up
def encodePW(self, pw):
        output = commands.getoutput(self.encode_pw % pw)
        return output.split('"')[1] 
Example #18
Source File: shellab.py    From Shellab with MIT License 5 votes vote down vote up
def raw_disasm(opcodes, bits, platform):
    instr = getoutput(('rasm2 -s intel -a x86 -b {} -k {} -d {}'.format(bits,platform,opcodes)))
    return instr 
Example #19
Source File: shellab.py    From Shellab with MIT License 5 votes vote down vote up
def raw_asm(instr, bits, platform):
    op = getoutput(('rasm2 -a x86 -b {} -k {} "{}"'.format(bits,platform,instr)))
    return op 
Example #20
Source File: dstat_tc_param.py    From EM-uNetPi with MIT License 5 votes vote down vote up
def Update(self):
        import commands
        import re

        current  = commands.getoutput("tc qdisc show dev eth0")

        pattern  = re.compile(r'delay.*?ms')
        matchObj = pattern.search(current)
        if matchObj:
            	param = matchObj.group().split()
		self.val['delayUPValue'] = param[1] 
        else:
		self.val['delayUPValue'] = '0.0ms'
        pattern  = re.compile(r'loss.*?\%')
        matchObj = pattern.search(current)
        if matchObj:
		param = matchObj.group().split()
		self.val['lossUPValue'] = param[1] 
        else:
		self.val['lossUPValue'] = '0%'

	current  = commands.getoutput("tc qdisc show dev wlan0")

        pattern  = re.compile(r'delay.*?ms')
        matchObj = pattern.search(current)
        if matchObj:
            	param = matchObj.group().split()
		self.val['delayDWValue'] = param[1] 
        else:
		self.val['delayDWValue'] = '0.0ms'
        pattern  = re.compile(r'loss.*?\%')
        matchObj = pattern.search(current)
        if matchObj:
		param = matchObj.group().split()
		self.val['lossDWValue'] = param[1] 
        else:
		self.val['lossDWValue'] = '0%' 
Example #21
Source File: dstat_cpu_temp.py    From EM-uNetPi with MIT License 5 votes vote down vote up
def Update(self):
		import commands
		import re

		current  = commands.getoutput("vcgencmd measure_temp")

		pattern  = re.compile(r'temp=.*')
		matchObj = pattern.search(current)
		if matchObj:
			param = matchObj.group().split("=")[1].split("'")
			self.val['cpuTempValue'] = param[0] 
		else:
			self.val['cpuTempValue'] = '0.0' 
Example #22
Source File: dstat_nat_session.py    From EM-uNetPi with MIT License 5 votes vote down vote up
def Update(self):
        import commands
        self.val['tcpNr'] = commands.getoutput("cat /proc/net/nf_conntrack | grep tcp | wc -l ")
        self.val['udpNr'] = commands.getoutput("cat /proc/net/nf_conntrack | grep udp | wc -l ") 
Example #23
Source File: reader.py    From Baidu_Lane_Segmentation with MIT License 5 votes vote down vote up
def __init__(self, dataset_dir, subset='train',rows=2000, cols=1354, shuffle=True, birdeye=True):
        label_dirname = dataset_dir + subset
        print (label_dirname)

        if six.PY2:
            import commands
            label_files = commands.getoutput(
                "find %s -type f | grep _bin.png | sort" %
                label_dirname).splitlines()
        else:
            import subprocess
            label_files = subprocess.getstatusoutput(
                "find %s -type f | grep _bin.png | sort" %
                label_dirname)[-1].splitlines()

        print ('---')
        print (label_files[0])
        self.label_files = label_files
        self.label_dirname = label_dirname
        self.rows = rows
        self.cols = cols
        self.index = 0
        self.subset = subset
        self.dataset_dir = dataset_dir
        self.shuffle = shuffle
        self.M = 0
        self.Minv = 0
        self.reset()
        self.get_M_Minv()
        self.augmentor = 0
        self.birdeye = birdeye
        print("images total number", len(label_files))

    # 标签转分类 255 ignore ? 
Example #24
Source File: bitleaker.py    From bitleaker with GNU General Public License v2.0 5 votes vote down vote up
def check_and_run_resource_manager():
    info_print('    [>>] Checking the resource manager process... ')
    sys.stdout.flush()

    output = commands.getoutput('sudo ps -e | grep resourcemgr')
    if 'resourcemgr' in output:
        color_print('Running\n', SUCCESS)
        return 0

    pid = os.fork()
    if pid == 0:
        commands.getoutput('sudo resourcemgr > /dev/null')
        sys.exit(0)
    else:
        # Wait for the resource manager
        resourcemgr_found = False

        for i in range(0, 10):
            output = commands.getoutput('ps -e | grep resourcemgr')
            if len(output) != 0:
                resourcemgr_found = True
                break

            sleep(1)

        if resourcemgr_found == False:
            color_print('Fail\n', FAIL)
            sys.exit(-1)

    color_print('Success\n', SUCCESS)
    sleep(3)
    return 0

#
# Replay PCR data to the TPM
# 
Example #25
Source File: pkg.py    From wixpy with GNU General Public License v3.0 5 votes vote down vote up
def get_pkg_cflags(pkg_names):
    flags = []
    for item in pkg_names:
        output = commands.getoutput("pkg-config --cflags-only-other %s" % item)
        names = output.strip().split(' ')
        for name in names:
            if name not in flags:
                flags.append(name)
    return flags 
Example #26
Source File: pkg.py    From wixpy with GNU General Public License v3.0 5 votes vote down vote up
def get_pkg_libs(pkg_names):
    libs = []
    for item in pkg_names:
        output = commands.getoutput("pkg-config --libs-only-l %s" % item)
        names = output.replace('-l', '').strip().split(' ')
        for name in names:
            if name not in libs:
                libs.append(name)
    return libs 
Example #27
Source File: pkg.py    From wixpy with GNU General Public License v3.0 5 votes vote down vote up
def get_pkg_includes(pkg_names):
    includes = []
    for item in pkg_names:
        output = commands.getoutput("pkg-config --cflags-only-I %s" % item)
        names = output.replace('-I', '').strip().split(' ')
        for name in names:
            if name not in includes:
                includes.append(name)
    return includes 
Example #28
Source File: pkg.py    From wixpy with GNU General Public License v3.0 5 votes vote down vote up
def get_pkg_version(pkg_name):
    return commands.getoutput("pkg-config --modversion %s" % pkg_name).strip() 
Example #29
Source File: environment.py    From bitmask-dev with GNU General Public License v3.0 5 votes vote down vote up
def after_all(context):
    context.browser.quit()
    if MODE == VIRTUALENV:
        commands.getoutput('bitmaskctl stop') 
Example #30
Source File: monitorparser.py    From lokun-record with GNU Affero General Public License v3.0 5 votes vote down vote up
def rrdupdate(ts, usercount, bw):
    rrdupdate = "rrdtool update monitor_db.rrd --template bandwidth:usercount {0}:{1}:{2}"
    r = rrdupdate.format(ts, bw, usercount) 
    if "-v" in sys.argv: print r
    rrd = getoutput(r)
    if rrd.startswith("ERROR"):
        print rrd
    return rrd