当前位置: 首页>>代码示例>>Python>>正文


Python lang.Runtime类代码示例

本文整理汇总了Python中java.lang.Runtime的典型用法代码示例。如果您正苦于以下问题:Python Runtime类的具体用法?Python Runtime怎么用?Python Runtime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Runtime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, console, history_file=default_history_file):
        Runtime.getRuntime().addShutdownHook(Thread(self))        

        self.history_file = history_file
        self.history = []
        self.loadHistory()            
          
        self.console = console
        self.index = len(self.history) - 1
        self.last = ""
开发者ID:0x7678,项目名称:android-ssl-bypass,代码行数:10,代码来源:history.py

示例2: run

    def run(self, options, args):
        if options.supported or options.supported_html:
            return storytext.guishared.ScriptEngine.run(self, options, args)

        class ShutdownHook(Thread):
            def run(tself):#@NoSelf
                self.cleanup(options.interface)
                
        if not options.disable_usecase_names:
            hook = ShutdownHook()
            Runtime.getRuntime().addShutdownHook(hook)

        return storytext.scriptengine.ScriptEngine.run(self, options, args)
开发者ID:gbtami,项目名称:storytext,代码行数:13,代码来源:__init__.py

示例3: actionPerformed

 def actionPerformed(self, event):
   browsers = ["google-chrome", "firefox", "opera", "epiphany", "konqueror", "conkeror", "midori", "kazehakase", "mozilla"]
   osName = System.getProperty("os.name")
   helpHTML = ClassLoader.getSystemResource("help.html").toString()
   if osName.find("Mac OS") == 0:
     Class.forName("com.apple.eio.FileManager").getDeclaredMethod( "openURL", [String().getClass()]).invoke(None, [helpHTML])
   elif osName.find("Windows") == 0:
     Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + helpHTML)
   else:
     browser = None
     for b in browsers:
       if browser == None and Runtime.getRuntime().exec(["which", b]).getInputStream().read() != -1:
         browser = b
         Runtime.getRuntime().exec([browser, helpHTML])
开发者ID:pavithra03,项目名称:neofelis,代码行数:14,代码来源:main.py

示例4: browseURI

def browseURI(uri):
    osName = System.getProperty("os.name")
    rt = Runtime.getRuntime()
    if osName.startswith("Mac OS"):
        rt.exec('open "%s"' % uri)
    else:
        if osName.startswith("Windows"):
            ProcessBuilder(["cmd", "/C", "start", uri]).start()
        else:
            browsers = ["google-chrome", "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"]
            for b in browsers:
                exists = rt.exec("which %s" % b).getInputStream().read()
                if exists != -1:
                    Runtime.getRuntime().exec("%s %s" % (b, uri))
                    return
开发者ID:adorsk-noaa,项目名称:sasi_gridder,代码行数:15,代码来源:sasi_gridder_jython_gui.py

示例5: launchProgramNoWait

def launchProgramNoWait(args, workingDir = None):
	if workingDir != None and not isinstance(workingDir, File):
		workingDir = File(workingDir)
	process = Runtime.getRuntime().exec(args, None, workingDir)
	OutputThread(process.getInputStream(), System.out).start()
	OutputThread(process.getErrorStream(), System.err).start()
	return process
开发者ID:JuergenBohl,项目名称:fiji,代码行数:7,代码来源:lib.py

示例6: syslog

def syslog( level, message ):
    try:
        ps = Runtime.getRuntime().exec(['logger', '-p', '%s.%s' % (LogConfig.syslogFacility, level), '-t', LogConfig.syslogTag, message])
        return ps.waitFor()
    except:
        log(INFO_, level + " " + message)
        return 0
开发者ID:ammula88,项目名称:WebsphereConfigLib,代码行数:7,代码来源:log.py

示例7: cpu_count

