def _execute(self, options, args): if len(args) < 1: raise CommandError("Not enough arguments") pattern = options.pattern if pattern is None: pattern = "<artist~album~tracknumber~title>" self.log("Using pattern: %r" % pattern) try: pattern = Pattern(pattern) except PatternError: raise CommandError("Invalid pattern: %r" % pattern) paths = args error = False for path in paths: try: util.print_(pattern % self.load_song(path)) except CommandError: error = True if error: raise CommandError("One or more files failed to load.")
def _print_pipeline(self): """Print debug information for the active pipeline to stdout (elements, formats, ...) """ if self.bin: # self.bin is just a wrapper, so get the real one for line in bin_debug([self.bin.bin]): print_(line) else: print_e("No active pipeline.")
def __run(self, command): sys.stdout, self.stdout = self.stdout, sys.stdout sys.stderr, self.stderr = self.stderr, sys.stderr try: try: r = eval(command, self.namespace, self.namespace) if r is not None: print_(repr(r)) except SyntaxError: exec(command, self.namespace) except: if hasattr(sys, 'last_type') and sys.last_type == SystemExit: self.destroy() else: traceback.print_exc() sys.stdout, self.stdout = self.stdout, sys.stdout sys.stderr, self.stderr = self.stderr, sys.stderr
def log(self, text): """Print output if --verbose was passed""" if self.verbose: return print_(text, file=sys.stderr)