DansTonCode.net
quote.smartness() == 42In the one and only true way. The object-oriented version of 'Spaghetti code' is, of course, 'Lasagna code'. (Too many layers).@author Roberto Waltman
Quote #284
python
@
author 
Anonymous
0
        except tweepy.TweepError as e:
            print e
            if e.reason == 'Not authorized':
                return []
            try:
                wait_secs = 10.0
                time.sleep(wait_secs)
                rate_status = api.rate_limit_status()
                print "Error! Remaining hits : ", rate_status['remaining_hits']
                if rate_status['remaining_hits'] == 0:
                    print "No remaining hits..."
                    api = get_best_context()
                    print "New context selected"
                    rate_status = api.rate_limit_status()
                while rate_status['remaining_hits'] == 0:
                    wait_until = rate_status['reset_time_in_seconds']
                    wait_secs = wait_until - time.time() + 30.0
                    print time.strftime("%d %b: %H:%M:%S ", time.localtime())
                    print "waiting %f minutes..." % float(wait_secs / 60.0)
                    time.sleep(wait_secs)
                    rate_status = api.rate_limit_status()
            except tweepy.TweepError as e:
                wait_secs = 600.0
                print "Waiting %f seconds(Something is wrong)..." % wait_secs
                time.sleep(wait_secs)
Code source n°284
Code-source en python proposé par Anonymous
 
 0