示例#1
0
 def test_creationflags(self):
     # creationflags argument
     CREATE_NEW_CONSOLE = 16
     sys.stderr.write("    a DOS box should flash briefly ...\n")
     subprocess.call(sys.executable +
                         ' -c "import time; time.sleep(0.25)"',
                     creationflags=CREATE_NEW_CONSOLE)
示例#2
0
    def copy_jvm_jar(self):
        from py.compat import subprocess
        basename = self.exe_name % self.get_info()
        root = udir.join('pypy')
        manifest = self.create_manifest(root)
        jnajar = py.path.local(__file__).dirpath('jvm', 'src', 'jna.jar')
        classlist = self.create_classlist(root, [jnajar])
        jarfile = py.path.local(basename + '.jar')
        self.log.info('Creating jar file')
        oldpath = root.chdir()
        subprocess.call(['jar', 'cmf', str(manifest), str(jarfile), '@'+str(classlist)])
        oldpath.chdir()

        # create a convenience script
        newexename = basename
        f = file(newexename, 'w')
        f.write("""#!/bin/bash
LEDIT=`type -p ledit`
EXE=`readlink $0`
if [ -z $EXE ]
then
    EXE=$0
fi
$LEDIT java -Xmx256m -jar $EXE.jar "$@"
""")
        f.close()
        os.chmod(newexename, 0755)
示例#3
0
 def test_creationflags(self):
     # creationflags argument
     CREATE_NEW_CONSOLE = 16
     sys.stderr.write("    a DOS box should flash briefly ...\n")
     subprocess.call(sys.executable +
                     ' -c "import time; time.sleep(0.25)"',
                     creationflags=CREATE_NEW_CONSOLE)
示例#4
0
    def copy_jvm_jar(self):
        from py.compat import subprocess
        basename = self.exe_name % self.get_info()
        root = udir.join('pypy')
        manifest = self.create_manifest(root)
        jnajar = py.path.local(__file__).dirpath('jvm', 'src', 'jna.jar')
        classlist = self.create_classlist(root, [jnajar])
        jarfile = py.path.local(basename + '.jar')
        self.log.info('Creating jar file')
        oldpath = root.chdir()
        subprocess.call(['jar', 'cmf', str(manifest), str(jarfile), '@'+str(classlist)])
        oldpath.chdir()

        # create a convenience script
        newexename = basename
        f = file(newexename, 'w')
        f.write("""#!/bin/bash
LEDIT=`type -p ledit`
EXE=`readlink $0`
if [ -z $EXE ]
then
    EXE=$0
fi
$LEDIT java -Xmx256m -jar $EXE.jar "$@"
""")
        f.close()
        os.chmod(newexename, 0755)
示例#5
0
    def copy_jvm_jar(self):
        from py.compat import subprocess

        basename = self.exe_name % self.get_info()
        root = udir.join("pypy")
        manifest = self.create_manifest(root)
        jnajar = py.path.local(__file__).dirpath("jvm", "src", "jna.jar")
        classlist = self.create_classlist(root, [jnajar])
        jarfile = py.path.local(basename + ".jar")
        self.log.info("Creating jar file")
        oldpath = root.chdir()
        subprocess.call(["jar", "cmf", str(manifest), str(jarfile), "@" + str(classlist)])
        oldpath.chdir()

        # create a convenience script
        newexename = basename
        f = file(newexename, "w")
        f.write(
            """#!/bin/bash
LEDIT=`type -p ledit`
EXE=`readlink $0`
if [ -z $EXE ]
then
    EXE=$0
fi
$LEDIT java -Xmx256m -jar $EXE.jar "$@"
"""
        )
        f.close()
        os.chmod(newexename, 0755)
示例#6
0
 def test_startupinfo(self):
     # startupinfo argument
     # We uses hardcoded constants, because we do not want to
     # depend on win32all.
     STARTF_USESHOWWINDOW = 1
     SW_MAXIMIZE = 3
     startupinfo = subprocess.STARTUPINFO()
     startupinfo.dwFlags = STARTF_USESHOWWINDOW
     startupinfo.wShowWindow = SW_MAXIMIZE
     # Since Python is a console process, it won't be affected
     # by wShowWindow, but the argument should be silently
     # ignored
     subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"],
                 startupinfo=startupinfo)
示例#7
0
 def test_startupinfo(self):
     # startupinfo argument
     # We uses hardcoded constants, because we do not want to
     # depend on win32all.
     STARTF_USESHOWWINDOW = 1
     SW_MAXIMIZE = 3
     startupinfo = subprocess.STARTUPINFO()
     startupinfo.dwFlags = STARTF_USESHOWWINDOW
     startupinfo.wShowWindow = SW_MAXIMIZE
     # Since Python is a console process, it won't be affected
     # by wShowWindow, but the argument should be silently
     # ignored
     subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"],
                     startupinfo=startupinfo)
示例#8
0
 def create_classlist(self, root, additional_jars=[]):
     from py.compat import subprocess
     # first, uncompress additional jars
     for jarfile in additional_jars:
         oldpwd = root.chdir()
         subprocess.call(['jar', 'xf', str(jarfile)])
         oldpwd.chdir()
     filename = root.join('classlist.txt')
     classlist = filename.open('w')
     classfiles = list(root.visit('*.class', True))
     classfiles += root.visit('*.so', True)
     classfiles += root.visit('*.dll', True)
     classfiles += root.visit('*.jnilib', True)
     for classfile in classfiles:
         print >> classlist, classfile.relto(root)
     classlist.close()
     return filename
