def pass_command(args): c = 0 if not args.findfile: items = listmanager.counter(args.text_file) process = list() while items != 0: if c == 0: c += 1 else: print("") listmanager.printcurrent(args.text_file) arguments, nonevar = getargs(args, separate_list=False) # print(arguments) process.append(subprocess.Popen(arguments)) for p in process: p.wait() # print(str(p.poll())) while p.poll() == None: if p.poll() != None: p.terminate() listmanager.striplines(args.text_file, number=1, counter=True) items -= 1 return items else: arguments, nonevar = getargs(args, separate_list=False) # print(arguments) process = list() process.append(subprocess.Popen(arguments)) for p in process: p.wait() # print(str(p.poll())) while p.poll() == None: if p.poll() != None: p.terminate() return 0
def pararell(args, workers): from subprocess import call from time import sleep c = 0 workers = int(workers) tfile = args.text_file args0 = args f = False filelist = listmanager.read_lines_to_list(tfile, all=True) if not args.findfile: items = listmanager.counter(args.text_file) index = 0 process = list() while items != 0: if c == 0: c += 1 else: #print("") pass from colorama import Fore colors = Fore.__dict__ p = 0 for r in range(workers): if index != items: k = 0 l = p for col in colors: if l > len(colors): l = l - len(colors) color = colors[col] if k == (l + 1): break else: k += 1 #listmanager.printcurrent(tfile) try: f = filelist[index] except: break tq = tqdm(leave=False, position=0) #tq = tqdm(leave=False,position=0,bar_format="{l_bar}%s{bar}%s{r_bar}" % (color, color)) tq.write('Opening thread for ' + f) tq.close() tq = tqdm(total=1, unit='|', leave=True, position=0, bar_format="{l_bar}%s{bar}%s{r_bar}" % (color, Fore.RESET)) tq.update(1) tq.close() opworkers = workers if items < workers: opworkers = items arguments, nonevar = getargs(args, separate_list=False, current=f, pos=p, tothreads=opworkers) #print(arguments) f = False args = args0 #print(arguments) process.append(subprocess.Popen(arguments)) index += 1 p += 1 for pr in process: #pr.wait() #call('clear' if os.name =='posix' else 'cls') # print(str(p.poll())) while pr.poll() == None: sleep(3) if os.name == 'posix': call('clear') #linux else: try: call('cls') #macos except: print("\n" * 100) os.system('cls') #windows listmanager.counter(tfile, doprint=True) p = 0 index2 = index - workers for r in range(workers): if index2 != items: k = 0 l = p for col in colors: if l > len(colors): l = l - len(colors) color = colors[col] if k == (l + 1): break else: k += 1 #listmanager.printcurrent(tfile) try: f = filelist[index2] except: break tq = tqdm(leave=False, position=0) # tq = tqdm(leave=False,position=0,bar_format="{l_bar}%s{bar}%s{r_bar}" % (color, color)) tq.write('Opening thread for ' + f) tq.close() tq = tqdm(total=1, unit='|', leave=True, position=0, bar_format="{l_bar}%s{bar}%s{r_bar}" % (color, Fore.RESET)) tq.update(1) tq.close() index2 += 1 p += 1 if pr.poll() != None: pr.terminate() if os.name == 'posix': call('clear') #linux else: try: call('cls') #macos except: os.system('cls') #windows listmanager.striplines(tfile, number=workers, counter=False) items -= workers if items < 0: items = 0 return items