mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Transifex pull: made script more kind when networks fails
This commit is contained in:
parent
a414fdee77
commit
d5253e1690
@ -2,11 +2,11 @@
|
||||
#vim:set fileencoding=utf-8 sw=2 expandtab
|
||||
|
||||
from transifex import Transifex
|
||||
import requests
|
||||
import getpass
|
||||
import sys
|
||||
|
||||
def main():
|
||||
import getpass
|
||||
import sys
|
||||
|
||||
print 'Use your account to talk with Transifex.'
|
||||
user = raw_input('Username: ')
|
||||
passwd = getpass.getpass('Password: ')
|
||||
@ -14,18 +14,32 @@ def main():
|
||||
|
||||
for lang in sys.argv[1:]:
|
||||
fname = 'Resources_%s.po' % lang
|
||||
print "Updating %s from Transifex..." % fname,
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
lang = trans.canonical_lang(lang)
|
||||
trans.pull(lang, fname)
|
||||
pull(trans, lang, fname)
|
||||
except RuntimeError, e:
|
||||
print e.message
|
||||
continue
|
||||
except IOError, e:
|
||||
print e.strerror
|
||||
continue
|
||||
print
|
||||
|
||||
def pull(trans, lang, fname):
|
||||
count = 0
|
||||
print "Updating %s from Transifex...\n" % fname,
|
||||
sys.stdout.flush()
|
||||
while count < 5:
|
||||
count += 1
|
||||
try:
|
||||
trans.pull(lang, fname)
|
||||
return
|
||||
except requests.exceptions.HTTPError, e:
|
||||
print " *** Retrying %s from Transifex...\n" % fname,
|
||||
sys.stdout.flush()
|
||||
|
||||
if count >= 5:
|
||||
raise Exception("Too many retries")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user