def cpu_count():
    # Python 2.6+
    try:
        import multiprocessing
        return multiprocessing.cpu_count()
    except (ImportError, NotImplementedError):
        pass

    # POSIX
    try:
        import os
        res = int(os.sysconf('SC_NPROCESSORS_ONLN'))

        if res > 0:
            return res
    except (AttributeError, ValueError):
        pass

    # Windows
    try:
        res = int(os.environ['NUMBER_OF_PROCESSORS'])

        if res > 0:
            return res
    except (KeyError, ValueError):
        pass

    # jython
    try:
        from java.lang import Runtime
        runtime = Runtime.getRuntime()
        res = runtime.availableProcessors()
        if res > 0:
            return res
    except ImportError:
        pass

    # BSD
    try:
        import subprocess
        sysctl = subprocess.Popen(['sysctl', '-n', 'hw.ncpu'],
                                  stdout=subprocess.PIPE)
        scStdout = sysctl.communicate()[0]
        res = int(scStdout)

        if res > 0:
            return res
    except (OSError, ValueError):
        pass

    # Linux
    try:
        res = open('/proc/cpuinfo').read().count('processor\t:')

        if res > 0:
            return res
    except IOError:
        pass

    return 0
开发者ID:hayderimran7,项目名称:pycpuinfo,代码行数:60,代码来源:info.py

示例8: cachedBlast

def cachedBlast(fileName, blastLocation, database, eValue, query, pipeline, force = False):
  """
  Performs a blast search using the blastp executable and database in blastLocation on
  the query with the eValue.  The result is an XML file saved to fileName.  If fileName
  already exists the search is skipped.  If remote is true then the search is done remotely.
  """
  if not os.path.isfile(fileName) or force:
    output = open(fileName, "w")
    command = [blastLocation + "/bin/blastp",
               "-evalue", str(eValue),
               "-outfmt", "5",
               "-query", query,
               "-num_threads", str(Runtime.getRuntime().availableProcessors()),
               "-db", database]
    blastProcess = subprocess.Popen(command,
                                    stdout = output)
    while blastProcess.poll() == None:
      if pipeline.exception:
        print "Stopping in blast"
        psProcess = subprocess.Popen(["ps", "aux"], stdout = subprocess.PIPE)
        awkProcess = subprocess.Popen(["awk", "/" + " ".join(command).replace("/", "\\/") + "/"], stdin = psProcess.stdout, stdout = subprocess.PIPE)
        for line in awkProcess.stdout:
          subprocess.Popen(["kill", "-9", re.split(r"\s+", line)[1]])
        output.close()
        raise pipeline.exception
    if blastProcess.poll() != 0:
      raise OSError()
    output.close()
  try:
    return parseBlast(fileName)
  except SAXParseException:
    print 'Retry'
    return cachedBlast(fileName, blastLocation, database, eValue, query, pipeline, True)
开发者ID:jarl-haggerty,项目名称:profelis,代码行数:33,代码来源:utils.py

示例9: cpu_count

def cpu_count():
    """Returns the number of cpus"""
    # jython
    try:
        from java.lang import Runtime
        runtime = Runtime.getRuntime()
        res = runtime.availableProcessors()
        if res > 0:
            return res
    except ImportError:
        pass
    # POSIX
    try:
        res = int(os.sysconf('SC_NPROCESSORS_ONLN'))
        if res > 0:
            return res
    except (AttributeError,ValueError):
        pass
    # Windows
    try:
        res = int(os.environ['NUMBER_OF_PROCESSORS'])
        if res > 0:
            return res
    except (KeyError, ValueError):
        pass
    #Could not get the number of cpus. Return 1
    return 1
开发者ID:URVnutrigenomica-CTNS,项目名称:VHELIBS,代码行数:27,代码来源:multithreading.py

示例10: system

def system(cmd):
	"""
	system(cmd): executes cmd in a shell
	Jpython currently lacks a system command in its os module. This is
	a temporary filler in till a better one comes along the way
	"""
	r= Runtime.getRuntime()
	try:
		p = r.exec(cmd)
		p.waitFor()
	except:
		raise 'Error executing shell command: ' + cmd
	lnr_err = LineNumberReader(InputStreamReader(p.getErrorStream()))
	err_lines = []
	while 1:
		line_err = lnr_err.readLine()
		if not line_err:
			break
		else:
			print line_err
	#
	lnr = LineNumberReader(InputStreamReader(p.getInputStream()))
	#lines = []
	while 1:
		line = lnr.readLine()
		if not line:
			break
		else:
			print line
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:29,代码来源:system.py

