def connect(interface, con): essid, f, q, enc = con if enc: key = raw_input("This connection demands a key: ") if key: cmd = ["sudo", "/sbin/iwconfig", interface, essid, "key", key] else: cmd = ["sudo", "/sbin/iwconfig", interface, essid] subprocess.command(cmd)
def split_your_file(file_name): my_file = open(file_name, 'r') for line in my_file.readlines(): if re.search(r'^#', line) is None: for word in line.split(): if re.search(r'^/dev', word) is not None: print (command(['blkid', word]))
def menu(): command('clear') print(Fore.CYAN+Style.DIM+" Instalador de fuentes 'FeelMyFonts.py'") print(deco+"\n 1."+enun+"Seleccionar carpeta.") print(deco+" 2."+enun+"Instalar.") print(deco+" 3."+enun+"Salir.") print(defti+"\n Carpeta actual: ", carpetaActual) lista_fuentes=[] if carpetaActual != "/home/"+usuario: print(deco+"\n Fuentes encontradas:\n") for fuentes in listdir(carpetaActual): if fuentes.endswith(".ttf") or fuentes.endswith(".TTF") or fuentes.endswith(".otf"): lista_fuentes.append(fuentes) if len(lista_fuentes) != 0: for index in range(0,len(lista_fuentes)): print(subtitle+" - ",lista_fuentes[index]) else: print(error+" -No se encontro las fuentes.")
print(error+"\n Debe ingresar un numero.") sleep(1) if opcion == 1: carpetaActual=filedialog.askdirectory() if str(carpetaActual) == '()': carpetaActual="/home/"+usuario elif opcion == 2: lista_fuentes=[] for fuentes in listdir(carpetaActual): if fuentes.endswith(".ttf") or fuentes.endswith(".TTF") or fuentes.endswith(".otf"): lista_fuentes.append(fuentes) lista_fuentes_cant=len(lista_fuentes) if lista_fuentes_cant != 0: print(deco+"\n Ingrese el nombre general de la fuente: ",end='') name=input(enun+"") path_fonts="/usr/share/fonts/"+name+"/" run(['sudo','mkdir',path_fonts]) for i in range(0, len(lista_fuentes)): path_file=carpetaActual+"/"+lista_fuentes[i] run(['sudo','cp',path_file,path_fonts]) else: print(error+"\n Sin fuentes no hay paraiso.") sleep(2) else: command('clear') break
def Monitor(thresholds, dbpassword): CPUthresholds = thresholds[0] RAMthresholds = thresholds[1] Diskthresholds = thresholds[2] while True: TotalCPUUsagePercent = CPUUsagePercent() SepCPUUsagePercent = CPUUsageSepPercent() TotalRAMUsagePercent = RAMUsagePercent() TotalDiskUsagePercent = DiskUsagePercent() command(['clear']) count = 1 print("[+]\tSystem Monitor created by mtorres\n") print("[*]\tCPU Info:") print("[**]\t\tCPUs Available: " + str(psutil.cpu_count(logical=True))) for use in SepCPUUsagePercent: print("[**]\t\tUsage Percent CPU " + str(count) + ": " + str(use) + "%") count += 1 print("[**]\t\tUsage Percent (Total): " + str(TotalCPUUsagePercent) + "%") print("\n[*]\tRAM Info:") print("[**]\t\tTotal: " + str(totalRAM())) print("[**]\t\tUsage Percent: " + str(TotalRAMUsagePercent) + "%") print("\n[*]\tDisk Info (MountPoint /):") print("[**]\t\tTotal:" + str(DiskTotal())) print("[**]\t\tUsage Percent:" + str(TotalDiskUsagePercent) + "%") if TotalCPUUsagePercent >= CPUthresholds: createLog("Total CPU", CPUthresholds, TotalCPUUsagePercent) count = 1 for usage in SepCPUUsagePercent: if usage >= CPUthresholds: createLog("CPU " + str(count), CPUthresholds, usage) count += 1 if TotalRAMUsagePercent >= RAMthresholds: createLog("RAM", RAMthresholds, TotalRAMUsagePercent) if TotalDiskUsagePercent >= Diskthresholds: createLog("Disk", Diskthresholds, TotalDiskUsagePercent) # Start monitoring database processlist mydb = mysql.connector.connect(host="localhost", user="******", password=dbpassword) db = mydb.cursor() db.execute("show processlist") result = db.fetchall() dblog = {} count = 0 for output in result: dblog[count] = { "id": output[0], "user": output[1], "host": output[2], "db": output[3], "command": output[4], "time": output[5], "state": output[6], "info": output[7], "progress": output[8], } count += 1 with open('dblog.txt', 'wb') as arq: pickle.dump(dblog, arq) arq.close() db.close()
def main(): command(['clear']) menu()
return getattr(raminfo, name) def main(): command(['clear']) menu() if __name__ == '__main__': try: mode = sys.argv[1].lower() except IndexError: mode = "normal" try: if mode == "silence": dbpassword = "" thresholds = [70, 80, 60] Monitor(thresholds, dbpassword) else: main() except KeyboardInterrupt: command(['clear']) exit() # # while True: # print(psutil.cpu_percent(interval=1)) # print(psutil.virtual_memory())
def compilationLauncher(): command(["xterm", "-e", "./compilation.sh"])
def roscoreLauncher(): command(["xterm", "-e", "roscore"])
def blenderLauncher(): command(["xterm", "-e", "blender", "./dgHand.blend"])
def subsLauncher(): command(["xterm", "-e", "python", "./main_sub.py"])
def calSubsLauncher(): command(["xterm", "-e", "python", "./cal_sub.py"])
def manoLauncher(): command(["xterm", "-e", "../../../devel/lib/tfg/mano"])
def gloveLauncher(): command(["xterm", "-e", "sudo" ,"../../../devel/lib/tfg/dglove"])