示例#9
0
 def create_classlist(self, root, additional_jars=[]):
     from py.compat import subprocess
     # first, uncompress additional jars
     for jarfile in additional_jars:
         oldpwd = root.chdir()
         subprocess.call(['jar', 'xf', str(jarfile)])
         oldpwd.chdir()
     filename = root.join('classlist.txt')
     classlist = filename.open('w')
     classfiles = list(root.visit('*.class', True))
     classfiles += root.visit('*.so', True)
     classfiles += root.visit('*.dll', True)
     classfiles += root.visit('*.jnilib', True)
     for classfile in classfiles:
         print >> classlist, classfile.relto(root)
     classlist.close()
     return filename
示例#10
0
 def test_call_kwargs(self):
     # call() function with keyword args
     newenv = os.environ.copy()
     newenv["FRUIT"] = "banana"
     rc = subprocess.call([sys.executable, "-c",
                       'import sys, os;' \
                       'sys.exit(os.getenv("FRUIT")=="banana")'],
                     env=newenv)
     self.assertEqual(rc, 1)
示例#11
0
    def create_classlist(self, root, additional_jars=[]):
        from py.compat import subprocess

        # first, uncompress additional jars
        for jarfile in additional_jars:
            oldpwd = root.chdir()
            subprocess.call(["jar", "xf", str(jarfile)])
            oldpwd.chdir()
        filename = root.join("classlist.txt")
        classlist = filename.open("w")
        classfiles = list(root.visit("*.class", True))
        classfiles += root.visit("*.so", True)
        classfiles += root.visit("*.dll", True)
        classfiles += root.visit("*.jnilib", True)
        for classfile in classfiles:
            print >> classlist, classfile.relto(root)
        classlist.close()
        return filename
示例#12
0
 def test_call_kwargs(self):
     # call() function with keyword args
     newenv = os.environ.copy()
     newenv["FRUIT"] = "banana"
     rc = subprocess.call([sys.executable, "-c",
                       'import sys, os;' \
                       'sys.exit(os.getenv("FRUIT")=="banana")'],
                     env=newenv)
     self.assertEqual(rc, 1)
示例#13
0
 def test_call_string(self):
     # call() function with string argument on UNIX
     f, fname = self.mkstemp()
     os.write(f, "#!/bin/sh\n")
     os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
                 sys.executable)
     os.close(f)
     os.chmod(fname, 0700)
     rc = subprocess.call(fname)
     os.remove(fname)
     self.assertEqual(rc, 47)
示例#14
0
 def test_call_string(self):
     # call() function with string argument on UNIX
     f, fname = self.mkstemp()
     os.write(f, "#!/bin/sh\n")
     os.write(
         f, "exec %s -c 'import sys; sys.exit(47)'\n" % sys.executable)
     os.close(f)
     os.chmod(fname, 0700)
     rc = subprocess.call(fname)
     os.remove(fname)
     self.assertEqual(rc, 47)
示例#15
0
def load_and_cache_assembly(name, outfile):
    tmpfile = udir.join(name)
    arglist = SDK.runtime() + [Query.get(), name, str(tmpfile)]
    retcode = subprocess.call(arglist)
    assert retcode == 0
    mydict = {}
    execfile(str(tmpfile), mydict)
    types = mydict['types']
    f = outfile.open('wb')
    pickle.dump(types, f, pickle.HIGHEST_PROTOCOL)
    f.close()
    return types
示例#16
0
文件: query.py 项目: alkorzt/pypy
def load_and_cache_assembly(name, outfile):
    tmpfile = udir.join(name)
    arglist = SDK.runtime() + [Query.get(), name, str(tmpfile)]
    retcode = subprocess.call(arglist)
    assert retcode == 0
    mydict = {}
    execfile(str(tmpfile), mydict)
    types = mydict['types']
    f = outfile.open('wb')
    pickle.dump(types, f, pickle.HIGHEST_PROTOCOL)
    f.close()
    return types
示例#17
0
 def test_call_string(self):
     # call() function with string argument on Windows
     rc = subprocess.call(sys.executable +
                          ' -c "import sys; sys.exit(47)"')
     self.assertEqual(rc, 47)
示例#18
0
 def test_call_seq(self):
     # call() function with sequence argument
     rc = subprocess.call([sys.executable, "-c",
                           "import sys; sys.exit(47)"])
     self.assertEqual(rc, 47)
示例#19
0
 def probe(self, exe, args):
     from py.compat import subprocess
     env = os.environ.copy()
     env['_INSTRUMENT_COUNTERS'] = str(self.datafile)
     subprocess.call("'%s' %s" % (exe, args), env=env, shell=True)
示例#20
0
 def test_call_seq(self):
     # call() function with sequence argument
     rc = subprocess.call(
         [sys.executable, "-c", "import sys; sys.exit(47)"])
     self.assertEqual(rc, 47)
示例#21
0
 def test_call_string(self):
     # call() function with string argument on Windows
     rc = subprocess.call(sys.executable +
                          ' -c "import sys; sys.exit(47)"')
     self.assertEqual(rc, 47)
示例#22
0
文件: driver.py 项目: chyyuu/pygirl
 def probe(self, exe, args):
     from py.compat import subprocess
     env = os.environ.copy()
     env['_INSTRUMENT_COUNTERS'] = str(self.datafile)
     subprocess.call("'%s' %s" % (exe, args), env=env, shell=True)