diff options
author | zyp <zyp@localhost> | 2006-05-17 01:54:31 +0200 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-05-17 01:54:31 +0200 |
commit | efbe12547b2250cebd08ad25b6145a902a7b0849 (patch) | |
tree | 9296744342654c57ef3e0a1ef0dfc573bc5ee3af /anidb.py | |
parent | cf40dbdb820d1248c0e11c67a15b3cb88851becf (diff) |
[project @ zyp-20060516235431-615621c154308c58]
[project @ 36]
Added distutils metadata, MANIFEST.in, README and COPYING. Incremented clientver. Prevented useless connects.
Diffstat (limited to 'anidb.py')
-rw-r--r-- | anidb.py | 40 |
1 files changed, 23 insertions, 17 deletions
@@ -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): |