def main(): USB1208LS=MCCDAQ() USB1208LS.FlashLED(0) USB1208LS.GetBoardName(0) i=USB1208LS.getStatus() print USB1208LS.GetErrMsg(i) print USB1208LS.GetConfig(BOARDINFO,0,0,BISERIALNUM) WConio.clrscr() print "Demonstration of cbAOut() - chan0 pin13 - D/A 10bits" ExitFlag = False while (ExitFlag==False): WConio.gotoxy (0, 3) EngUnits = float ( raw_input('Enter a voltage between -5.0 and +5.0: ') ) DataValue=USB1208LS.FromEngUnits(0, BIP5VOLTS, EngUnits) USB1208LS.AOut (0, 0 , BIP5VOLTS, DataValue) print "%.2f volts has been sent to D/A 0.\n"\ "Press Q to quit , any other key to continue: " %EngUnits (ch,)=WConio.getch() if (ch=='q' or ch=='Q'): ExitFlag=True
def main(): WConio.clrscr() print "Demonstration of GetConfig().\n"\ "List of Installed Boards:\n" # Get the number of boards installed in system NumBoards=USB1208LS.GetConfig (GLOBALINFO, 0, 0, GINUMBOARDS) USB1208LS.SetConfig (BOARDINFO, 0, 0, BINUMADCHANS,8) # single ended #USB1208LS.SetConfig (BOARDINFO, 0, 0, BINUMADCHANS,4) # diff ended for i in range(NumBoards): # Get board type of each board BoardType=USB1208LS.GetConfig (BOARDINFO, i, 0, BIBOARDTYPE) # If a board is installed if (BoardType > 0): # Get the board's name BoardNameStr=USB1208LS.GetBoardName (i) print " Board #%d = %s" %(i,BoardNameStr) # Get the board's base address BaseAdr=USB1208LS.GetConfig (BOARDINFO, i, 0, BIBASEADR) print " Base Address = 0x%x" %BaseAdr PrintADInfo (i) PrintDAInfo (i) PrintDigInfo (i) PrintCtrInfo (i) PrintExpInfo (i) raw_input("\npause")
def robust_write(self, command = ''): """Write to the RCS with robust exception handling.""" try: self.write(command) except DisconnectError: global servo_mode servo_mode = IDLE # Blank screen due to device disconnect. WConio.textattr(0xb0) WConio.clrscr() WConio.gotoxy(10, 10) WConio.cputs('USB-RCS has been disconnected during write. ' 'Trying to reconnect. ') self.robust_reconnect() usb = rcs.robust_read('U') firmware_version = usb[2] display_once(firmware_version) except Exception, e: WConio.textattr(0xc0) WConio.clrscr() WConio.gotoxy(0, 10) print "Unexpected exception in robust_write: ", type(e) print print e print raw_input("Press enter to exit ->") exit()
def display_once(firmware_version): """Display static information, call once.""" WConio.textattr(0x70) WConio.clrscr() # Display Firmware Version or Firmware Status. WConio.gotoxy(2, 0) if firmware_version < 1.0: WConio.textattr(0xc0) WConio.cputs(' Firmware Unreliable! ') else: WConio.textattr(0xa0) WConio.cputs(' Firmware Version %2.2f '%firmware_version) # Display servo static labels. WConio.gotoxy(0, 2) WConio.textattr(0x70) WConio.cputs(' S# Acc #Q Cyc Speed Pos mS\n') for i in range(1, 17): WConio.cputs(' %2i\n'%i) # Display analog channel labels. WConio.gotoxy(0, 20) WConio.textattr(0x70) WConio.cputs (' C# Voltage C# Voltage') for i in range(1, 5): WConio.cputs('\n %i %i'% (i, i+4))
def main(): USB1208LS=MCCDAQ() WConio.clrscr() print "Demonstration of cbDIn()\n"\ "Press any key to quit.\n\n"\ "You may change a bit by applying a TTL high or\n"\ "a TTL low to the corresponding pin# on port A.\n" print "The first 7 bits are: pin32 to pin 39\n"\ "0 1 2 3 4 5 6 7\n " (a,a,a,a,a,a,a,a,a,a,row)=WConio.gettextinfo() USB1208LS.DConfigPort (0, FIRSTPORTB, DIGITALIN) while (WConio.kbhit()==False): DataValue=USB1208LS.DIn(0, FIRSTPORTB) WConio.gotoxy(0,row) print "Port Value: %d " %DataValue # parse DataValue into bit values to indicate on/off status */ for I in range (8): if (DataValue & 2**I): BitValue = 1 else: BitValue = 0 print "%d " %BitValue,
def makeArray(size): WConio.clrscr() gameArray=None gameArray=[[chr(250) for y in range(size[1])] for x in range(size[0])] printGrid(gameArray) printBoard(gameArray) return gameArray
def play(self): repeats = 0 lastclick = None while True: #self.find_diamond() items = self.find_one() if items: self.click(items) #print "clicked", items if items == lastclick: repeats += 1 else: lastclick = items #time.sleep(0.1) #os.system('cls') WConio.clrscr() print '\n'.join([' '.join(x) for x in self.get_matrix()]) # else: # #time.sleep(0.5) # self.click(self.buffer[0]) # print "Clicked from buffer", self.buffer[0] # self.buffer.remove(self.buffer[0]) # time.sleep(0.1) # #print "Waiting..." # # fails += 1 if repeats >= 5: return "Finished!"
def ClearScreen(): # Clears the screen and moves the cursor to the upper left corner if gOS == "Windows": WConio.clrscr() elif gOS == "Linux": gConsole.erase() gConsole.move(0, 0)
def printAsciiArt(): # Imprime el arte ascii de la introducción WConio.clrscr() # limpio la pantalla previa try: (width, height) = getTerminalSize() # se obtiene el largo de la consola para dejarlo centrado asciiart = open("data/documents/ascii.txt", "r") for i in asciiart: print " "*(int((width - 26) / 2) - 10), i.rstrip() asciiart.close() except: pass
def clrscr(): """ Limpia la pantalla :return: void """ # noinspection PyBroadException try: WConio.clrscr() except: pass
def selectBoard(arrows): WConio.clrscr() k=None comment = None size=[5,5] gameArray=makeArray(size) WConio.gotoxy(0,21) print "{0:^79}".format("Hit the spacebar to accept this board.") while k<>" ": k = WConio.getkey() if k in arrows[0]: d=arrows[0].index(k) size[0]=(size[0]+arrows[1][d]*2) size[1]=(size[1]+arrows[2][d]*2) if size[0]>21: size[0]=21 comment = "That's as wide as you can go." elif size[0]<5: size[0]=5 comment = "That's as narrow as you can go." elif size[1]>9: size[1]=9 comment = "That's as tall as you can go." elif size[1]<5: size[1]=5 comment = "That's as short as you can go." else: comment = "" gameArray=makeArray(size) WConio.gotoxy(0,21) print "{0:^79}".format("{} {}".format(size,comment)) if size[0]*size[1]>50: print "{0:^79}".format("This size board will get some random tokens thrown on.") print "{0:^79}".format(" Hit the spacebar to accept this board.") #init pieces gameArray[0][0]=chr(1) gameArray[0][len(gameArray[0])-1]=chr(2) gameArray[len(gameArray)-1][0]=chr(2) gameArray[len(gameArray)-1][len(gameArray[0])-1]=chr(1) if len(gameArray)*len(gameArray[0])>50: c=0 WConio.gotoxy(0,21) while c< len(gameArray)*len(gameArray[0])-40: m=randint(0,len(gameArray)-1) n=randint(0,len(gameArray[0])-1) p=randint(0,len(gameArray)-1) q=randint(0,len(gameArray[0])-1) if gameArray[m][n]==chr(250) and gameArray[p][q]==chr(250) and m<>p: gameArray[m][n]=chr(1) gameArray[p][q]=chr(2) c=c+2 clearLines() return (gameArray)
def clrscr(): """ Limpia la pantalla. :return: void :rtype: None """ if _IMPORTED[0]: try: WConio.clrscr() # @UndefinedVariable except: pass else: if not is_windows(): os.system("clear")
def printAsciiArtServer(): """ Imprime el arte ascii de la introducción del servidor :return: void """ if _wconio: WConio.clrscr() try: # se obtiene el largo de la consola para dejarlo centrado (width, height) = getTerminalSize() asciiart = open("data/doc/other/asciiartserver.txt", "r") for i in asciiart: print " " * (int((width - 26) / 2) - 1), i.rstrip() asciiart.close() except: pass
def __draw(self): WConio.clrscr() # make walls for i in xrange(len(self.__walls)): self.__walls[i].draw() self.__worldInfo.player.draw((1,1)) for z in self.__worldInfo.zombies: z.draw((1,1)) for h in self.__worldInfo.healthPacks: h.draw((1,1)) self.__drawHUD() WConio.gotoxy(0,self.__size[1] + 2)
def printAsciiArtServer(): """ Imprime el arte ascii de la introducción del servidor :return: void """ if _wconio: WConio.clrscr() try: # se obtiene el largo de la consola para dejarlo centrado (width, height) = getTerminalSize() # @UnusedVariable asciiart = open("data/doc/other/asciiartserver.txt", "r") for i in asciiart: print " " * (int((width - 26) / 2) - 1), i.rstrip() asciiart.close() except: pass
def main(): USB1208LS=MCCDAQ() WConio.clrscr() print "Demonstration of voltage conversions.\n"\ "Press any key to quit.\n" # get the A/D channel to sample Chan = int ( raw_input('Enter the channel to display: ') ) print "\n\nNote: Please make certain that the board you are using supports\n"\ " the gain you are choosing and if it is not a programmable\n"\ " gain that the switches on the board are set correctly.\n\n" BoardNum = 0 Gain = BIPPT625VOLTS # collect the sample with cbAIn() */ while (Gain > 0): # select gain */ WConio.gotoxy(0,10) while 1: Gain = int ( raw_input ("Please select one of the following ranges(1 to 4):\n"\ " 10 VOLTS UNIPOLAR --> 1\n"\ " 10 VOLTS BIPOLAR ---> 2\n"\ " 5 VOLTS UNIPOLAR --> 3\n"\ " 5 VOLTS BIPOLAR ---> 4\n"\ " Quit ---> 0\n\n"\ " Your Choice ---> ")) if ( (Gain >= 0) and (Gain <= 4) ): break # Set Gain, MaxVal, and MinVal */ if (Gain==0): sys.exit(1) elif (Gain==1): Gain = UNI10VOLTS elif (Gain==2): Gain = BIP10VOLTS elif (Gain==3): Gain = UNI5VOLTS elif (Gain==4): Gain = BIP5VOLTS if (Gain >= 0): DataValue=USB1208LS.AIn (BoardNum, Chan, Gain) EngUnits =USB1208LS.ToEngUnits(BoardNum, Gain, DataValue) print "\nThe voltage on channel %d is %.2f " %(Chan, EngUnits) Gain = BIPPT625VOLTS
def main(): USB1208LS=MCCDAQ() WConio.clrscr() print "Demonstration of DOut()\n"\ "Press any key to quit." USB1208LS.DConfigPort (0, FIRSTPORTA, DIGITALOUT) # get a user value to write to the port DataValue=256 while ((DataValue < 0) or (DataValue > 255)): DataValue = int ( raw_input('Enter a value to send to FIRSTPORTA (0-255): ') ) USB1208LS.DOut(0, FIRSTPORTA, DataValue) print "\nThe value %u was written to FIRSTPORTA. \n" \ "see pin21-PA0 pin28-PA7" %DataValue raw_input('\nPause')
def summaryTable(builds): WConio.clrscr() WConio.textcolor(WConio.WHITE) print "PROJECT NAME".ljust(90) + "STATUS".ljust(10) print "=" * 100 good = bad = 0 for item in builds: if item['status'] == 'ok': WConio.textcolor(WConio.LIGHTGREEN) good += 1 else: WConio.textcolor(WConio.RED) bad += 1 print item['project'].ljust(90) + item['status'].ljust(4) WConio.textcolor(WConio.WHITE) print "=" * 100 WConio.textcolor(WConio.GREEN) print "GOOD :".rjust(90) + str(good).rjust(10, '.') WConio.textcolor(WConio.RED) print "BAD :".rjust(90) + str(bad).rjust(10, '.')
def main(): USB1208LS=MCCDAQ() WConio.clrscr() print "Demonstration of AIn()\n"\ "Press any key to quit.\n" # get the A/D channel to sample Chan = int ( raw_input('Enter the channel to display: ') ) print "\nThe raw data value on Channel %u is: " %Chan, (a,a,a,a,a,a,a,a,a,col,row)=WConio.gettextinfo() print "\nThe voltage on Channel %u is: " %Chan, # collect the sample from the channel until a key is pressed while (WConio.kbhit()==False): DataValue=USB1208LS.AIn (0, Chan, BIP5VOLTS) EngUnits =USB1208LS.ToEngUnits (0, BIP5VOLTS, DataValue) WConio.gotoxy(col,row) print "%5d" %DataValue, WConio.gotoxy(col,row+1) print "%.2fV" %EngUnits,
def robust_read(self, command = None, count = 1): """Read from the RCS with robust exception handling.""" global servo_mode while True: try: return self.read(command, count) except DisconnectError: servo_mode = IDLE # Blank screen due to device disconnect. WConio.textattr(0xb0) WConio.clrscr() WConio.gotoxy(10, 10) WConio.cputs('USB-RCS has been disconnected during read. ' 'Trying to reconnect. ') self.robust_reconnect() usb = rcs.robust_read('U') firmware_version = usb[2] display_once(firmware_version) except ReadTimeoutError, e: servo_mode = IDLE # Blank screen due to device disconnect. WConio.textattr(0xc0) WConio.clrscr() WConio.gotoxy(10, 10) WConio.cputs('USB-RCS read timeout: ' 'Communications is not responding as expected.') WConio.gotoxy(10, 12) raw_input("Unplug the USB-RCS.") while self.status() != DISCONNECTED: time.sleep(0.500) WConio.gotoxy(10, 12) WConio.cputs("Now, plug-in the USB-RCS.") self.robust_reconnect() usb = rcs.robust_read('U') firmware_version = usb[2] display_once(firmware_version) except Exception, e: WConio.textattr(0xc0) WConio.clrscr() WConio.gotoxy(0, 10) print "Unexpected exception in robust_read: ", type(e) print e raw_input("Press enter to exit ->") exit()
def exec_cmd(argv): console.clrscr() return -1
import sys import socket import string import os import io import time import random import urllib2 import re import WConio import threading import sys #(2,24) old_setting = WConio.gettextinfo()[4] & 0x00FF WConio.clrscr() WConio.settitle("PyBot Control Center") WConio.gotoxy(2,2) WConio.cputs("Welcome to the PyBot Control Center\n\r") f = open('C:\\PyBot\\connections.txt', 'w') j = open('C:\\PyBot\\update.txt', 'w') p = open('C:\\PyBot\\cmd.txt', 'w') f.write('') j.write('') p.write('') f.close() j.close() class GetConnections ( threading.Thread ): def run ( self ): WConio.textcolor(WConio.LIGHTRED)
# backspace elif v_key == '\b': if len(v_cmd_buf) > 0: v_cmd_buf.pop() sys.stdout.write('\b \b') # CTRL+Z/U, clear command buffer elif (v_key == '\x15') or (v_key == '\x1A'): while len(v_cmd_buf) > 0: v_cmd_buf.pop() sys.stdout.write('\b \b') # CTRL+L, clear screen, but keep command elif v_key == '\x0C': console.clrscr() sys.stdout.write(config.cli_prompt + '>' + ''.join(v_cmd_buf).strip()) # TAB, to auto-complete the input command elif v_key == '\x09': v_cmd = ''.join(v_cmd_buf).strip() v_tmp_list = [] for v_path in config.cmd_search_path: for v_cmd_file in os.listdir(os.getcwd() + v_path): if (v_cmd_file[:len(config.cmd_file_prefix)] == config.cmd_file_prefix) \ and (v_cmd_file[-3:] == '.py') \ and v_cmd in v_cmd_file[len(config.cmd_file_prefix):-3]: v_tmp_list.append(v_cmd_file[len(config.cmd_file_prefix):-3]) if len(v_tmp_list) == 1: for i in range(len(v_cmd_buf)):
def PrintStockInfoTitleWithColor(): import WConio WConio.settitle("My Stock Info") WConio.clrscr() ColorConsole.PrintStockInfoTitle()
def clr(self): #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - wc.clrscr()
def clear(): W.clrscr() game.on('clear')
def clrscr() : """Efface la console Windows""" if sys.flags.interactive == 0 : # en WConio WConio.clrscr()
def lookPrimaryArguments(data=None): """ Se buscan los argumentos primarios <--help, --version, ...> :param data: Datos extra :return: void """ (width, height) = getTerminalSize() if len(sys.argv) >= 2: if sys.argv[1] == "--benchmark": if _wconio: WConio.clrscr() print "Benchmark Hero of Antair" print "Python " + sys.version + "\n" if len(sys.argv) == 3: if str(sys.argv[2]).isdigit(): repeticiones = int(sys.argv[2]) if repeticiones > 1: print "Realizando prueba benchmark a {0} repeticiones ...".format( str(repeticiones)) ms = benchmark(True, True, repeticiones) print "\nTiempo promedio de ejecucion: " + str( ms) + "ms" print "Benchmark guardado en log/benchmark" elif repeticiones == 1: print "Realizando prueba unica benchmark ...".format( str(repeticiones)) ms = benchmark(True, True, repeticiones) print "\nTiempo promedio de ejecucion: " + str( ms) + "ms" print "Benchmark guardado en log/benchmark" else: st_error( "Error al ejecutar prueba benchmark, el numero de repeticiones debe ser mayor o igual a 1", True) else: print "Realizando prueba benchmark a 5 repeticiones ..." ms = benchmark(True, True) print "\nTiempo promedio de ejecucion: " + str(ms) + "ms" print "Benchmark guardado en log/benchmark" exit() elif sys.argv[1] == "--changelog" or sys.argv[1] == "-ch": try: changelog = open("CHANGELOG", "r") print "" for line in changelog: if line != "": print delAcentos(str(line)).rstrip() changelog.close() except: st_error( "Error al ejecutar el comando --changelog, Archivo no encontrado", True) exit() elif sys.argv[1] == "--dwi": try: if _wconio: WConio.clrscr() archivo = open("data/doc/other/dwi.txt", "r") print "" for line in archivo: if line != "": print str(line).rstrip() archivo.close() except: print "" exit() elif sys.argv[1] == "--fcfm" or sys.argv[1] == "--850": try: if _wconio: WConio.clrscr() asciiart = open("data/doc/other/850.txt", "r") counter = 0 for i in asciiart: print " " * (int((width - 26) / 2) - 3), i.rstrip() counter += 1 if counter > 15 and i.strip() != "": time.sleep(1) asciiart.close() except: st_error( "Error al ejecutar el comando --changelog, Archivo no encontrado" ) exit() elif sys.argv[1] == "--help" or sys.argv[1] == "-h": try: helpfile = open( _actualpath + "data/doc/documentation/arguments.txt", "r") for h in helpfile: if h != "": print h.replace("</>", color.END).replace( "<b>", color.BOLD).rstrip() helpfile.close() except: st_error( "Error al ejecutar el comando --help, Archivo no encontrado" ) exit() elif sys.argv[1] == "--linecounter": if _wconio: WConio.clrscr() try: total = 0 listedfiles = [] totallines = [] for file in os.listdir(_actualpath + "/lib/"): # @ReservedAssignment if ".py" in file and ".pyc" not in file: listedfiles.append(file) archv = open(_actualpath + "/lib/" + file, "r") for l in archv: total += 1 archv.close() totallines.append(total) total = 0 for file in os.listdir(_actualpath + "/bin/"): # @ReservedAssignment if ".py" in file and ".pyc" not in file: listedfiles.append(file) archv = open(_actualpath + "/bin/" + file, "r") for l in archv: total += 1 archv.close() totallines.append(total) total = 0 brief = open(_actualpath + "linec", "w") brief.write("Archivos analizados:\n") for i in range(len(totallines)): brief.write("\t" + str(listedfiles[i]) + " => " + str(totallines[i]) + " lineas\n") brief.write("\nTotal: " + str(sum(totallines)) + " lineas\n") brief.close() st_info("Archivo generado correctamente") except: st_error("Error al ejecutar el comando linecounter") exit() elif sys.argv[1] == "--sierpinski": if _wconio: WConio.clrscr() if len(sys.argv) == 3: if sys.argv[2] == "/help": helpfile = open( _actualpath + "data/doc/other/sierpinski.txt", "r") print "" for h in helpfile: if h != "": print h.rstrip() helpfile.close() else: st_error("Argumentos incompletos, consulte --help") exit() elif len(sys.argv) == 4: negative = False reverse = False try: s = sys.argv[2][0:1] except: s = "H" try: r = int(sys.argv[3]) if r > 0: pass else: r = 1 except: r = 1 elif len(sys.argv) == 5: param = sys.argv[2] if param == "/negative": negative = True else: negative = False if param == "/reverse": reverse = True else: reverse = False try: s = sys.argv[3][0:1] except: s = "H" try: r = int(sys.argv[4]) if r > 0: pass else: r = 1 except: r = 1 else: st_error("Argumentos desconocidos, consulte /sierpinski /help", True) for x in range(height * r): i = "" for y in range(width): if negative: if not x & y: i += s else: i += " " else: if x & y: i += s else: i += " " if reverse: print i[::-1], else: print i, exit() elif sys.argv[1] == "--version" or sys.argv[1] == "-v": print data exit() elif sys.argv[1] == "--config" or sys.argv[1] == "-c": if len(sys.argv) > 3: name = sys.argv[2] value = sys.argv[3] if name != "": if value != "": setConfig(name, value) addLineConfigFile(CONFIG_HOA_FILE, name) else: st_error("Valor de configuración inválido", True) else: st_error("Nombre de configuración inválido", True) else: if len(sys.argv) == 3: if sys.argv[2] == "--view": avconf = loadConfigFile(CONFIG_HOA_FILE) files = os.listdir(CONFIG_FOLDER) maxsep = 0 for conf_file in files: maxsep = max(maxsep, len(conf_file)) maxsep += 5 for conf_file in files: if conf_file in avconf: print conf_file.ljust(maxsep), getConfigValue( conf_file, True, True) else: st_error("config: opcion desconocida", True) else: st_error("config: argumentos insuficientes", True) exit() else: pass
import sys import socket import string import os import io import time import random import urllib2 import re import WConio import threading import sys #(2,24) old_setting = WConio.gettextinfo()[4] & 0x00FF WConio.clrscr() WConio.settitle("PyBot Control Center") WConio.gotoxy(2, 2) WConio.cputs("Welcome to the PyBot Control Center\n\r") f = open('C:\\PyBot\\connections.txt', 'w') j = open('C:\\PyBot\\update.txt', 'w') p = open('C:\\PyBot\\cmd.txt', 'w') f.write('') j.write('') p.write('') f.close() j.close() class GetConnections(threading.Thread): def run(self):
def initialize(): #------------------------------------------------------------------------------- wc.clrscr() return WindowBase()
def lookPrimaryArguments(data=None): """ Se buscan los argumentos primarios <--help, --version, ...> :param data: Datos extra :return: void """ (width, height) = getTerminalSize() if len(sys.argv) >= 2: if sys.argv[1] == "--benchmark": if _wconio: WConio.clrscr() print "Benchmark Hero of Antair" print "Python " + sys.version + "\n" if len(sys.argv) == 3: if str(sys.argv[2]).isdigit(): repeticiones = int(sys.argv[2]) if repeticiones > 1: print "Realizando prueba benchmark a {0} repeticiones ...".format( str(repeticiones)) ms = benchmark(True, True, repeticiones) print "\nTiempo promedio de ejecucion: " + str( ms) + "ms" print "Benchmark guardado en log/benchmark" elif repeticiones == 1: print "Realizando prueba unica benchmark ...".format( str(repeticiones)) ms = benchmark(True, True, repeticiones) print "\nTiempo promedio de ejecucion: " + str( ms) + "ms" print "Benchmark guardado en log/benchmark" else: st_error( "Error al ejecutar prueba benchmark, el numero de repeticiones debe ser mayor o igual a 1", True) else: print "Realizando prueba benchmark a 5 repeticiones ..." ms = benchmark(True, True) print "\nTiempo promedio de ejecucion: " + str(ms) + "ms" print "Benchmark guardado en log/benchmark" exit() elif sys.argv[1] == "--changelog" or sys.argv[1] == "-ch": try: changelog = open("CHANGELOG", "r") print "" for line in changelog: if line != "": print delAcentos(str(line)).rstrip() changelog.close() except: st_error( "Error al ejecutar el comando --changelog, Archivo no encontrado", True) exit() elif sys.argv[1] == "--dwi": try: if _wconio: WConio.clrscr() archivo = open("data/doc/other/dwi.txt", "r") print "" for line in archivo: if line != "": print str(line).rstrip() archivo.close() except: print "" exit() elif sys.argv[1] == "--fcfm" or sys.argv[1] == "--850": try: if _wconio: WConio.clrscr() asciiart = open("data/doc/other/850.txt", "r") counter = 0 for i in asciiart: print " " * (int((width - 26) / 2) - 3), i.rstrip() counter += 1 if counter > 15 and i.strip() != "": time.sleep(1) asciiart.close() except: st_error( "Error al ejecutar el comando --changelog, Archivo no encontrado") exit() elif sys.argv[1] == "--help" or sys.argv[1] == "-h": try: helpfile = open( _actualpath + "data/doc/documentation/arguments.txt", "r") for h in helpfile: if h != "": print h.replace("</>", color.END).replace("<b>", color.BOLD).rstrip() helpfile.close() except: st_error( "Error al ejecutar el comando --help, Archivo no encontrado") exit() elif sys.argv[1] == "--linecounter": if _wconio: WConio.clrscr() try: total = 0 listedfiles = [] totallines = [] for file in os.listdir( _actualpath + "/lib/"): # @ReservedAssignment if ".py" in file and ".pyc" not in file: listedfiles.append(file) archv = open(_actualpath + "/lib/" + file, "r") for l in archv: # @UnusedVariable total += 1 archv.close() totallines.append(total) total = 0 for file in os.listdir( _actualpath + "/bin/"): # @ReservedAssignment if ".py" in file and ".pyc" not in file: listedfiles.append(file) archv = open(_actualpath + "/bin/" + file, "r") for l in archv: # @UnusedVariable total += 1 archv.close() totallines.append(total) total = 0 brief = open(_actualpath + "linec", "w") brief.write("Archivos analizados:\n") for i in range(len(totallines)): brief.write( "\t" + str(listedfiles[i]) + " => " + str( totallines[i]) + " lineas\n") brief.write("\nTotal: " + str(sum(totallines)) + " lineas\n") brief.close() st_info("Archivo generado correctamente") except: st_error("Error al ejecutar el comando linecounter") exit() elif sys.argv[1] == "--sierpinski": if _wconio: WConio.clrscr() if len(sys.argv) == 3: if sys.argv[2] == "/help": helpfile = open( _actualpath + "data/doc/other/sierpinski.txt", "r") print "" for h in helpfile: if h != "": print h.rstrip() helpfile.close() else: st_error("Argumentos incompletos, consulte --help") exit() elif len(sys.argv) == 4: negative = False reverse = False try: s = sys.argv[2][0:1] except: s = "H" try: r = int(sys.argv[3]) if r > 0: pass else: r = 1 except: r = 1 elif len(sys.argv) == 5: param = sys.argv[2] if param == "/negative": negative = True else: negative = False if param == "/reverse": reverse = True else: reverse = False try: s = sys.argv[3][0:1] except: s = "H" try: r = int(sys.argv[4]) if r > 0: pass else: r = 1 except: r = 1 else: st_error( "Argumentos desconocidos, consulte /sierpinski /help", True) for x in range(height * r): i = "" for y in range(width): if negative: if not x & y: i += s else: i += " " else: if x & y: i += s else: i += " " if reverse: print i[::-1], else: print i, exit() elif sys.argv[1] == "--version" or sys.argv[1] == "-v": print data exit() elif sys.argv[1] == "--config" or sys.argv[1] == "-c": if len(sys.argv) > 3: name = sys.argv[2] value = sys.argv[3] if name != "": if value != "": setConfig(name, value) addLineConfigFile(CONFIG_HOA_FILE, name) else: st_error("Valor de configuración inválido", True) else: st_error("Nombre de configuración inválido", True) else: if len(sys.argv) == 3: if sys.argv[2] == "--view": avconf = loadConfigFile(CONFIG_HOA_FILE) files = os.listdir(CONFIG_FOLDER) maxsep = 0 for conf_file in files: maxsep = max(maxsep, len(conf_file)) maxsep += 5 for conf_file in files: if conf_file in avconf: print conf_file.ljust(maxsep), getConfigValue( conf_file, True, True) else: st_error("config: opcion desconocida", True) else: st_error("config: argumentos insuficientes", True) exit() else: pass
# backspace elif v_key == '\b': if len(v_cmd_buf) > 0: v_cmd_buf.pop() sys.stdout.write('\b \b') # CTRL+Z/U, clear command buffer elif (v_key == '\x15') or (v_key == '\x1A'): while len(v_cmd_buf) > 0: v_cmd_buf.pop() sys.stdout.write('\b \b') # CTRL+L, clear screen, but keep command elif v_key == '\x0C': console.clrscr() sys.stdout.write(config.cli_prompt + '>' + ''.join(v_cmd_buf).strip()) # TAB, to auto-complete the input command elif v_key == '\x09': v_cmd = ''.join(v_cmd_buf).strip() v_tmp_list = [] for v_path in config.cmd_search_path: for v_cmd_file in os.listdir(os.getcwd() + v_path): if (v_cmd_file[:len(config.cmd_file_prefix)] == config.cmd_file_prefix) \ and (v_cmd_file[-3:] == '.py') \ and v_cmd in v_cmd_file[len(config.cmd_file_prefix):-3]: v_tmp_list.append( v_cmd_file[len(config.cmd_file_prefix):-3])