BryanDavis has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402119 )

Change subject: pcc: Python3 compatibility
......................................................................

pcc: Python3 compatibility

Make pcc work with python3 (it's the future!) while still keeping
python2 support for those poor folks for whom `/usr/bin/env python` is
still python2.

Change-Id: Ic0df42ea526ae05b86f238597653496080b05a9e
---
M utils/pcc
1 file changed, 17 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/19/402119/1

diff --git a/utils/pcc b/utils/pcc
index 6e77b47..1afd2a0 100755
--- a/utils/pcc
+++ b/utils/pcc
@@ -30,9 +30,14 @@
   Licensed under the Apache license.
 
 """
+from __future__ import print_function
+
 import sys
-reload(sys)
-sys.setdefaultencoding('utf-8')
+try:
+    reload(sys)
+    sys.setdefaultencoding('utf-8')
+except NameError:
+    pass  # python3 FTW
 
 import argparse
 import json
@@ -41,7 +46,11 @@
 import subprocess
 import textwrap
 import time
-import urllib2
+
+try:
+    import urllib2
+except ImportError:
+    import urllib.request as urllib2
 
 try:
     import jenkinsapi
@@ -125,7 +134,7 @@
     password=args.api_token
 )
 
-print yellow('Compiling %(change)s on node(s) %(nodes)s...' % vars(args))
+print(yellow('Compiling %(change)s on node(s) %(nodes)s...' % vars(args)))
 
 job = jenkins.get_job('operations-puppet-catalog-compiler')
 build_params = {
@@ -145,7 +154,7 @@
 
 build = invocation.get_build()
 
-print 'Your build URL is %s' % white(build.baseurl)
+print('Your build URL is %s' % white(build.baseurl))
 
 running = True
 output = ''
@@ -153,7 +162,7 @@
     time.sleep(1)
     running = invocation.is_running()
     new_output = build.get_console().rstrip('\n')
-    print format_console_output(new_output[len(output):]),
+    print(format_console_output(new_output[len(output):]),)
     output = new_output
 
 # Puppet's exit code is not always meaningful, so we grep the output
@@ -161,8 +170,8 @@
 ok = ('Run finished' in output and not
       re.search(r'[1-9]\d* (ERROR|FAIL)', output))
 if ok:
-    print green('SUCCESS')
+    print(green('SUCCESS'))
     sys.exit(0)
 else:
-    print red('FAIL')
+    print(red('FAIL'))
     sys.exit(1)

-- 
To view, visit https://gerrit.wikimedia.org/r/402119
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0df42ea526ae05b86f238597653496080b05a9e
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BryanDavis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to