def printList(listItems, title="", showSelector=False, showByStep=20, showUrl=False): if title: separator("=", title) total = len(listItems) printLine("Total found: %d" % total) for key, item in enumerate(listItems): key += 1 printLine("%s : %s%s%s" % ( str(key).rjust(3, " "), printDate(item.created).ljust(12, " ") if hasattr(item, 'created') else '', item.title if hasattr(item, 'title') else item.name, " " + (">>> " + config.NOTE_URL % item.guid) if showUrl else '',)) if key % showByStep == 0 and key < total: printLine("-- More --", "\r") tools.getch() printLine(" " * 12, "\r") if showSelector: printLine(" 0 : -Cancel-") try: while True: num = rawInput(": ") if tools.checkIsInt(num) and 1 <= int(num) <= total: return listItems[int(num) - 1] if num == '0': exit(1) failureMessage('Incorrect number "%s", ' 'please try again:\n' % num) except (KeyboardInterrupt, SystemExit): tools.exit()
def printList( listItems, title="", showSelector=False, showByStep=0, showUrl=False, showTags=False, showNotebook=False, showGUID=False, ): if title: separator("=", title) total = len(listItems) printLine("Found %d item%s" % (total, ("s" if total != 1 else ""))) for key, item in enumerate(listItems): key += 1 printLine("%s : %s%s%s%s%s%s" % ( item.guid if showGUID and hasattr(item, "guid") else str(key).rjust(3, " "), printDate(item.created).ljust(11, " ") if hasattr(item, "created") else "", printDate(item.updated).ljust(11, " ") if hasattr(item, "updated") else "", item.notebookName.ljust(18, " ") if showNotebook and hasattr(item, "notebookName") else "", item.title if hasattr(item, "title") else item.name if hasattr(item, "name") else item.shareName, "".join(map(lambda s: " #" + s, item.tagGuids)) if showTags and hasattr(item, "tagGuids") and item.tagGuids else "", " " + (">>> " + config.NOTE_WEBCLIENT_URL % item.guid) if showUrl else "", )) if showByStep != 0 and key % showByStep == 0 and key < total: printLine("-- More --", "\r") tools.getch() printLine(" " * 12, "\r") if showSelector: printLine(" 0 : -Cancel-") try: while True: num = rawInput(": ") if tools.checkIsInt(num) and 1 <= int(num) <= total: return listItems[int(num) - 1] if num == "0" or num == "q": exit(1) failureMessage('Incorrect number "%s", ' "please try again:\n" % num) except (KeyboardInterrupt, SystemExit), e: if e.message: tools.exit(e.message) else: tools.exit
def Input_Thread(): global finished, controll, lock try: while not finished: input = getch() print ">" + input # print("Deine Eingabe-> %s" % ord(input)) if input == "q" or ord(input) == 3: print("quit") finished = True lock.acquire() if ord(input) == 13: controll.acceleration = 0 print "Rest to Zero" if input == 'w': controll.incAccel(0.05) print "Accel: ", controll.acceleration if input == 's': controll.incAccel(-0.05) print "Accel: ", controll.acceleration if input == 'a': controll.steering += 0.5 print "Steering: ", controll.steering if input == 'd': controll.steering -= 0.5 print "Steering: ", controll.steering if input == 'c': controll.enable = not controll.enable print "Controlled: ", controll.enable lock.release() except (KeyboardInterrupt, SystemExit): finished = True
def SearchResult(result): """Печать результатов поиска""" request_row = "%(request_title)s : %(request)s \n" result_total = "%(find_total)s : %(total)d \n" result_row = "%(key)s: %(title)s \n" total = len(result) sys.stdout.write(result_total % {"find_total": LNG["find_total"], "total": total}) for key, item in result.iteritems(): sys.stdout.write(result_row % {"key": str(key).rjust(3, " "), "title": item["title"]}) if key % 2 == 0 and key < total: sys.stdout.write("-- More -- \r") getch() sys.stdout.write(" " * 10 + "\r") sys.stdout.flush()
def printList(listItems, title="", showSelector=False, showByStep=20, showUrl=False): if title: separator("=", title) total = len(listItems) printLine("Total found: %d" % total) for key, item in enumerate(listItems): key += 1 printLine("%s : %s%s%s" % ( str(key).rjust(3, " "), printDate(item.created).ljust(18, " ") if hasattr(item, 'created') else '', item.title if hasattr(item, 'title') else item.name, " " + (">>> " + config.NOTE_URL % item.guid) if showUrl else '', )) if key % showByStep == 0 and key < total: printLine("-- More --", "\r") tools.getch() printLine(" " * 12, "\r") if showSelector: printLine(" 0 : -Cancel-") try: while True: num = rawInput(": ") if tools.checkIsInt(num) and 1 <= int(num) <= total: return listItems[int(num) - 1] if num == '0': exit(1) failureMessage('Incorrect number "%s", ' 'please try again:\n' % num) except (KeyboardInterrupt, SystemExit), e: if e.message: tools.exit(e.message) else: tools.exit
def printList(listItems, title="", showSelector=False, showByStep=0, showUrl=False, showTags=False, showNotebook=False, showGUID=False): if title: separator("=", title) total = len(listItems) printLine("Found %d item%s" % (total, ('s' if total != 1 else ''))) for key, item in enumerate(listItems): key += 1 printLine("%s : %s%s%s%s%s%s" % ( item.guid if showGUID and hasattr(item, 'guid') else str(key).rjust(3, " "), printDate(item.created).ljust(11, " ") if hasattr(item, 'created') else '', printDate(item.updated).ljust(11, " ") if hasattr(item, 'updated') else '', item.notebookName.ljust(18, " ") if showNotebook and hasattr(item, 'notebookName') else '', item.title if hasattr(item, 'title') else item.name, "".join(map(lambda s: " #" + s, item.tagGuids)) if showTags and hasattr(item, 'tagGuids') and item.tagGuids else '', " " + (">>> " + config.NOTE_WEBCLIENT_URL % item.guid) if showUrl else '',)) if showByStep != 0 and key % showByStep == 0 and key < total: printLine("-- More --", "\r") tools.getch() printLine(" " * 12, "\r") if showSelector: printLine(" 0 : -Cancel-") try: while True: num = rawInput(": ") if tools.checkIsInt(num) and 1 <= int(num) <= total: return listItems[int(num) - 1] if num == '0' or num == 'q': exit(1) failureMessage('Incorrect number "%s", ' 'please try again:\n' % num) except (KeyboardInterrupt, SystemExit), e: if e.message: tools.exit(e.message) else: tools.exit
if settings.START_REDIS: print("Starting Redis") redis.start() print("") print("Menu:") if settings.START_NGINX: print("(r) to reload Nginx config") if settings.START_PHP: print("(p) to restart PHP processes") print("---") print("(STRG+c) or (q) to quit") print("") while True: char = tools.getch() if char == b"\x03" or char == b"q": break elif char == b"r" and settings.START_NGINX: print("Reloading Nginx config... ",end="") nginx.reload_config() print("done") elif char == b"p" and settings.START_PHP: print("Restarting PHP processes... ",end="") php.stop() php.start() print("done") print("Stopping processes...") if settings.START_NGINX: