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

Change subject: Switch to Python3-compatible print()
......................................................................

Switch to Python3-compatible print()

Change-Id: If5cc41ddf765a927c2f40419556fe25d2ff26a0d
---
M clients/debdeploy-deploy
M clients/debdeploy-restarts
M clients/debdeploy-revdeps
M server/debdeploy
M server/debdeploy_conf.py
M server/debdeploy_updatespec.py
M server/generate-debdeploy-spec
7 files changed, 97 insertions(+), 83 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/debdeploy 
refs/changes/50/374950/1

diff --git a/clients/debdeploy-deploy b/clients/debdeploy-deploy
index d86d3e7..68b736e 100755
--- a/clients/debdeploy-deploy
+++ b/clients/debdeploy-deploy
@@ -2,6 +2,8 @@
 # -*- coding: utf-8 -*-
 """Module for deploying DEB packages on wide scale."""
 
+from __future__ import print_function
+
 import argparse
 import json
 import logging
@@ -261,7 +263,7 @@
 
 
 if __name__ == '__main__':
-    print(main())
+    print((main()))
 
 # Local variables:
 # mode: python
diff --git a/clients/debdeploy-restarts b/clients/debdeploy-restarts
index 184bca9..c697bc4 100755
--- a/clients/debdeploy-restarts
+++ b/clients/debdeploy-restarts
@@ -4,6 +4,8 @@
 Module for listing necessary service restarts after library updates
 '''
 
+from __future__ import print_function
+
 import logging
 import pickle
 import subprocess
@@ -138,7 +140,7 @@
 
 
 if __name__ == '__main__':
-    print main()
+    print(main())
 
 # Local variables:
 # mode: python
diff --git a/clients/debdeploy-revdeps b/clients/debdeploy-revdeps
index 3878269..5a9bccc 100755
--- a/clients/debdeploy-revdeps
+++ b/clients/debdeploy-revdeps
@@ -4,6 +4,8 @@
 Module for querying installed reverse dependencies of a package
 '''
 
+from __future__ import print_function
+
 import argparse
 import json
 import subprocess
@@ -48,7 +50,7 @@
         if e.output.startswith('E: No packages found'):
             return result(False, 'INVALID_PACKAGE', [])
 
-        print 'Failed to query reverse dependies', e.returncode
+        print('Failed to query reverse dependies', e.returncode)
         return result(False, 'QUERY_FAIL', [])
 
     deps = set()
@@ -67,7 +69,7 @@
 
 
 if __name__ == '__main__':
-    print main()
+    print(main())
 
 # Local variables:
 # mode: python
diff --git a/server/debdeploy b/server/debdeploy
index 5b23740..9100048 100755
--- a/server/debdeploy
+++ b/server/debdeploy
@@ -5,6 +5,8 @@
 # reinstate rollback handling
 # revamp and readd restart handling
 
+from __future__ import print_function
+
 import argparse
 import code
 import cumin
@@ -25,7 +27,7 @@
 from debdeploy_updatespec import *
 
 if os.geteuid() != 0:
-    print "debdeploy needs to be run as root"
+    print("debdeploy needs to be run as root")
     sys.exit(1)
 
 
@@ -60,7 +62,7 @@
         if self.buf.count("\n") > self.threshold:
             pydoc.pager(self.buf)
         else:
-            print self.buf
+            print(self.buf)
 
 
 def show_unreachable_hosts(worker):
@@ -70,10 +72,10 @@
             unreachable_hosts.append(node.name)
 
     if unreachable_hosts:
-        print
-        print "The following hosts were unreachable:"
+        print()
+        print("The following hosts were unreachable:")
         for host in unreachable_hosts:
