Commits

Chris McDonough committed de359a4

make work minimally with Jython

Comments (0)

Files changed (2)

paste/script/command.py

 try:
     import subprocess
 except ImportError:
-    from paste.script.util import subprocess24 as subprocess
+    try:
+        from paste.script.util import subprocess24 as subprocess
+    except ImportError:
+        subprocess = None # jython
+        
 difflib = None
 
 if sys.version_info >= (2, 6):
         force_no_simulate:
             if true, run the command even if --simulate
         """
+        if subprocess is None:
+            raise RuntimeError('Environment does not support subprocess '
+                               'module, cannot run command.')
         cmd = self.quote_first_command_arg(cmd)
         cwd = popdefault(kw, 'cwd', os.getcwd())
         capture_stderr = popdefault(kw, 'capture_stderr', False)

paste/script/copydir.py

 try:
     import subprocess
 except ImportError:
-    from paste.script.util import subprocess24 as subprocess
+    try:
+        from paste.script.util import subprocess24 as subprocess
+    except ImportError:
+        subprocess = None # jython
 import inspect
 
 class SkipTemplate(Exception):
                     print '%sRunning: %s' % (pad, ' '.join(cmd))
                 if not simulate:
                     # @@: Should
+                    if subprocess is None:
+                        raise RuntimeError('copydir failed, environment '
+                                           'does not support subprocess '
+                                           'module')
                     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
                     stdout, stderr = proc.communicate()
                     if verbosity > 1 and stdout: