Skip to content

Commit d5253e1

Browse files
author
Federico Fissore
committed
Transifex pull: made script more kind when networks fails
1 parent a414fde commit d5253e1

File tree

1 file changed

+20
-6
lines changed
  • arduino-core/src/processing/app/i18n/python

1 file changed

+20
-6
lines changed

arduino-core/src/processing/app/i18n/python/pull.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,44 @@
22
#vim:set fileencoding=utf-8 sw=2 expandtab
33

44
from transifex import Transifex
5+
import requests
6+
import getpass
7+
import sys
58

69
def main():
7-
import getpass
8-
import sys
9-
1010
print 'Use your account to talk with Transifex.'
1111
user = raw_input('Username: ')
1212
passwd = getpass.getpass('Password: ')
1313
trans = Transifex(user, passwd)
1414

1515
for lang in sys.argv[1:]:
1616
fname = 'Resources_%s.po' % lang
17-
print "Updating %s from Transifex..." % fname,
1817
sys.stdout.flush()
1918
try:
2019
lang = trans.canonical_lang(lang)
21-
trans.pull(lang, fname)
20+
pull(trans, lang, fname)
2221
except RuntimeError, e:
2322
print e.message
2423
continue
2524
except IOError, e:
2625
print e.strerror
2726
continue
28-
print
27+
28+
def pull(trans, lang, fname):
29+
count = 0
30+
print "Updating %s from Transifex...\n" % fname,
31+
sys.stdout.flush()
32+
while count < 5:
33+
count += 1
34+
try:
35+
trans.pull(lang, fname)
36+
return
37+
except requests.exceptions.HTTPError, e:
38+
print " *** Retrying %s from Transifex...\n" % fname,
39+
sys.stdout.flush()
40+
41+
if count >= 5:
42+
raise Exception("Too many retries")
2943

3044
if __name__ == '__main__':
3145
main()

0 commit comments

Comments
 (0)