Esempio n. 1
0
 def do_search(self, line):
     try:
         username, category, query = parse_search_arguments(self.args)
     except Exception as e:
         sys.stdout.write("%s\n" % e)
     else:
         sys.stdout.write("Searching " + get_search_interp(username, category, query) + "\n")
         items = get_search_results(username, category, query)
         fmt = lambda x: u"{:<12} {}".format(*x)
         sys.stdout.write(u"\n".join(map(fmt, enumerate(items))) + "\n")
         self._search_cache = items
     return
Esempio n. 2
0
 def do_search(self, line):
     try:
         username, category, query = parse_search_arguments(self.args)
     except Exception as e:
         sys.stdout.write("%s\n" % e)
     else:
         sys.stdout.write("Searching " +
                          get_search_interp(username, category, query) +
                          "\n")
         items = get_search_results(username, category, query)
         fmt = lambda x: u"{:<12} {}".format(*x)
         sys.stdout.write(u"\n".join(map(fmt, enumerate(items))) + "\n")
         self._search_cache = items
     return
Esempio n. 3
0
def cli(cmd=None, args=None):
    """Main entry point of the script"""
    if cmd == "headless":
        with Player(no_input=True) as player:
            player.run()
            return

    try:
        username, category, query = parse_search_arguments(args)
    except Exception as e:
        sys.stdout.write("%s\n" % e)
        return

    if cmd in ["s", "search"] or not cmd:
        cli_search(username, category, query)
    elif cmd in ["p", "play"]:
        cli_play(username, category, query)
    else:
        sys.stdout.write("Unrecognized command %s\n" % cmd)

    sys.stdout.write("\n")
Esempio n. 4
0
def cli(cmd=None, args=None):
    """Main entry point of the script"""
    if cmd == 'headless':
        with Player(no_input=True) as player:
            player.run()
            return

    try:
        username, category, query = parse_search_arguments(args)
    except Exception as e:
        sys.stdout.write("%s\n" % e)
        return

    if cmd in ['s', 'search'] or not cmd:
        cli_search(username, category, query)
    elif cmd in ['p', 'play']:
        cli_play(username, category, query)
    else:
        sys.stdout.write("Unrecognized command %s\n" % cmd)

    sys.stdout.write("\n")