-            print host
+            print(host)
 
 def run_cumin(cmd, alias):
     '''
@@ -103,8 +105,8 @@
             return worker
 
         except cumin.backends.InvalidQueryError as e:
-            print "Invalid query:"
-            print e
+            print("Invalid query:")
+            print(e)
             sys.exit(1)
         finally:
             sys.stdout = oldstdout
@@ -127,9 +129,9 @@
     update_desc["daemon-disrupt"] = "Daemon update with service availability 
impact"
     update_desc["library"] = "Library update, several services might need to 
be restarted"
 
-    print "Rolling out", source, ":",
-    print update_desc[update_type]
-    print
+    print("Rolling out", source, ": ")
+    print(update_desc[update_type])
+    print()
 
     cmd = '/usr/bin/debdeploy-deploy --source ' + source + ' --updatespec '
     for distro in fixes:
@@ -150,30 +152,30 @@
                             "INVALID_DISTRO": "Found an unsupported distro:"}
 
             if result['status'] in status_codes:
-                print status_codes[result['status']]
-                print status_print.fill(str(nodeset))
-                print
+                print(status_codes[result['status']])
+                print(status_print.fill(str(nodeset)))
+                print()
             elif result['success'] and result['status'] == 'UPDATES':
                 updates = result['data']
                 for package in updates.keys():
-                    print package, "was updated: ", updates[package][0], "->", 
updates[package][1]
-                    print status_print.fill(str(nodeset))
-                    print
+                    print(package, "was updated: ", updates[package][0], "->", 
updates[package][1])
+                    print(status_print.fill(str(nodeset)))
+                    print()
             else:
                 if result['success']:
-                    print "Unspecified return code:"
+                    print("Unspecified return code:")
                 else:
-                    print "Unspecified error:"
-                print result['status']
+                    print("Unspecified error:")
+                print(result['status'])
 
         except ValueError as e:
-            print "Could not decode JSON response for"
-            print nodeset
-            print e
+            print("Could not decode JSON response for")
+            print(nodeset)
+            print(e)
 
         except KeyError as e:
-            print "Failed to read expected value", e, ":"
-            print nodeset
+            print("Failed to read expected value", e, ":")
+            print(nodeset)
 
     show_unreachable_hosts(worker)
 
@@ -210,18 +212,18 @@
                                         restarts_per_lib[library][program] = []
                                     restarts_per_lib[library][program] = 
nodeset
                 elif result['status'] == 'NO_RESTARTS_NEEDED':
-                    print "No service needs a restart"
+                    print("No service needs a restart")
 
         except ValueError as e:
-            print "Could not decode JSON response for"
-            print nodeset
-            print e
+            print("Could not decode JSON response for")
+            print(nodeset)
+            print(e)
 
     for lib in restarts_per_lib:
-        print "Restarts for", lib, ":"
+        print("Restarts for", lib, ":")
         for program in restarts_per_lib[lib]:
-            print "  ", program
-            print "      " + str(restarts_per_lib[lib][program]) + " (" + 
str(len(restarts_per_lib[lib][program])) + " hosts)"
+            print("  ", program)
+            print("      " + str(restarts_per_lib[lib][program]) + " (" + 
str(len(restarts_per_lib[lib][program])) + " hosts)")
 
     show_unreachable_hosts(worker)
 
@@ -248,28 +250,28 @@
             if result['success']:
                 if result['status'] == 'LIST_DEPS':
                     if result['data']:
-                        print nodeset
+                        print(nodeset)
                         for service in result['data']:
-                            print status_print.fill(service)
+                            print(status_print.fill(service))
                     else:
-                        print nodeset
-                        print status_print.fill("No reverse dependencies 
installed")
+                        print(nodeset)
+                        print(status_print.fill("No reverse dependencies 
installed"))
             else:
                 error_codes = {"QUERY_FAIL": "Failed to query reverse 
dependencies:",
                                "INVALID_PACKAGE": "Unknown package:"}
 
                 if result['status'] in error_codes:
-                    print error_codes[result['status']]
-                    print status_print.fill(str(nodeset))
+                    print(error_codes[result['status']])
+                    print(status_print.fill(str(nodeset)))
 
         except ValueError as e:
-            print "Could not decode JSON response for"
-            print nodeset
-            print e
+            print("Could not decode JSON response for")
+            print(nodeset)
+            print(e)
 
         except KeyError as e:
-            print "Failed to read expected value", e, ":"
-            print nodeset
+            print("Failed to read expected value", e, ":")
+            print(nodeset)
 
     show_unreachable_hosts(worker)
 
diff --git a/server/debdeploy_conf.py b/server/debdeploy_conf.py
index 6556970..6870476 100644
--- a/server/debdeploy_conf.py
+++ b/server/debdeploy_conf.py
@@ -1,5 +1,7 @@
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
+
 import ConfigParser, sys
 
 class DebDeployConfig(object):
@@ -16,12 +18,12 @@
     def __init__(self, configfile):
         config = ConfigParser.ConfigParser()
         if len(config.read(configfile)) == 0:
-            print "/etc/debdeploy.conf doesn't exist, you need to create it."
-            print "See /usr/share/doc/debdeploy-master/examples/debdeploy.conf"
+            print("/etc/debdeploy.conf doesn't exist, you need to create it.")
+            print("See 
/usr/share/doc/debdeploy-master/examples/debdeploy.conf")
             sys.exit(1)
 
         if not config.has_section("distros"):
-            print "Could not read list of supported distributions, make sure", 
configfile, "contains a section [distros]"
+            print("Could not read list of supported distributions, make sure", 
configfile, "contains a section [distros]")
             sys.exit(1)
 
         for distro in config.options("distros"):
@@ -29,7 +31,7 @@
             self.supported_distros[distro].append([x.strip() for x in 
config.get("distros", distro).split(",")])
 
         if len(self.supported_distros) < 1:
-            print "You need to specify at least one supported distribution in 
/etc/debdeploy.conf"
+            print("You need to specify at least one supported distribution in 
/etc/debdeploy.conf")
             sys.exit(1)
 
         if config.has_section("libraries"):
diff --git a/server/debdeploy_updatespec.py b/server/debdeploy_updatespec.py
index 29e2d8a..08839fc 100644
--- a/server/debdeploy_updatespec.py
+++ b/server/debdeploy_updatespec.py
@@ -1,5 +1,7 @@
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
+
 import salt.client
 import yaml
 import sys
@@ -30,26 +32,26 @@
                 updatefile = yaml.load(stream)
 
         except IOError:
-            print "Error: Could not open", updatespec
+            print("Error: Could not open", updatespec)
             sys.exit(1)
 
         except yaml.scanner.ScannerError, e:
-            print "Invalid YAML file:"
-            print e
+            print("Invalid YAML file:")
+            print(e)
             sys.exit(1)
 
         if not updatefile.has_key("source"):
-            print "Invalid YAML file, you need to specify the source package 
using the 'source' stanza, see the annotated example file for details"
+            print("Invalid YAML file, you need to specify the source package 
using the 'source' stanza, see the annotated example file for details")
             sys.exit(1)
         else:
             self.source = updatefile["source"]
 
         if not updatefile.has_key("update_type"):
-            print "Invalid YAML file, you need to specify the type of update 
using the 'update_type' stanza, see the annotated example file for details"
+            print("Invalid YAML file, you need to specify the type of update 
using the 'update_type' stanza, see the annotated example file for details")
             sys.exit(1)
         else:
             if updatefile["update_type"] not in self.legit_type:
-                print "Invalid YAML file, invalid 'update_type'"
+                print("Invalid YAML file, invalid 'update_type'")
                 sys.exit(1)
             self.update_type = updatefile["update_type"]
 
@@ -60,14 +62,14 @@
             self.libraries = updatefile["libraries"]
 
         if not updatefile.has_key("fixes"):
-            print "Invalid YAML file, you need to specify at least one fixed 
version using the 'fixes' stanza, see the annotated example file for details"
+            print("Invalid YAML file, you need to specify at least one fixed 
version using the 'fixes' stanza, see the annotated example file for details")
             sys.exit(1)
         else:
             for i in updatefile["fixes"]:
                 if len(supported_distros.keys()) >= 1:
                     self.fixes[i] = updatefile["fixes"].get(i)
                 else:
-                    print "Invalid YAML file,", i, "is not a supported 
distribution. You need to activate it in /deb/debdeploy.conf"
+                    print("Invalid YAML file,", i, "is not a supported 
distribution. You need to activate it in /deb/debdeploy.conf")
                     sys.exit(1)
 
 # Local variables:
diff --git a/server/generate-debdeploy-spec b/server/generate-debdeploy-spec
index 8e9b750..e309c36 100755
--- a/server/generate-debdeploy-spec
+++ b/server/generate-debdeploy-spec
@@ -1,6 +1,8 @@
 #! /usr/bin/python
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
+
 import sys, optparse, logging, os, datetime
 from debdeploy_conf import *
 
@@ -15,29 +17,29 @@
 while source == "":
     source = raw_input("Please enter the name of source package (e.g. 
openssl). Leave blank or type 'quit' to abort\n>").strip()
     if source == "" or source == "quit":
-        print "Aborting"
+        print("Aborting")
         sys.exit(1)
 
 comment = raw_input('You can enter an optional comment, e.g. a reference to a 
security advisory or a CVE ID mapping\n>').strip()
 if comment == "quit":
-    print "Aborting"
+    print("Aborting")
     sys.exit(1)
 
 while updatetype not in ['tool', 'daemon-direct', 'daemon-disrupt', 'reboot', 
'library', 'quit']:
-    print "tool           -> The updated packages is an enduser tool, can be"
-    print "                  rolled-out immediately."
-    print "daemon-direct  -> Daemons which are restarted during update, but 
which"
-    print "                  do no affect existing users."
-    print "daemon-disrupt -> Daemons which are restarted during update, where 
the"
-    print "                  users notice an impact. The update procedure is 
almost"
-    print "                  identical, but displays additional warnings"
-    print "library        -> After a library is updated, programs may need to 
be"
-    print "                  restarted to fully effect the change. In addition"
-    print "                  to libs, some applications may also fall under 
this rule,"
-    print "                  e.g. when updating QEMU, you might need to 
restart VMs."
+    print("tool           -> The updated packages is an enduser tool, can be")
+    print("                  rolled-out immediately.")
+    print("daemon-direct  -> Daemons which are restarted during update, but 
which")
+    print("                  do no affect existing users.")
+    print("daemon-disrupt -> Daemons which are restarted during update, where 
the")
+    print("                  users notice an impact. The update procedure is 
almost")
+    print("                  identical, but displays additional warnings")
+    print("library        -> After a library is updated, programs may need to 
be")
+    print("                  restarted to fully effect the change. In 
addition")
+    print("                  to libs, some applications may also fall under 
this rule,")
+    print("                  e.g. when updating QEMU, you might need to 
restart VMs.")
     updatetype = raw_input("Please enter the update type:\n>").strip()
     if source == "" or source == "quit":
-        print "Aborting"
+        print("Aborting")
         sys.exit(1)
 
 for i in conf.supported_distros:
@@ -49,18 +51,18 @@
         at_least_one_fixed_version = True
 
 if not at_least_one_fixed_version:
-    print "At least one fixed version needs to be configured, aborting"
+    print("At least one fixed version needs to be configured, aborting")
     sys.exit(1)
 
 if updatetype == 'library':
-    print conf.library_hints
-    print "You can specify an optional comma-separated list of one or more 
library base names."
-    print "These are used to detect necessary library restarts after an 
upgrade of a library"
-    print "E.g. for openssl, these would be 'libssl' and 'libcrypto'"
+    print(conf.library_hints)
+    print("You can specify an optional comma-separated list of one or more 
library base names.")
+    print("These are used to detect necessary library restarts after an 
upgrade of a library")
+    print("E.g. for openssl, these would be 'libssl' and 'libcrypto'")
 
     if conf.library_hints.get(source, None):
-        print "A pre-defined set has been configured: ", 
conf.library_hints[source]
-        print "Press ENTER to use it or provide an alternative list"
+        print("A pre-defined set has been configured: ", 
conf.library_hints[source])
+        print("Press ENTER to use it or provide an alternative list")
         libinput = raw_input("Please enter the name of a library. Leave blank 
to quit \n>").strip()
         if libinput == "":
             libraries = conf.library_hints[source]
@@ -76,13 +78,13 @@
 valid_name = False
 suggested_name = datetime.datetime.now().strftime("%Y-%m-%d-") + source + 
".yaml"
 while not valid_name:
-    print "Please enter a name under which the YAML file should be created"
-    print "Leave blank to use ", suggested_name
+    print("Please enter a name under which the YAML file should be created")
+    print("Leave blank to use ", suggested_name)
     yamlfilename = raw_input('>').strip()
     if not yamlfilename:
         yamlfilename = suggested_name
     if os.path.exists(yamlfilename):
-        print "File name already exists, please re-enter."
+        print("File name already exists, please re-enter.")
     else:
         valid_name = True
 
@@ -99,7 +101,7 @@
         for i in libraries:
             yamlfile.write("      - " + i + "\n")
 except IOError, e:
-    print "Error:", e
+    print("Error:", e)
     sys.exit(1)
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If5cc41ddf765a927c2f40419556fe25d2ff26a0d
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/debdeploy
Gerrit-Branch: master
Gerrit-Owner: Muehlenhoff <mmuhlenh...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to