Mercurial > p > roundup > code
diff roundup/scripts/roundup_server.py @ 5376:64b05e24dbd8
Python 3 preparation: convert print to a function.
Tool-assisted patch. It is possible that some "from __future__ import
print_function" are not in fact needed, if a file only uses print()
with a single string as an argument and so would work fine in Python 2
without that import.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 09:54:52 +0000 |
| parents | 91954be46a66 |
| children | 35ea9b1efc14 |
line wrap: on
line diff
--- a/roundup/scripts/roundup_server.py Sat Jul 21 23:07:16 2018 +1000 +++ b/roundup/scripts/roundup_server.py Tue Jul 24 09:54:52 2018 +0000 @@ -17,6 +17,7 @@ """Command-line script that runs a server over roundup.cgi.client. """ +from __future__ import print_function __docformat__ = 'restructuredtext' @@ -87,7 +88,7 @@ DEFAULT_MULTIPROCESS = MULTIPROCESS_TYPES[-1] def auto_ssl(): - print _('WARNING: generating temporary SSL certificate') + print(_('WARNING: generating temporary SSL certificate')) import OpenSSL, random pkey = OpenSSL.crypto.PKey() pkey.generate_key(OpenSSL.crypto.TYPE_RSA, 768) @@ -236,7 +237,7 @@ self.wfile.write('''<p>%s: An error occurred. Please check the server log for more information.</p>'''%ts) # out to the logfile - print 'EXCEPTION AT', ts + print('EXCEPTION AT', ts) traceback.print_exc() do_GET = do_POST = do_HEAD = run_cgi @@ -472,7 +473,7 @@ # if root, setgid to the running user if os.getuid(): - print _('WARNING: ignoring "-g" argument, not root') + print(_('WARNING: ignoring "-g" argument, not root')) return try: @@ -501,7 +502,7 @@ raise ValueError, _("Can't run as root!") if os.getuid(): - print _('WARNING: ignoring "-u" argument, not root') + print(_('WARNING: ignoring "-u" argument, not root')) return try: @@ -697,8 +698,8 @@ # obtain request server class if self["MULTIPROCESS"] not in MULTIPROCESS_TYPES: - print _("Multiprocess mode \"%s\" is not available, " - "switching to single-process") % self["MULTIPROCESS"] + print(_("Multiprocess mode \"%s\" is not available, " + "switching to single-process") % self["MULTIPROCESS"]) self["MULTIPROCESS"] = "none" server_class = base_server elif self["MULTIPROCESS"] == "fork": @@ -807,7 +808,7 @@ specified if -d is used.''' if message: message += '\n' - print _('''%(message)sUsage: roundup-server [options] [name=tracker home]* + print(_('''%(message)sUsage: roundup-server [options] [name=tracker home]* Options: -v print the Roundup version number and exit @@ -869,7 +870,7 @@ "port": DEFAULT_PORT, "mp_def": DEFAULT_MULTIPROCESS, "mp_types": ", ".join(MULTIPROCESS_TYPES), -} +}) def writepidfile(pidfile): @@ -975,11 +976,11 @@ if opt in ("-h", "--help"): usage() elif opt in ("-v", "--version"): - print '%s (python %s)' % (roundup_version, - sys.version.split()[0]) + print('%s (python %s)' % (roundup_version, + sys.version.split()[0])) elif opt in ("-S", "--save-config"): config.save() - print _("Configuration saved to %s") % config.filepath + print(_("Configuration saved to %s") % config.filepath) # any of the above options prevent server from running return @@ -997,8 +998,8 @@ # fork the server from our parent if a pidfile is specified if config["PIDFILE"]: if not hasattr(os, 'fork'): - print _("Sorry, you can't run the server as a daemon" - " on this Operating System") + print(_("Sorry, you can't run the server as a daemon" + " on this Operating System")) sys.exit(0) else: if config['NODAEMON']: @@ -1010,15 +1011,15 @@ httpd = config.get_server() if success_message: - print success_message + print(success_message) else: - print _('Roundup server started on %(HOST)s:%(PORT)s') \ - % config + print(_('Roundup server started on %(HOST)s:%(PORT)s') + % config) try: httpd.serve_forever() except KeyboardInterrupt: - print 'Keyboard Interrupt: exiting' + print('Keyboard Interrupt: exiting') if __name__ == '__main__': run()
