def installMacOS(): import download import extract import stat url = 'http://www.on-tapp.tv/wp-content/vpn/openvpn-macos-2.3.4.zip' bindir = xbmc.translatePath('special://profile/addon_data/plugin.program.vpnicity/macos/sbin/') dest = os.path.join(bindir, 'openvpn-macos.zip') macbin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(macbin) os.chmod(macbin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def ocrInvoices(): myPath = path.getPath() for val in os.listdir(myPath): if val.endswith(".png") or val.endswith( ".jpg"): #OCRowanie plików .png picPath = myPath + '/' + val txtPath = picPath[:-4] + ".txt" img = Image.open(picPath) text = pytesseract.image_to_string(img, lang='pol') faktura = open(txtPath, "w") faktura.write(text) faktura.close() elif val.endswith(".pdf"): #OCRowanie plików .pdf pdfPath = myPath + '/' + val txtPath = pdfPath[:-4] + ".txt" imgPath = pdfPath[:-4] + ".jpg" xmlPath = pdfPath[:-4] + ".xml" c = pdftables.Client("baq0339zc5zj") c.xml(pdfPath, xmlPath) '''pdf2jpeg(pdfPath,imgPath) #Tworzenie grafiki z dokumentu pdf img = Image.open(imgPath) #OCRowanie stworzonej grafiki text = pytesseract.image_to_string(img, lang='pol') faktura = open(txtPath, "w") faktura.write(text) faktura.close()''' print("done")
def checkInstalled(): import path exists = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if not exists: if utils.yesno('Do you want to install the VPN application now'): import install install.install(silent=False)
def start_machine(device_name): print "start player" + device_name p = subprocess.Popen(path.getPath("player") + " --vm-name '" + device_name + "'", shell=True) start_machine_list.append(p.pid) print p.pid
def ocrToGetNumber(): myPath = path.getPath() for val in os.listdir(myPath): if val.endswith(".png") or val.endswith( ".jpg"): # OCRowanie plików .jpg i .png picPath = myPath + '/' + val txtPath = picPath[:-4] + ".txt" image = cv2.imread(picPath) #----------image preprocessing------------- gray = get_grayscale(image) thresh = thresholding(gray) opening_ = opening(gray) #na razie niepotrzebne canny1_ = canny(gray) #na razie niepotrzebne #cv2.imshow('img1', image) #cv2.waitKey(0) #------------------------------------------ text = pytesseract.image_to_string(image, lang='pol', config=config1) text = text.replace('-', '') faktura = open(txtPath, "w") faktura.write(text) faktura.close() elif val.endswith(".pdf"): # OCRowanie plików .pdf pdfPath = myPath + '/' + val txtPath = pdfPath[:-4] + ".txt" imgPath = pdfPath[:-4] + ".jpg" pdf2jpeg(pdfPath, imgPath) img = cv2.imread(imgPath) # OCRowanie stworzonej grafiki text = pytesseract.image_to_string(img, lang='pol', config=config1) text = text.replace('-', '') faktura = open(txtPath, "w") faktura.write(text) faktura.close()
def installMacOS(): import download import extract import stat url = utils.getResourceUrl() + 'openvpn-macos-2.3.4.zip' bindir = xbmc.translatePath( 'special://profile/addon_data/plugin.program.vpnicity/macos/sbin/') dest = os.path.join(bindir, 'openvpn-macos.zip') macbin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(macbin) os.chmod(macbin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('MacOS VPN application successfully installed') else: utils.dialogOK('MacOS VPN application installation failed', 'Please try again later')
def checkInstalled(): import path exists = path.getPath(utils.GetSetting('OS'), silent=True) if not exists: if utils.yesno('Do you want to install the VPN application now'): import install install.install(silent=False)
def shortest_path_backward_bfs(self, first_vertex, second_vertex): b = [] a = bfs(self, first_vertex) b = getPath(a, second_vertex) return b[0], b[1]
def getBestPath(): # Get the maze from a photo maze, ballPosition = imageProcessing.getMaze() #print(maze) print("Ball Position: ", ballPosition) # Resolve the maze if ballPosition == False: print("Marble is missing") servosPigpio.stopMotors() sys.exit("Marble is missing") # Resolve the maze if ballPosition == end: print("End reached") servosPigpio.stopMotors() sys.exit("End reached") bestPath, conditionalPathing = path.getPath(maze, ballPosition, end) if bestPath == "Impossible": print("No path") servosPigpio.stopMotors() sys.exit("No path") return bestPath, conditionalPathing
def get_need(line): try: cmd = line.cmdline if (line.name == 'adb'): if (cmd[1] == '-s' or cmd[1] == '-P'): if (len(cmd) >= 4): pass #if(cmd[3] == 'fork-server'): #return False return True if (line.name == path.getPath('pythonName')): if (len(cmd) >= 1 and cmd[1].find('test.py') > -1): return True if (line.name == 'player'): return True if (line.name == 'node'): return True if (line.name == 'sh'): return True if (line.name == 'VBoxHeadless'): return True return False except psutil.AccessDenied: return except psutil.NoSuchProcess: return
def OpenVPN(config): import path exe = path.getPath(ADDON.getSetting('OS')) if not exe: return None try: timeout = int(ADDON.getSetting('TIMEOUT')) except: timeout = 99999 if utils.platform() == "android": cmdline = "StartAndroidActivity(%s,%s,%s,%s)" % \ ( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.CONNECT", "com.vpnicity.openvpn.control.PROFILE_PATH", "file://" + config ) timeout = 0 else: cmdline = utils.getSudo() cmdline += '"' + exe + '"' cmdline += ' ' cmdline += '"' + config + '"' cmdline = cmdline.replace('\\', '/') print '++++++++++++++++++++++++++ cmdline is...', cmdline return Run(cmdline, timeout)
def install(silent=False): if utils.ADDON.getSetting('OS') == 'Windows': return if utils.ADDON.getSetting('OS') == 'MacOS': installMacOS() return cmdLine = utils.getSudo() cmdLine +='apt-get update;' cmdLine +='sudo apt-get -y install openvpn;' cmdLine +='sudo apt-get -y install psmisc' dp = None if not silent: dp = utils.progress('Installing VPN application', 'Please be patient this may take a few minutes') p = subprocess.Popen(cmdLine, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() if silent: return import xbmc xbmc.sleep(100) dp.close() success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def killGuard(config): pro_list = is_exist_in_process_list(path.getPath('pythonName')) print "杀死其他监控进程" for pro in pro_list: ##杀死其他监控进程 if (is_other_guard(pro) == True): kill(pro.pid) print_info(pro) killAll(getTargetList(config)) #杀死模拟器相关进程
def Main(): import message message.check() utils.checkVersion() vpn.CheckUsername() path.getPath(utils.ADDON.getSetting('OS'), silent=True) CheckPlugin() if not vpn.validToRun(): utils.log('Login Error') return # utils.checkOS() addDir('-- Configure %s' % TITLE, _SETTINGS, isFolder=False) current = xbmcgui.Window(10000).getProperty('VPNICITY_LABEL') if len(current) > 0: abrv = xbmcgui.Window(10000).getProperty('VPNICITY_ABRV') thumbnail = utils.DISABLE #'os.path.join(IMAGES, abrv.lower()+'.png') addDir('-- Disable %s %s' % (current, TITLE), _KILL, thumbnail=thumbnail, isFolder=False) mode = _COUNTRY isFolder = True if ADDON.getSetting('AUTO') == 'true': mode = _VPN isFolder = False countries = vpn.GetCountries() CreateFile('-Remove-') for country in countries: label = country[0] menu = [] menu.append((ENABLEAUTO % label, 'XBMC.RunPlugin(%s?mode=%d&abrv=%s)' % (sys.argv[0], _AUTO, urllib.quote_plus(country[2])))) thumbnail = os.path.join(IMAGES, country[2].lower()+'.png') addDir(label, mode, abrv=country[1], thumbnail=thumbnail, isFolder=isFolder, menu=menu) try: CreateFile(country[0], country[1]) except: pass
def start(num): try: if (sys.argv[2] != ""): num = num + " " + sys.argv[2] except: pass str1 = "python " + path.getPath( "test.py") + " " + num #+ " > /Users/yuhaiqiang/Desktop/log/test.log" subprocess.Popen(str1, shell=True)
def convertToKeyedArrays(relFilePath): with open(path.getPath(relFilePath), 'r') as f: results = {} for idx, L in enumerate(f): if idx in [0, 1, 2]: results[idx] = {'name': L.strip(), 'data': []} else: row = L.strip().split('\t') for index, value in enumerate(row): ((results[index])['data']).append(float(value)) return results
def convertToJson(relFilePath): with open(path.getPath(relFilePath), 'r') as f: #rows=[map(float,L.strip().split(',')) columns = {} resultList = [] jsonResult = {} for idx, L in enumerate(f): if idx in [0, 1, 2]: columns[idx] = L else: row = L.strip().split('\t') for index, value in enumerate(row): jsonResult[columns[index]] = value resultList.append(jsonResult) return resultList
def move(N, currentPos, color, isKill): k = 0 newPosition = 0 path = getPath(color) N = int(N) k = path.index(currentPos) if (k + N > 24 and not isKill): newPosition = k elif (k + N > len(path) - 1 or currentPos == path[-1]): newPosition = k else: newPosition = (k + N) return path[newPosition]
def drawMap(order): #Label(rightFrame, text=" ", bg='yellow').grid(row =0,column =0) path = getPath(grid, self.beginning, self.destination, order) for pa in path: for p in pa: Label(rightFrame, text=" ", bg='yellow').grid(row=p[1] - 1, column=p[0] - 1) Label(rightFrame, text=" ", bg='red').grid(row=self.beginning[1] - 1, column=self.beginning[0] - 1) Label(rightFrame, text=" ", bg='red').grid(row=self.destination[1] - 1, column=self.destination[0] - 1) for item in order: p = grid[item] Label(rightFrame, text=" ", bg='blue').grid(row=p[1] - 1, column=p[0] - 1)
def OpenVPN(config): import path exe = path.getPath(ADDON.getSetting('OS')) if not exe: return None try: timeout = int(ADDON.getSetting('TIMEOUT')) except: timeout = 99999 cmdline = utils.getSudo() cmdline += '"' + exe + '"' cmdline += ' ' cmdline += '"' + config + '"' cmdline = cmdline.replace('\\', '/') return Run(cmdline, timeout)
def install(silent=False): if utils.ADDON.getSetting('OS') == 'Windows': return if utils.ADDON.getSetting('OS') == 'MacOS': installMacOS() return if 'OpenELEC' in utils.ADDON.getSetting('OS'): installOpenELEC() return cmdLine = utils.getSudo() cmdLine += 'apt-get update;' cmdLine += 'sudo apt-get -y install openvpn;' cmdLine += 'sudo apt-get -y install psmisc' dp = None if not silent: dp = utils.progress('Installing VPN application', 'Please be patient this may take a few minutes') p = subprocess.Popen(cmdLine, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() if silent: return import xbmc xbmc.sleep(100) dp.close() success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def start(num): try: if (sys.argv[2] != ""): num = num + " " + sys.argv[2] except: pass str1 = "python " + path.getPath( 'root' ) + "scripts/test.py " + num #+ " > /Users/yuhaiqiang/Desktop/log/test.log" p = subprocess.Popen(str1, shell=True) playerName = DEVICES[sys.argv[1]] utils.sleep(50) ip = getDeviceId() config = {} config['pid'] = p.pid config['ip'] = ip config['playerName'] = playerName return config
def getDevice(num): pythonName = path.getPath('pythonName') if (pythonName == False): pythonName = 'Python' devicePros = is_exist_in_process_list(pythonName) currPId = os.getpid() for pro in devicePros: print_info(pro) try: cmd = pro.cmdline ####杀死启动本模拟器的其他进程组 if (cmd[1].find("test.py") > -1 and cmd[2] == num and isChildProcess(pro, currPId) == False): print_info(pro) return pro except psutil.AccessDenied: pass except psutil.NoSuchProcess: pass return False
def OpenVPN(config): import path exe = path.getPath(ADDON.getSetting('OS')) if not exe: return None try: timeout = int(ADDON.getSetting('TIMEOUT')) except: timeout = 99999 if utils.platform() == "android": cmdline = "StartAndroidActivity(%s,%s,%s,%s)" % \ ( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.CONNECT", "com.vpnicity.openvpn.control.PROFILE_PATH", "file://" + config ) else : cmdline = utils.getSudo() cmdline += '"' + exe + '"' cmdline += ' ' cmdline += '"' + config + '"' cmdline = cmdline.replace('\\', '/') return Run(cmdline, timeout)
def installOpenELEC(): import download import extract import stat url = utils.getOEUrl() if not url: utils.dialogOK('You do not appear to be running OpenELEC', 'Please check your settings') return bindir = xbmc.translatePath( 'special://profile/addon_data/plugin.program.vpnicity/bin/') dest = os.path.join(bindir, 'openvpn-oe.zip') oebin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(oebin) os.chmod(oebin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def installOpenELEC(): import download import extract import stat url = utils.getOEUrl() if not url: utils.dialogOK('You do not appear to be running OpenELEC', 'Please check your settings') return bindir = xbmc.translatePath('special://profile/addon_data/plugin.program.vpnicity/bin/') dest = os.path.join(bindir, 'openvpn-oe.zip') oebin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(oebin) os.chmod(oebin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def getTargetList(config): targets = list() targets.append('adb') targets.append('player') targets.append(path.getPath('pythonName')) targets.append('sh') targets.append('node') targets.append('VBoxHeadless') print config['pid'] target_list = list() for target in targets: pro_list = is_exist_in_process_list(target) ##返回该名字的进程列表 if (len(pro_list) != 0): #如果为0 ,则没有匹配进程 print target + '进程共 ' + str(len(pro_list)) + ' 个 匹配如下:' for pro in pro_list: if (isChildProcess(pro, config['pid']) == True or pro.name == "VBoxHeadless"): if (get_need(pro) == True): print_info(pro) target_list.append(pro) else: print target + ':没有找到相关进程' return target_list
import parse_invoice import path import tess_ORC myPath = path.getPath() def validateInvoice(path): invoices = parse_invoice.startColletion(path) tess_ORC.getInvoiceNumber(invoices, path) tess_ORC.getBuyerData(invoices, path) tess_ORC.getSellerData(invoices, path) tess_ORC.getInvoiceAmount(invoices, path) tess_ORC.getPositionsList(invoices, path) return invoices if __name__ == "__main__": invoices = validateInvoice(myPath) print("done")
def __init__(self): self.filePath = path.getPath()
from __future__ import unicode_literals import youtube_dl from path import getPath, changePath # from query import queryMusic from spotify import metadataGen from metascript import removeTags # path = "./songs/" path = getPath() def asciiCheck(s): return all(ord(c)<128 for c in s) while 1: menu_input = int(input("\nMenu :\n[1] Query Music \n[2] Change Dest\n")) if menu_input == 1: yt_link = input("Enter link : ") with youtube_dl.YoutubeDL({}) as ydl: info_dict = ydl.extract_info(yt_link, download=False) yt_title = info_dict.get('title', None) while(not all(ord(c)<128 for c in yt_title)): print("Error: \""+yt_title+"\" has non-ascii characters") yt_title = input("Enter new name : ") yt_title = removeTags(yt_title) ydl_opts = {
def restartBootDetect(): killBootDetects() cmd = "python " + path.getPath('root') + "scripts/boot_detect.py" subprocess.Popen(cmd, shell=True) print "重启 启动锁 监控进程"
training.append([bag, output_row]) random.shuffle(training) training = np.array(training) train_x = list(training[:, 0]) train_y = list(training[:, 1]) tf.reset_default_graph() net = tflearn.input_data(shape=[None, len(train_x[0])]) net = tflearn.fully_connected(net, 8) net = tflearn.fully_connected(net, 8) net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax') net = tflearn.regression(net) model = tflearn.DNN(net, tensorboard_dir=path.getPath('train_logs')) model.fit(train_x, train_y, n_epoch=20000, batch_size=500, show_metric=True) model.save(path.getPath('model.tflearn')) def clean_up_sentence(sentence): sentence_words = nltk.word_tokenize(sentence) sentence_words = [stemmer.stem(word.lower()) for word in sentence_words] return sentence_words def bow(sentence, words, show_details=False): sentence_words = clean_up_sentence(sentence) bag = [0] * len(words) for s in sentence_words: for i, w in enumerate(words):
def main(): currentTime = time.strftime('%Y_%m_%d_%H_%M', time.localtime(time.time())) PORT = 4723 + int(sys.argv[1]) - 1 BOOTSTRAP = 2251 + int(sys.argv[1]) - 1 #UDID = 101 + int(sys.argv[1]) - 1 for key in data.ACCOUNT_INFO: data.queue.put(data.ACCOUNT_INFO[key]) start_thread_list = list() appium_thread_list = list() operate_thread_list = list() adblogcat_thread_list = list() machineUdid_list = list() machinePort_list = list() print 'before' #id = os.getpid() #cmd = "kill -9 %d" % int(pid) #os.system(cmd) #targetApk = input("choose the app you want to operate: 1. qzone 2. baidu_tieba \n") #operateType = APP_MAP[targetApk] lock = path.getPath('root') + 'boot.lock' #设置启动文件锁 while (os.path.isfile(lock) == True): print "其他模拟器正在启动,10s后启动..." utils.sleep(10) fp = open(lock, 'w') fp.close() # 启动模拟器 for device_name in DEVICE_LIST: start_thread_list.append( threading.Thread(target=start_machine, args=(device_name, ))) for thread in start_thread_list: thread.start() print "start virtual" utils.sleep(40) device_id = '' #popen = subprocess.Popen("adb devices",shell = True) #str = popen.stdout # 启动appium_server for device_name in DEVICE_LIST: #machineUdid = '192.168.57.{}:5555'.format(UDID) machineUdid = getDevice() device_id = machineUdid machineUdid_list.append(machineUdid) machinePort = '{}'.format(PORT) machinePort_list.append(machinePort) machineBootStrap = '{}'.format(BOOTSTRAP) appium_thread_list.append( threading.Thread(target=start_appium_server, args=(machinePort, machineBootStrap, machineUdid))) PORT = PORT + 1 BOOTSTRAP = BOOTSTRAP + 1 #UDID = UDID + 1 #删除文件锁,同时将ip存入文件中 try: res = os.remove(lock) except: pass device_name = DEVICE_LIST[0] fp = open(path.getPath("root") + device_name + '.info', 'w') fp.write(device_id) fp.close() print('start adblogcat') for udid in machineUdid_list: fileName = path.getPath("log") + device_name + '_{}_{}'.format( udid, currentTime) adblogcat_thread_list.append( threading.Thread(target=start_adb_logcat, args=(udid, fileName))) for thread in adblogcat_thread_list: thread.start() print('start appium') for thread in appium_thread_list: thread.start() utils.sleep(40) ###appium启动慢 i = 0 for id in DEVICE_LIST: operate_thread_list.append( threading.Thread(target=APP_MAP.get(int(sys.argv[1])), args=(machinePort_list[i], machineUdid_list[i]))) i = i + 1 utils.sleep(10) for thread in operate_thread_list: thread.start() for thread in operate_thread_list: thread.join() utils.sleep(10) for start in start_machine_list: cmd = "kill -9 %d" % int(start) #print "执行" os.system(cmd) for start in start_appium_list: cmd = "kill -9 %d" % int(start) #print "执行" os.system(cmd) for start in start_adb_list: cmd = "kill -9 %d" % int(start) #print "执行" os.system(cmd) pid = os.getpid() cmd = "kill -9 %d" % int(pid) os.system(cmd)
def is_illegal(target_list, config): pid = config['pid'] ip = config['ip'] playerName = config['playerName'] argv1 = sys.argv[1] argv2 = sys.argv[2] num = 8 t_cmds = [1] * num ignore = "ignore" t_cmds[0] = ['adb', '', '-s', ignore, 'shell'] t_cmds[1] = ['adb', '', '-s', ignore, 'logcat', '-v', 'time'] #t_cmds[2] = ['adb', '','-P', 'ignore','-s','ignore', 'logcat','-v','threadtime'] t_cmds[2] = ['player', '', '--vm-name', ignore] t_cmds[3] = [path.getPath('pythonName'), '', 'ignore:', ignore, ignore] #t_cmds[4] = ['sh','','-c', ignore]##近似 t_cmds[7] = [ 'node', '', 'ignore:', '-p', 'ignore:', '-bp', 'ignore:', '-U', ignore ] t_cmds[4] = [ 'VBoxHeadless', '', '--comment', playerName, 'startvm', 'ignore:', 'ignore:', 'ignore:' ] t_cmds[5] = ['adb', '', '-s', ignore, 'logcat'] t_cmds[6] = [path.getPath('pythonName'), '', 'test.py', 'ignore', 'ignore'] #t_cmds[8] = ['adb','','-P','ignore:','fork-server','server','--reply-fd','ignore:'] is_illegal = True matchPros = list() print "子进程如下" for pro in target_list: print_info(pro) print "子进程如上" for pro in target_list: #if(isChildProcess(pro, pid) == False and pro.name != "VBoxHeadless"): # continue try: cmd = pro.cmdline for t_cmd in t_cmds: if (t_cmd[0] == pro.name): #t_cmd[1] = "1" is_match = True if (t_cmd[1] == "1"): ##如果找到那么就不找了 continue if (len(cmd) != len(t_cmd) - 1): ##一定不匹配 continue for j in range(2, len(t_cmd) - 1): if (t_cmd[j].find(ignore) > -1): continue if (cmd[j - 1].find(t_cmd[j]) == -1 ): # -1 是因为在第二位添加了一个标识位.如果不相等,那么说明,不匹配 is_match = False if (t_cmd[0] == "VBoxHeadless" and j == 3 and len(cmd[j - 1]) != len(t_cmd[j])): ##如果VBox is_match = False if (is_match == True ): ##如果匹配则将相应进程标志为 1,说明该进程存在,(但是不一定合法,还需合法性验证) t_cmd[1] = "1" matchPros.append(pro) ##加入匹配列表 for j in range(2, len(t_cmd) - 1): t_cmd[j] = t_cmd[j][0:7] t_cmd[j] += cmd[j - 1] if (is_illegal_pro(pro) == False): print "不合法进程:" print_info(pro) is_illegal = False except: continue res = {} for t_cmd in t_cmds: if (t_cmd[1] == ''): str = "" for t in t_cmd: str += (" " + t) print "没有该进程:" + str is_illegal = False res['status'] = is_illegal res['matchlist'] = matchPros for pro in matchPros: print_info(pro) return res
def start_appium_server(port, bootstrap, udid): # 无阻塞调用shell命令 p = subprocess.Popen(path.getPath("main.js") + " -p '" + port + "' -bp '" + bootstrap + "' -U '" + udid + "'", shell=True) start_appium_list.append(p.pid)
def getShortestCostWalk(self, first_vertex, second_vertex): cost = self.dictCosts tree = dijkstra(self, cost, first_vertex) #print (tree) print(getPath(tree, second_vertex))
def markovchainAllUsers(filepath,dirnameMC,dirnameMCDiff): #** Definitions #newspace=[ .. -8,-4,0,4,8 ..] if separation=4 #len(newspace)=numchanges #For x : 0~0.5 to 25~30 #For x_: -20 to 20 dirnameMC= path.getPath(filepath,"MarkovChain") dirnameMCDiff= path.getPath(filepath,"MarkovChainDiff") #shell("mkdir "+dirnameMC) #shell("mkdir "+dirnameMCDiff) if SAVE: allx=[] for filename in shell("ls "+filepath+" | grep .csv"): userid=filename.rstrip(".csv") x=getCol(filepath+str(userid)+".csv",-1) allx=allx+[float(num) for num in x] #x=np.asarray(x).astype(float) #allx=np.hstack((allx,x)) #x_=np.diff(x) #allx_=np.hstack((allx_,x_)) allx=np.array(allx) allx_=np.diff(allx) meanallx=np.mean(allx) stdallx=np.std(allx) meanallx_=np.mean(allx_) stdallx_=np.std(allx_) np.save("Save/meanallseqx",meanallx) np.save("Save/meanallseqx_",meanallx_) np.save("Save/stdallseqx",stdallx) np.save("Save/stdallseqx_",stdallx_) else: meanallx=np.load("Save/meanallx.npy") meanallx_=np.load("Save/meanallx_.npy") stdallx=np.load("Save/stdallx.npy") stdallx_=np.load("Save/stdallx_.npy") #** For each user for filename in shell("ls "+filepath+" | grep .csv"): userid=filename.rstrip(".csv") #** Get RSS information x=getCol(filepath+str(userid)+".csv",-1) x=np.asarray(x).astype(float) #** Store MarkovChain for all users separation=stdallx#3 numchanges=3 np.save(dirnameMC+userid,markovchain(x,numchanges,separation)) #** Find the derivative of the signal x_=np.diff(x) #** Store MarkovChainDiff for all users separation=stdallx_#4 numchanges=3 np.save(dirnameMCDiff+userid,markovchain(x_,numchanges,separation))
# -*- coding: UTF-8 -*- import os import sys import subprocess import psutil import utils import path pythonName = path.getPath('pythonName') ##打印进程信息 def print_info(line): try: print str(line.pid) + ' : ' + line.name + str(line.cmdline) except psutil.AccessDenied: print str(line.pid) + ' : ' + line.name print '没有权限访问cmdline' return except psutil.NoSuchProcess: print '没有该进程' return ####判断该进程是否在进程列表中 def is_exist_in_process_list(name): process_list = psutil.get_process_list() res_list = list() for line in process_list: try: if (line.name == name):