示例11: init

 def init(self, config):
     #self._numWorkers = 1
     self._numWorkers = Runtime.getRuntime().availableProcessors()
     self._maximaPath = config["maximaPath"]
     self._threadPool = ThreadPool(self._numWorkers)
     self._maximaPool = Queue.Queue(self._numWorkers)
     for i in range(self._numWorkers):
         self.launchMaximaInstance()
开发者ID:ssmir,项目名称:remote-maxima,代码行数:8,代码来源:service.py

示例12: main

def main():
    global myarg0
    
    try:
        myarg0
    except NameError:
        print "Please input the class you want to open source file"
        return
    
    path = "/home/LiGeng/Desktop/Javasrc"
    
    s = myarg0.split(".")
    for x in s:
        path = ("%s/%s")%(path, x)
    path = ("%s.java") % path
    
    print path
    Runtime.getRuntime().exec(("emacs %s")%path)
开发者ID:mcai4gl2,项目名称:CommandShell,代码行数:18,代码来源:opensource.py

示例13: run

def run(string, args=[], callback=None, callbackOnErr=False):
	def out (exit, call, inp, err):
		return {
			"exitCode": exit,
			"callbackReturn": call,
			"inputArray": inp,
			"errorArray": err
		}

	tmp = File.createTempFile('tmp', None)

	tmp.setExecutable(True)

	writer  = FileOutputStream(tmp);
	writer.write(string)
	writer.flush()
	writer.close()

	try:
		process = Runtime.getRuntime().exec([tmp.getAbsolutePath()] + ([str(i) for i in args] or []))
		process.waitFor()

		inp = BufferedReader(InputStreamReader(process.getInputStream()))
		err = BufferedReader(InputStreamReader(process.getErrorStream()))

		errFlag = False
		inputArray = []
		errorArray = []

		holder = inp.readLine()
		while holder != None:
			print holder
			inputArray += [holder]
			holder = inp.readLine()

		holder = err.readLine()
		while holder != None:
			errFlag = True
			errorArray += [holder]
			holder = err.readLine()

		tmp.delete()

		if errFlag:
			if callback and callbackOnErr: return out(1, callback(out(1, None, inputArray, errorArray)), inputArray, errorArray)
			else: return out(1, None, inputArray, errorArray)
		else:
			if callback: return out(0, callback(out(0, None, inputArray, [])), inputArray, [])
			else: return out(0, None, inputArray, [])
	except Exception as e:
		print str(e)

		tmp.delete()

		if callback and callbackOnErr: return out(3, callback(out(3, None, [], str(e).split("\n"))), [], str(e).split("\n"))
		else: return out(3, None, [], str(e).split("\n"))
开发者ID:wrink,项目名称:Runner,代码行数:56,代码来源:Runner.py

示例14: play

	def play(self):
		num_threads = Runtime.getRuntime().availableProcessors()
		executor = Executors.newFixedThreadPool(num_threads)
		callables = [_Worker(start_pos) for start_pos in self.positions]
		futures = executor.invokeAll(callables)
		# calculate stats
		for future in futures:
			worker = future.get()
			self.process_scores(worker)
		executor.shutdown()
开发者ID:day-me-an,项目名称:scholarship-python,代码行数:10,代码来源:rhul.py

示例15: get_cpu_count

def get_cpu_count():
    cpu_count = 1
    if os.name == 'java':
        from java.lang import Runtime
        runtime = Runtime.getRuntime()
        cpu_count = runtime.availableProcessors()
    else:
        import multiprocessing
        cpu_count = multiprocessing.cpu_count()
    return cpu_count
开发者ID:epam,项目名称:Indigo,代码行数:10,代码来源:indigo-release-libs.py


注:本文中的java.lang.Runtime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。