From efbe12547b2250cebd08ad25b6145a902a7b0849 Mon Sep 17 00:00:00 2001 From: zyp Date: Tue, 16 May 2006 23:54:31 +0000 Subject: [project @ zyp-20060516235431-615621c154308c58] [project @ 36] Added distutils metadata, MANIFEST.in, README and COPYING. Incremented clientver. Prevented useless connects. --- anidb.py | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'anidb.py') diff --git a/anidb.py b/anidb.py index 62258c9..d5c93d4 100644 --- a/anidb.py +++ b/anidb.py @@ -37,28 +37,11 @@ options, args = op.parse_args(sys.argv[1:]) options.login = options.add -# Authorization. - if options.login: if not options.username: options.username = raw_input('Username: ') if not options.password: options.passord = getpass.getpass() - a = pyanidb.AniDB(options.username, options.password) - try: - a.auth() - print 'Logged in as user %s.' % (options.username) - if a.new_version: - print 'New version available.' - except pyanidb.AniDBUserError: - print 'Invalid username/password.' - sys.exit(1) - except pyanidb.AniDBTimeout: - print 'Connection timed out.' - sys.exit(1) - except pyanidb.AniDBError, e: - print 'Fatal error:', e - sys.exit(1) # Input files. @@ -77,6 +60,29 @@ for name in args: subfiles.sort() files += [os.path.join(root, file) for file in subfiles if sum([file.endswith('.' + suffix) for suffix in options.suffix])] +if not files: + print 'All operations finished.' + sys.exit(0) + +# Authorization. + +if options.login: + a = pyanidb.AniDB(options.username, options.password) + try: + a.auth() + print 'Logged in as user %s.' % (options.username) + if a.new_version: + print 'New version available.' + except pyanidb.AniDBUserError: + print 'Invalid username/password.' + sys.exit(1) + except pyanidb.AniDBTimeout: + print 'Connection timed out.' + sys.exit(1) + except pyanidb.AniDBError, e: + print 'Fatal error:', e + sys.exit(1) + # Hashing. for filename, hash in pyanidb.hash.hash_files(files): -- cgit v1.2.3