Blob Blame History Raw
diff -up nws/nws/inst/bin/BackgroundLaunch.py.fixpy3 nws/nws/inst/bin/BackgroundLaunch.py
--- nws/nws/inst/bin/BackgroundLaunch.py.fixpy3	2019-02-06 13:04:16.234539884 -0500
+++ nws/nws/inst/bin/BackgroundLaunch.py	2019-02-06 13:04:22.323410156 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # Copyright (c) 2005-2008, REvolution Computing, Inc.
 #
diff -up nws/nws/inst/bin/RNWSSleighWorker.py.fixpy3 nws/nws/inst/bin/RNWSSleighWorker.py
--- nws/nws/inst/bin/RNWSSleighWorker.py.fixpy3	2019-02-06 13:01:56.317534844 -0500
+++ nws/nws/inst/bin/RNWSSleighWorker.py	2019-02-06 13:02:51.659341784 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 #
 # Copyright (c) 2005-2008, REvolution Computing, Inc.
 #
@@ -51,11 +51,11 @@ def main():
     else:
         outfile = _NULFILE
     Env['RSleighLogFile'] = outfile
-    verbose = Env.has_key('RSleighWorkerOut') and 'TRUE' or 'FALSE'
+    verbose = 'RSleighWorkerOut' in Env and 'TRUE' or 'FALSE'
     nwsName = Env['RSleighNwsName']
     nwsHost = Env.get('RSleighNwsHost', 'localhost')
     nwsPort = int(Env.get('RSleighNwsPort', '8765'))
-    print nwsName, nwsHost, nwsPort
+    print(nwsName, nwsHost, nwsPort)
 
     # create the script file for the worker to execute
     script = '''\
@@ -88,7 +88,7 @@ cmdLaunch(%s)
     tmpfile.write(script)
     tmpfile.close()
 
-    print "executing R worker"
+    print("executing R worker")
     rprog = Env.get('RProg', 'R')
     argv = [rprog, '--vanilla', '--slave']
     out = open(outfile, 'w')
@@ -100,10 +100,10 @@ cmdLaunch(%s)
         else:
             p = subprocess.Popen(argv, stdin=open(tmpname), stdout=out,
                     stderr=subprocess.STDOUT, preexec_fn=setpg)
-    except OSError, e:
-        print >> sys.stderr, 'error executing command:', argv
+    except OSError as e:
+        print('error executing command:', argv, file=sys.stderr)
         if not os.path.exists(rprog):
-            print >> sys.stderr, rprog, 'does not exist'
+            print(rprog, 'does not exist', file=sys.stderr)
         raise e
 
     if hasattr(p, '_handle'):
@@ -113,7 +113,7 @@ cmdLaunch(%s)
         try: os.setpgid(wpid, 0)
         except: pass
 
-    print "waiting for shutdown"
+    print("waiting for shutdown")
     sys.path[1:1] = modulePath.split(os.pathsep)
 
     try:
@@ -124,13 +124,13 @@ cmdLaunch(%s)
         nws = NetWorkSpace(nwsName, nwsHost, nwsPort, useUse=True, create=False)
         sentinel(nws)
 
-        print "killing R worker"
+        print("killing R worker")
         kill(wpid)
     except ImportError:
         # nws-python isn't installed, so just wait for the worker to exit
         p.wait()
 
-    print "all done"
+    print("all done")
 
     # XXX might need to wait for child to die on Windows
     try: os.remove(tmpname)
@@ -147,7 +147,7 @@ def getenv(args):
             k, v = [x.strip() for x in kv.split('=', 1)]
             if k: e[k] = v
         except:
-            print "warning: bad argument:", kv
+            print("warning: bad argument:", kv)
     return e
 
 def setup(f):
@@ -164,7 +164,7 @@ def setup(f):
         sys.stderr = outfile
     except:
         traceback.print_exc()
-        print "warning: unable to create file:", log
+        print("warning: unable to create file:", log)
 
     # cd to the specified directory
     wd = Env.get('RSleighWorkingDir')
@@ -175,13 +175,13 @@ def setup(f):
         os.chdir(wd)
     except:
         traceback.print_exc()
-        print "warning: unable to cd to", wd
+        print("warning: unable to cd to", wd)
 
     # this information will normally seem rather obvious
-    print "current working directory:", os.getcwd()
+    print("current working directory:", os.getcwd())
 
 def sentinel(nws):
-    print "waiting for sleigh to be stopped"
+    print("waiting for sleigh to be stopped")
 
     try:
         nws.find('Sleigh ride over')
@@ -190,7 +190,7 @@ def sentinel(nws):
         try: nws.store('bye', str(sys.exc_info()[1]))
         except: pass
 
-    print "sentinel returning"
+    print("sentinel returning")
 
 def kill(pid):
     try:
@@ -203,7 +203,7 @@ def kill(pid):
             try:
                 from signal import SIGTERM as sig
             except ImportError:
-                print "couldn't import signal module"
+                print("couldn't import signal module")
                 sig = 15
             try: os.kill(-pid, sig)
             except: os.kill(pid, sig)
@@ -225,9 +225,9 @@ if __name__ == '__main__':
                 Env.get('RSleighID', 'X') + '.txt'
         setup(f)
 
-        if not Env.has_key('RSleighNwsName'):
-            print "RSleighNwsName variable is not set"
-            print >> sys.__stderr__, "RSleighNwsName variable is not set"
+        if 'RSleighNwsName' not in Env:
+            print("RSleighNwsName variable is not set")
+            print("RSleighNwsName variable is not set", file=sys.__stderr__)
         else:
             main()
     except:
diff -up nws/nws/inst/examples/sleigh/portfolio_race.py.fixpy3 nws/nws/inst/examples/sleigh/portfolio_race.py
--- nws/nws/inst/examples/sleigh/portfolio_race.py.fixpy3	2008-05-19 09:32:16.000000000 -0400
+++ nws/nws/inst/examples/sleigh/portfolio_race.py	2019-02-06 13:03:12.829890746 -0500
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import os, sys, subprocess
 from nws.client import NwsServer
 
 if not os.environ.get('DISPLAY'):
-    print >> sys.stderr, 'error: X11 is required.  DISPLAY environment variable not set'
+    print('error: X11 is required.  DISPLAY environment variable not set', file=sys.stderr)
     sys.exit(1)
 
 # create a unique workspace to synchronize with the contestants
@@ -22,10 +22,10 @@ seq = subprocess.Popen(argv, stdin=open(
 # wait for them to be ready, and then start the race
 ws.fetch('par')
 ws.fetch('seq')
-raw_input('hit return to start race: ')
+input('hit return to start race: ')
 ws.store('go', 'go')
 
 # wait for them to exit
-print "click in the windows when complete to close them"
+print("click in the windows when complete to close them")
 par.wait()
 seq.wait()