本文整理汇总了Python中subprocess.Popen.find方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.find方法的具体用法?Python Popen.find怎么用?Python Popen.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def __init__(self, manager, *args, **kw):
super(ProbeAdapter, self).__init__(*args, **kw)
self.__instances = set("0")
manager.register_adapter("/probeResource", self)
# Print the IP-Address of this machine
output = Popen(["ifconfig"], stdout=PIPE).communicate()[0]
indexIPStart = output.find("inet addr")+10
indexIPEnd = output.find("Bcast")
global IPAddress
IPAddress = output[indexIPStart:indexIPEnd].strip(' ')
logger.debug("--- The IP-Address of this machine is: "+IPAddress+" ---")
示例2: run
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def run( dev_name ):
keyline = Popen(["./keymap_update","-i", dev_name], stdout=PIPE, bufsize=0).communicate()[0].split("\n")[0]
print keyline
index = keyline.find( "esc" )
if index == -1:
return True
return False
示例3: pingHost
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def pingHost(host):
pingout,pingerr=Popen(["ping.exe", line, "-n", "1"], stdout=PIPE, shell=True).communicate()
print "Pingout: " + pingout + " :|: "
if pingout.find(" ms") > 0:
return True
else:
return False
示例4: set_platform
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def set_platform():
global plexconnectpath
cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
if sys.platform.startswith('darwin'): # OSX
plexconnectpath = cwd+"/PlexConnect_daemon.bash "
call("echo 1 >daemon_support.txt",shell=True)
call("launchctl list | grep -c plexconnect >daemon_installed.txt",shell=True) #outputs: 0=not installed,1=daemon installed
elif sys.platform.startswith('win32'):
if controlsupport == True:
plexconnectpath = "python PlexConnect_WinService.py "
call("echo 1 >daemon_support.txt",shell=True)
output = Popen("sc query PlexConnect-service", shell=True, stdout=PIPE).communicate()[0]
if output.find("FAILED") > 0:
call("echo 0 >daemon_installed.txt",shell=True)
else:
call("echo 1 >daemon_installed.txt",shell=True)
else:
plexconnectpath = "start /B pythonw PlexConnect.py"
call("echo 0 >daemon_installed.txt",shell=True)
call("echo 0 >daemon_installed.txt",shell=True)
else: # linux
plexconnectpath = cwd+"/PlexConnect_daemon.bash "
call("echo 0 >daemon_support.txt",shell=True)
call("echo 0 >daemon_installed.txt",shell=True)
示例5: wpa_run
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def wpa_run(self):
dump_cmd = ['airodump-ng', '-c', self.channel, '--bssid', self.bssid, '-w', './log/' + self.bssid, self.iface]
airodump_proc = Popen(dump_cmd, stdout=DN, stderr=DN)
self.proc_list.append(airodump_proc)
self.send_deauths()
while self.key == '':
output = Popen('tshark -r ./log/' + self.bssid + '-01.cap 2>/dev/null| grep "Message 4 of 4"',shell=True, stdout=PIPE).communicate()[0]
if output.find('Message 4 of 4') != -1:
execute('rm ./log/'+self.bssid+'.key')
airodump_proc.kill()
airodump_proc.communicate()
crack_cmd = ['aircrack-ng', '-w', self.password_list, '-b', self.bssid, './log/' + self.bssid + '-01.cap','-l', './log/' + self.bssid + '.key']
crack_proc = Popen(crack_cmd, stdout=DN)
self.proc_list.append(crack_proc)
crack_proc.wait()
try:
f = open('./log/' + self.bssid + '.key')
key = f.read()
f.close()
self.key = key
self.crack_success = True
self.stop()
except:
pass
else:
self.send_deauths()
time.sleep(5)
return self.key
示例6: main
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def main():
try:
while True:
s, tmp = Popen(['factor'], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate(raw_input())
stdout.write('1')
stdout.write(s[s.find(':') + 1:].replace(' ', ' x '))
except EOFError:
pass
示例7: isCoherenceRunning
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def isCoherenceRunning(self):
if(self.onLinux):
output = Popen(["ps", "-C", "coherence"], stdout=PIPE).communicate()[0]
result = output.find("coherence")
if result > 0:
return True
else:
return False
示例8: get_permission_groups
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def get_permission_groups(self, username):
groups = []
groups_str = Popen(["groups", username], stdout=PIPE).communicate()[0]
if groups_str.find(":")!=-1:
groups_lst = groups_str.split(":")[1].strip()
groups = ["@%s"% x.strip() for x in groups_lst.split()]
self.env.log.debug('unixgroups found for %s = %s' % (username, ','.join(groups)))
return groups
示例9: run_bulk_extractor
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def run_bulk_extractor(target,block_size,concurrency_factor,quiet=True,retbuf=False):
""" Run the copy of bulk_extractor out of the same directory in which the script is running.
set the DFRWS2012 challenge variables."""
dn = os.path.dirname(os.path.realpath(__file__))
os.putenv("DFRWS2012","1")
d = tempfile.mkdtemp(prefix="pbulk")
os.rmdir(d) # delete it, so I can make it again
qflag = '0'
if quiet:
qflag = '-1'
cmd = [os.path.join(dn,'./bulk_extractor'),
'-e','all', # all modules
'-e','bulk', # explicitly turn on bulk
'-e','lift', # explicitly turn on LIFT
'-x','accts', # turn off accts
'-x','email', # turn off email
'-x','xor', # turn off xor
'-x','wordlist', # no wordlist
'-S','DFRWS2012=YES',
'-S','bulk_block_size='+str(block_size),
'-S','work_start_work_end=NO',
'-S','enable_histograms=NO',
'-C','0', # no context is reported
'-G'+str(page_size), # page size
'-g'+str(margin), # margin
'-q',qflag, # quiet mode
'-j',str(concurrency_factor),
'-o',d,
target]
if not quiet: print(" ".join(cmd))
if not retbuf:
print(" ".join(cmd))
call(cmd)
else:
ret=Popen(cmd,stdout=PIPE).communicate()[0].strip()
try:
space=ret.find(' ')
return ret[space+1:]
except TypeError:
space=ret.find(b' ')
return ret[space+1:].decode('utf-8')
if not quiet: print("output dir: {}".format(d))
示例10: test
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def test(self):
p = Popen("python manage.py printmodels", stdout=PIPE, stderr=PIPE, shell=True).stdout.read()
self.assertTrue(p.find("Bio") != -1)
Popen("bash save.bash", stdout=PIPE, stderr=PIPE, shell=True)
l = os.listdir(".")
for d in l:
if d.find(".dat") != -1:
f = open(d, "r")
self.assertTrue((f.read()).find("error") != -1)
f.close()
Popen("rm " + d, stdout=PIPE, stderr=PIPE, shell=True)
示例11: main
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def main( ):
'''Write some help documentation here
'''
input_file = 'tmpfile.m'
dogpack_home_dir = os.environ['DOGPACK']
t_order = 2
s_order = 4
number_pts = 1
iterations = 8
my_dictionary = {'dogpack_dir' : dogpack_home_dir, 'num_pts' : number_pts ,
's_order' : s_order, 't_order' : t_order }
print "# leading comments can be given a '#' character"
print "# running t_order = ", t_order, " space_order = ", s_order
old_err = i = 0
while( 1 ):
directory_num = my_dictionary['dir_num'] = i
folder = 'outputSL%(s_order)i_%(t_order)i_00%(dir_num)i' % my_dictionary
if( not os.path.exists(folder) ):
print 'Did Not find folder: ' + folder
break
my_dictionary['curr_folder'] = folder
# we want to do:
# data = open('dogpack.data','w')
# print >> data, dogpack_data_template % { 'mx': mx_now, 'ts_method': ts_method}
# data.close()
# and we avoid the .close() (even in case of exception) with 'with':
directory_num = i
with closing(open(input_file,'w')) as data:
# print >> data, dogpack_data_template % locals()
## if we had used same names for everything
print >> data, run_matlab_template % my_dictionary
s = Popen('matlab -nodesktop -nosplash < ' + input_file, shell=True, stdout=PIPE).communicate()[0]
new_err = float( s[s.find('>>')-1:len(s)].replace(">>","") )
r1 = '%(old)e %(new)e ' % {'old': old_err, 'new' : new_err}
if( new_err > 0 and old_err > 0 ):
rat = math.log( old_err / new_err, 2 )
else:
rat = 1.0
result = r1 + folder + ' log2( ratio ) = %(rat)8e' % \
{'old' : old_err, 'new' : new_err, 'rat' : rat }
print result
old_err = new_err
i = i + 1
示例12: check_buf_filetype
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def check_buf_filetype(buf, need_type):
if ukconfig.USE_MAGIC_LIB:
s = magic.from_buffer(buf)
else:
f = tempfile.NamedTemporaryFile(delete=False)
f.write(buf)
f.close()
s = Popen('file "{0}"'.format(f.name), stdout=PIPE, shell=True).stdout.read()
os.remove(f.name)
if s.find(need_type) != -1:
return True
else:
return False
示例13: main
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def main():
"""Write some help documentation here
"""
input_file = "tmpfile.m"
dogpack_home_dir = os.environ["DOGPACK"]
number_pts = 1
iterations = 4
my_dictionary = {"dogpack_dir": dogpack_home_dir, "num_pts": number_pts}
print "# leading comments can be given a '#' character"
old_err = i = 0
while 1:
directory_num = my_dictionary["dir_num"] = i
# folder = 'outputSL%(s_order)i_%(t_order)i_00%(dir_num)i' % my_dictionary
folder = "/var/tmp/seal/TestConvergenceHybrid/output00%(dir_num)i" % my_dictionary
if not os.path.exists(folder):
break
my_dictionary["curr_folder"] = folder
# we want to do:
# data = open('dogpack.data','w')
# print >> data, dogpack_data_template % { 'mx': mx_now, 'ts_method': ts_method}
# data.close()
# and we avoid the .close() (even in case of exception) with 'with':
directory_num = i
with closing(open(input_file, "w")) as data:
# print >> data, dogpack_data_template % locals()
## if we had used same names for everything
print >> data, run_matlab_template % my_dictionary
s = Popen("matlab -nodesktop -nosplash < " + input_file, shell=True, stdout=PIPE).communicate()[0]
new_err = float(s[s.find(">>") - 1 : len(s)].replace(">>", ""))
r1 = "%(new).3e " % {"old": old_err, "new": new_err}
if old_err > 0 and new_err > 0:
result = r1 + folder + " log2(ratio) = %(rat).3f" % {"rat": log((old_err / new_err), 2)}
else:
result = (
r1
+ folder
+ " log2(ratio) = %(rat).3f" % {"old": old_err, "new": new_err, "rat": (old_err / new_err)}
)
print result
old_err = new_err
i = i + 1
示例14: plexconnect_control
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def plexconnect_control(control):
global controlsupport
if control == "install" or control == "uninstall" or control == "remove":
if sys.platform.startswith('darwin'): #OSX specific
command = Popen("./support/OSX/"+control+".bash", shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
time.sleep(2) # actions may still be in progress
else:
if sys.platform.startswith('win32') and control == "remove":
call(plexconnectpath+"stop", shell=True)
time.sleep(3)
call(plexconnectpath+control, shell=True)
print("win "+plexconnectpath+":"+control)
else:
call(plexconnectpath+control, shell=True)
else:
if os.name == "posix": # OSX / Linux flavors
command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
else: # win 32
if controlsupport == False and control == "stop":
cmdShutdown()
shutdown()
time.sleep(2)
command = Popen("taskkill /FI \"IMAGENAME eq pythonw.exe\" /F", shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
call("echo PlexConnect is not running > plexconnect_status.txt",shell=True)
if controlsupport == False and control == "start":
proc = Popen(["start.bat"],shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(2)
call("echo PlexConnect is running > plexconnect_status.txt",shell=True)
if controlsupport == True and control == "start":
output = Popen("sc query PlexConnect-service", shell=True, stdout=PIPE).communicate()[0]
if output.find("FAILED") > 0:
command = Popen(plexconnectpath+" install", shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
time.sleep(3)
command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
time.sleep(3)
else:
command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
else:
command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0]
call("echo PlexConnect is not running > plexconnect_status.txt",shell=True)
time.sleep(2)
set_platform() # update all proper programfile & paths
time.sleep(2)
plexconnect_status(localIP)
示例15: convertEpisode
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import find [as 别名]
def convertEpisode(self):
self.convertMutex.tryLock(-1)
self.downloadMutex.tryLock(-1)
workItem = self.lstwToConvert.takeItem(0)
self.downloadMutex.unlock()
output_file = workItem.text()[:len(workItem.text()) - 3] + self.cbOutputFormat.currentText()
file_info = Popen(['ffmpeg', '-i', workItem.text()], stderr=PIPE)
file_info.wait()
file_info = file_info.stderr.read(-1).decode('utf-8')
file_info = file_info[file_info.find('Duration:') + 10:]
file_info = file_info[:file_info.find(',')]
file_time_info = file_info.split(':')
file_time_info = file_time_info + file_time_info[2].split('.')
length = int(file_time_info[0]) * 3600 + int(file_time_info[1]) * 60 + int(file_time_info[3])
self.pbConverted.setMaximum(length)
self.pbConverted.setValue(0)
self.appendLogs.emit('Zaczynam konwertować: ' + workItem.text())
'''TO DO Start converting'''
self.convertMutex.unlock()