def doLater(self, args): if not args: self.stderr.write('Please give paths to look up.\n') defer.returnValue(3) return for path in args: path = path.decode('utf-8') if not os.path.exists(path): self.stderr.write('Could not find %s\n' % path.encode('utf-8')) continue self.stdout.write('%s\n' % path) try: ret = yield self.parentCommand.database.getTracksByHostPath(common.hostname(), path) except error.Error, e: if e.status == 404: self.stderr.write('Database or view does not exist.\n') self.reactor.stop() defer.returnValue(3) return ret = list(ret) if len(ret) == 0: self.stdout.write('Not in database.\n') else: self.stdout.write('In database in %d tracks.\n' % len(ret))
def addOptions(self): self.parser.add_option('-H', '--hostname', action="store", dest="hostname", default=common.hostname(), help="override hostname (%default)")