def imprimir_input(enteros : list, flotantes = None, mensaje_de_advertencia = None): """ Imprime las teclas introducidas hasta el momento, Recibe un mensaje de advertencia en caso de que se supere el rango (opcional) Retorna None en caso de que se de a enter sin haber introducido nada """ command('clear') print(mensaje, end='') if lista_vacia(enteros): print() else: if enteros[0] == '-': print('-', end='') enteros = enteros[1:] # en caso de que el numero sea negativo se empieza a contar # desde el segundo elemento para evitar que el '-' moleste iterator = 0 for i in enteros: print(i,end='') iterator += 1 sublista = enteros[iterator:] if (len(sublista) > 0) and ((len(sublista) %3) == 0): print('.',end='') if flotantes != None: print(',',end='') for i in flotantes: print(i, end='') print(mensaje_de_advertencia if mensaje_de_advertencia != None else '') print()
def anal(name, mode): node = 'node' # sciezka do nodejs boxjs = 'run.js' # sciezka do box-js decode = '' # sciezka do deocodera box-js if name.endswith("jse"): os.command(decode + " " + name + " -o " + name.replace("jse", "js")) else: if mode == '-h': HELP() sys.exit() elif mode == '-U': # U - Uniwersalny analysis(name, F.t30, F.nfe) elif mode == '-D': # D - Download analysis(name, F.t30, F.nfe, F.d) elif mode == '-oD': # oD - Only Download analysis(name, F.d) elif mode == '-LD': # LD - Long Download flags = ' '.join([F.t120, F.d]) # Laczymy flagi dla boxa w jeden string print flags # DEBUG command = ' '.join([ node, boxjs, name, flags ]) # Laczymy cala komenda w jeden string dzielony spacjami print command # DEBUG #run(command) # odpalamy analize #---- cmd = ' '.join([node, boxjs, name]) run(cmd, flags)
def main(): # start camera camera = PiCamera() camera.start_preview() sleep(2) while (True): # do everything forever sleep(15) camera.capture('image.jpg') os.system('git add image.jpg') os.system('git commit') os.system('git push') response = requests.get("uas-at-fgcu/soc") tasks = json.load(response.text) if tasks["camera-mode"] == 'default': camera.exposure_mode = 'auto' camera.image_effect = 'none' if tasks["camera-mode"] == 'night': camera.exposure_mode = 'night' if tasks["camera-restart"] == True: # restart camera camera.stop_preview() sleep(2) camera.start_preview() sleep(2) if tasks["soc-restart"] == True: os.command("shutdown -r now") pass
def rsync(): data_dir = get_data_dir() archive_dir = get_archive_dir() flags = ["-r"] command_words = ["rsync"] + flags + [data_dir, archive_dir] command_str = " ".join(command_words) os.command(command_str)
def save_file(data, filepath): if os.path.exists(filepath): os.command("mv %s %s_%s" % (filepath, filepath, date_string()), shell=True) f = open(filename, 'w') f.writelines(data) f.close()
def genera_password(tipo_caratteri, lunghezza): password = '' lung_str_diff = len(tipo_caratteri) - 1 print('\n') #CREA SPAZIO for i in range(lunghezza): password += tipo_caratteri[randint(0, lung_str_diff)] cprint(' ' + password, 'yellow') try: seconda_scelta = int(input( '''\n\nCosa vuoi fare adesso? 1 - Scriverla su un file.txt 2 - Creane un\'altra 3 - Copiarlo nella clipboard 4 - Cancellare i comandi del terminale e uscire dal programma 0 - Uscire dal programma ''')) if seconda_scelta == 1: nome = input('\n Scegli il nome del file (senza estenzione): ') home = check_output(['xdg-user-dir', 'DESKTOP']) # print(home[0:-1] + '/' + nome + '.txt') path = home[0:-1] + '/' + nome + '.txt' try: f = open(path , 'w') f.write(path + '\n\nLa tua password è: ' + password) f.close() cprint('\n La tua password è stata salvata in ' + path, 'green') print('\n Grazie e arrivederci!\n\n**********************************************************') except: cprint('\n Qualcosa è andato storto...', 'red') decisione_tipo_password() elif seconda_scelta == 2: print('\n**********************************************************\n') decisione_tipo_password() elif seconda_scelta == 3: copy(password) cprint('Password salvata negli appunti!\n\n Grazie e arrivederci!\n', 'blue') elif seconda_scelta == 4: command('clear') elif seconda_scelta == 0: cprint('\n Grazie e arrivederci!\n', 'blue') else: cprint('\nHAI INSERITO UN NUMERO NON VALIDO!\n', 'red') except KeyboardInterrupt: cprint('\n Grazie e arrivederci!\n', 'blue')
def goodbye(): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) except: pass command("echo 'stop' > ./attack.txt") s.close()
def delete_directory(path): try: cmd = "rm -rf {}".format(path) os.command(cmd) except OSError: print("Deletion of the directory %s failed" % path) else: print("Successfully deleted the directory %s" % path)
def startAttack(): victim = raw_input("Enter ip of victim: ") r = re.compile(r'.{1,3}[.].{1,3}[.].{1,3}[.].{1,3}$') if r.match(victim): command("echo 'run;" + victim + "' > ./attack.txt") time.sleep(5) attack() else: print("Only input ip addresses") startAttack()
def move_files(file_names, old_path, new_path, ext=None): """move files to different directory""" # generate new names if ext: for i in range(len(file_names)): file_names[i] = file_names[i] + '.' + ext for i, file_name in enumerate(file_names): os.command('mv ' + os.path.join(old_path, file_name) + ' ' + os.path.join(new_path, file_name))
def grab_latest_prod_data(self): """ Grab the latest uids and passwords from production, so that we have them up-to-date for our scrapes. """ # Grab the file from the porduction box. # There is a process running on production that keeps this file updated # rsync -r -v --progress -e ssh [email protected]:/home/hirsh/portalInfo.txt /temp/portalInfo.txt # TODO: make sure return value is good. os.command('rsync -e ssh [email protected]:/home/hirsh/portalInfo.txt /temp/portalInfo.txt') time.sleep(4)
def dice(): command('clear') print("Rolling...") wait(1) command('clear') d1 = die(1,6) d2 = die(1,6) d3 = die(1,6) d4 = die(1,6) d5 = die(1,6) return [d1, d2, d3, d4, d5]
def exit(self, shutdown): self.Config.set("Settings", "current_screen", self.current_screen) self.Config.set("Settings", "logging_enabled", self.logging_enabled) self.Config.set("Settings", "mpg_enabled", self.mpg_enabled) self.Config.write(self.config_path) print("Configuration saved.") self.lcd.clear() self.lcd.noDisplay() if shutdown: os.command("sudo shutdown now") sys.exit() elif not shutdown: sys.exit()
def grab_latest_prod_data(self): """ Grab the latest uids and passwords from production, so that we have them up-to-date for our scrapes. """ # Grab the file from the porduction box. # There is a process running on production that keeps this file updated # rsync -r -v --progress -e ssh [email protected]:/home/hirsh/portalInfo.txt /temp/portalInfo.txt # TODO: make sure return value is good. os.command( 'rsync -e ssh [email protected]:/home/hirsh/portalInfo.txt /temp/portalInfo.txt' ) time.sleep(4)
def main(): paths = [ 'C:\\Windows\\Prefetch', 'C:\\Windows\\Temp', 'C:\\Users\\%USER%\\AppData\\Local\\Temp' ] command('color a') command('cls') for path in paths: clearPath(path) jumpLine(1) command('echo ' + '+' + '-' * 100 + '+') jumpLine(1) command('echo [*] Finalizado com sucesso!') jumpLine(1) command('pause')
class Main: def __init__(self): self.name = "functions executor" def google-chrome(self, postfixcommand=""): if postfixcommand=="": command = self.mainwordsmapping() os.command()
def rename_data(file_path, file_names, names, ext): """rename files """ # generate new names new_names = [] for i in range(len(file_names)): name = '' for j in range(len(names)): name = name + names[j][i] + '_' new_names.append(name[:-2]) for i, file_name in enumerate(file_names): old_path = os.path.join(file_path, file_name + '.' + ext) new_path = os.path.join(file_path, new_names[i] + '.' + ext) os.command('mv ' + old_path + ' ' + new_path) return new_names
def launch(): # allows for a clear command to run from os import system as command # clears the screen before beginning command("clear") # unimports it, we are done with it del command # prints main screen print("##########################################################") print("# PY3 WebCrawl #") print("# #") print("# Authors: #") print("# Kevin Becker <*****@*****.**> #") print("# Ben Champion <*****@*****.**> #") print("##########################################################") # launches main main()
def CreateHash(i,hash,hashc,escape,ruta): #,hash,hashc,escape ARGS if i == 312: command("mkdir %s/%s" % (ruta, hashc + "Ik0P2As")) for root,directorio,archivo in os.walk(ruta): if len(root) > 131: command("echo '%s' > %s/%s/temp" % (hash,ruta,hashc + "AD")) else: pass #command("echo '%s' > %s/%s/temp" % (hashc,ruta,hashc)) else: command("mkdir %s/%s" % (ruta,hashc)) command("echo '%s' > %s/%s/temp" % (hashc,ruta,hashc))
def create_screen(self, file_path=None): file_path = file_path if file_path else self.file_path res = None try: logger.debug("Saving image on: %s ...." % file_path) res = command(self.config["cmd_screenshot"] % file_path) except: logger.exception("Unable to create image file") return self.file_path if (res >= 0) else None
def GiveTurnTo(self, target, delay_time): self.state = 'DEFENDING' if target.hp <= 0: target.hp = 0 target.state = 'DEFEATED' self.state = 'WON' else: target.state = 'ATTACKING' if self.hp > self.max_hp: self.hp = self.max_hp delay(delay_time) if platform == 'linux': command('clear') else: command('cls') #show the info about fighters print(self.statusBar + target.statusBar + '\n' * 2) #show battle logs for i in range(len(self.history)): print(self.history[i] + target.history[i])
def infer(xdata_full, ind_calib, ydata, data_err, nmcmc=10000,gamma=0.1,fixindnom=None): xdata_all=xdata_full[ind_calib] np.savetxt('xdata_all.txt',xdata_all) np.savetxt('ydata_calib.txt',ydata) np.savetxt('dataerr_calib.dat', data_err) np.savetxt('xdata_calib.txt',xdata_all[ind_calib]) dim = np.loadtxt('mindexp.0.dat').shape[1] if fixindnom!=None: np.savetxt('fixindnom.dat', fixindnom) dim -= fixindnom.shape[0] comstr = 'model_inf -l classical -o 0 -i uniform -t xdata_all.txt -f pcs -c LU -s pci -u 5 -a -1 -b 1' #uniform_lupci? comstr += ' -m '+str(nmcmc)+' -g '+str(gamma)+' -d '+str(dim) comstr += ' -z -x xdata_calib.txt -y ydata_calib.txt ' # -e $EE -j chainstart.dat if fixindnom!=None: comstr += ' -v fixindnom.dat' os.command(comstr) return
def playVideo(pin): global state global player if not state: try: print("Starting video") player = OMXPlayer(path) state = False time.sleep(5) return "success" except Exception as e: print(e) return "error" else: try: print("Stopping video") player.quit os.command('killall omxplayer') state = True time.sleep(5) return "success" except Exception as e: print(e) return "error"
def task_00(): ''' 由于 office 自动调整行高的功能,导致文字上下离线太近, 而每行的高度都不同, 需求: 把各行高度都增加 25 像素 ''' from openpyxl import load_workbook # 载入 workbook, 显示 sheet 的名称 wb = load_workbook('target.xlsx') print(wb.sheetnames) # 选择 第2张 sheet ws = wb[wb.sheetnames[1]] # 6~64行, 每行高度增加 25; for i in range(6, 65): ws.row_dimensions[i].height += 25 # 保存 wb.save('targetX.xlsx') # 打开目录 command("explorer .")
import sys import os args = sys.argv list_of_args = args[1:] print(list_of_args) for arg in len(list_of_args): result = os.command()
def jumpLine(linhas): for i in range(linhas): command('echo.')
flag3 = 0 # print flag1 # print lines # print lines return lines.split(':')[1].strip() else: if (flag1 == 1) and (flag2 == 1) and (flag3 == 1): if lines.find('IP') >= 0: # print flag1 flag1 = 0 flag2 = 0 flag3 = 0 # print flag1 print lines return lines.split(':')[1].strip() ''' hallNo = argv[0] machineType = argv[1] machineIP = lookup('hallNo','machineType') os.command('ping machineIP') ''' #find ip #ip = lookup('NCHGT','DINGXIN') #print ip #(status,output) = commands.getstatusoutput("'ping %s' % ip") #print status #print output #os.system('ping %s' % ip) #ping module if __name__ == '__main__': listAllIn = iterationTerm()
def doSsh(host, user): os.command('ssh -Y '+user+'@'+host)
def clearPath(path): cd(path) command('del /q /f /s *')
def main(): args = parse_arguments() if args.scenario and not (args.scenario[0] == "@"): print("/!\ [WARNING] /!\ \n===> The scenario must have the '@' sign!") sys.exit(1) execution_time_output = "%s/%s" % (args.output, "execution_time.txt") print("EXECUTION TIME OUTPUT %s" % execution_time_output) os.command("touch %s" % execution_time_output) os.command("echo > %s" % execution_time_output) for x in range(args.begin, args.begin + args.nbr): """ Test nbr times the app and the energy consumption """ # Force the device to clear logs subprocess.Popen(["adb", "logcat", "-c"], shell=False) # Output name to store data current_output = get_new_output(args.output, args.app, args.refactored, x) force_stop_app(args.app) # Call the garbage collector to launch if args.gc: launch_gc_app() force_stop_app(gc_app) # Wait 10 seconds to avoid biases caused with the garbage collector application launch time.sleep(10) yocto_device = None try: # Default framerate is 75/s yocto_device = YoctoDevice("75/s", True) print(yocto_device) except Exception as yocto_exception: print(yocto_exception) sys.exit(1) # Create an event to stop the current thread thread_stop = threading.Event() # Launch the test ttest = threading.Thread(target = threaded_test, args=(thread_stop,x,args.app,args.feature,args.scenario)) ttest.start() # Run the device yocto_device.run() # Wait tests stops... ttest.join() # ... and stop the yocto device! yocto_device.stopMeasure() print(CStatistics([y for x, y in yocto_device._values])) os.command("adb logcat | grep EXEC >> %s" % execution_time_output) print("DONE") clear_cache_file(app)
def my_ip(): ip = requests.get("http://httpbin.org/ip").json() IP = ip["origin"] return IP IP = my_ip() def word(): f = open("D:\FMS\ip.txt", "a") Word = f.write("%s" % IP) f.close() return Word while True: file = word() print(file) ipchange = os.command("ping 4.4.4.4 -n 3") # 触发换IP try: if ipchange: while True: file = word() print(file) except: print("1")
#!/bin/sh """:" exec python $0 ${1+"$@"} """#" import os try: os.command("ls -l") except: print 'Something went wrong' class Big_stuff: def __init__(self): print 'init running' print 'running and running' def howdy(self): print 'go gorilla' def biggest(): x = 1 y = 2 if x >= y: return x elif y >= x: return y print 'do the run run run' import os
def rename_filter(bfile: str, outfile: str): command = "./plink --bfile {} --silent --make-bed --out {}".format( bfile, outfile) os.command(command)
# if result.filename == None: # print "No gene expression source file exit, use argument '-h' for help!" # sys.exit(1) # else: # folder_names_path = result.folder_names_path folder_names_path = './folder_list.txt' fp = open(folder_names_path, 'r') while True: line = fp.readline().strip() if not line: break folder_name = line.strip() unmapped_bam_path = "../neurogene/rnaseq_PD/run_output/" + folder_name + "/unmapped.bam" if not os.path.isfile(unmapped_bam_path): print "Cannot find the bam path: " + unmapped_bam_path sys.exit(1) fastq_folder_path = './' + folder_name + '/' if not os.path.exists(fastq_folder_path): os.mkdir(fastq_folder_path) unmapped_fastq_path = fastq_folder_path + folder_name + "unmapped.fastq" shell_command = "bam2fastx -q -A -N -Q -o " + unmapped_fastq_path + " " + unmapped_bam_path os.command(shell_command)
def display_ppm(filename): os.command("display %s" %(filename, ))
#!/data/data/com.termux/files/usr/bin/python3 from os import system as command print("Installing everything needet") command( "pkg install python; pkg install python3; pip install termcolor; pkg install termux-api; pkg install curl;cp TermFun /data/data/com.termux/files/usr/bin && cp TermFunListener /data/data/com.termux/files/usr/bin ;cd /sdcard; curl https://f-droid.org/repo/com.termux.api_47.apk -O; pm install com.termux.api_47.apk; pkg install nmap;" ) command( "chmod +x /data/data/com.termux/files/usr/bin/TermFun; chmod +x /data/data/com.termux/files/usr/bin/TermFunListener" ) command("clear") print("The Termux-API apk was placed on your /sdcard install it please.") print("You can also download the Termux-API from the appstore if you want.") print("But Remember Termux cant run correctly without the termux-api apk.") from termcolor import colored as c print(c("You can now run TermFun by typing TermFun in the Terminal"))
print("----- ----- ----- ----- -----") print(f"| {diceList[0]} | | {diceList[1]} | | {diceList[2]} | | {diceList[3]} | | {diceList[4]} | ") print("----- ----- ----- ----- -----") game = True p1Used = [] p2Used = [] p1TotalScore = 0 p2TotalScore = 0 while game: # Player 1 command('clear') print("Player 1 -", p1TotalScore, "\nPlayer 2 -", p2TotalScore, "\nTurns remaining -", 13-len(p1Used), "\n") input("Player 1, press enter to roll the dice: ") diceList = dice() print_dice(diceList) rollsLeft = 2 while rollsLeft > 0: again = input("Roll again (Y/N)? ") if "Y" in str.upper(str(again)): rollsLeft -= 1 diceList = dice()
def open_url(self, url=None): url = url if url else self.url logger.debug("Opening url: %s" % url) command(self.config["cmd_open_url"] % url)