Skip to content

Commit ed8395d

Browse files
committed
Run python-modernize on stashcp
1 parent 67c88d8 commit ed8395d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

stashcp/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import absolute_import
4+
from __future__ import print_function
35
import optparse
46
import sys
57
import subprocess
@@ -459,7 +461,7 @@ def parse_job_ad():
459461
match = re.search('^\s*(Owner|ProjectName)\s=\s"(.*)"', line, re.IGNORECASE)
460462
if match:
461463
temp_list[match.group(1)] = match.group(2)
462-
except IOError, e:
464+
except IOError as e:
463465
logging.error("Unable to open the .job.ad file")
464466

465467
return temp_list
@@ -495,7 +497,7 @@ def _es_send(payload):
495497
f = urllib2.urlopen(req)
496498
f.read()
497499
f.close()
498-
except urllib2.URLError, e:
500+
except urllib2.URLError as e:
499501
logging.warning("Error posting to ES: %s", str(e))
500502

501503
p = multiprocessing.Process(target=_es_send, name="_es_send", args=(payload,))
@@ -689,7 +691,7 @@ def get_stashservers_caches(responselines):
689691
for l in lists[0:-1]:
690692
names = names + ',' + l.split('=')[0]
691693
# skip leading comma
692-
print(names[1:])
694+
print((names[1:]))
693695
sys.exit(0)
694696

695697
if cache_list_name == None:
@@ -763,9 +765,9 @@ def get_best_stashcache():
763765
response.close()
764766
break
765767
response.close()
766-
except urllib2.URLError, e:
768+
except urllib2.URLError as e:
767769
logging.debug("URL error: %s", str(e))
768-
except Exception, e:
770+
except Exception as e:
769771
logging.debug("Error: %s", str(e))
770772
i+=1
771773

@@ -857,7 +859,7 @@ def main():
857859

858860
cache_list_name = args.cache_list_name
859861
if args.closest or args.list_names:
860-
print get_best_stashcache()
862+
print(get_best_stashcache())
861863
sys.exit(0)
862864

863865
if len(opts) != 2:

0 commit comments

Comments
 (0)