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


Python FileOutputStream.flush方法代码示例

本文整理汇总了Python中java.io.FileOutputStream.flush方法的典型用法代码示例。如果您正苦于以下问题:Python FileOutputStream.flush方法的具体用法?Python FileOutputStream.flush怎么用?Python FileOutputStream.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.FileOutputStream的用法示例。


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

示例1: getMsgRaw

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
def getMsgRaw(fileName, rs):
    msgID = rs.getLong(1)
    size = rs.getInt(2)
    storageLocation = StoredMessage.stripOldStorageDir(rs.getString(3))
    custID = rs.getInt(4)
    ts = rs.getTimestamp(5)
    receivedDate = None
    if ts is not None:
        receivedDate = Date(ts.getTime)
    msg = StoredMessage(custID, msgID, storageLocation, None, None, receivedDate, 0, 0, 0, 0, None, amPartId, size, size, None, None)

    if msg:
        # do some validation
        if long(msgId) != msg.getMessageId():
            printQueue.append("consumer: ERROR: message ID " + str(msgId) + " not the same as " + str(msg.getMessageId()))

        #print "found message", msgId, "in DB for AM partition"
        msgStream = msg.getEncryptedCompressedContentStream()
        if msgStream:
            out = FileOutputStream(fileName)
            FileUtils.copyStream(msg.getEncryptedCompressedContentStream(), out)
            out.flush()
            out.close()
            #print "found message", msgId, "on disk in AM partition"
            return True
        else:
            printErrorToRemigrate(msgId, " not found on disk for AM partition.")
            return False
    else:
        printErrorToRemigrate(msgId, " not found in db for AM partition.")
        return False
开发者ID:piyush76,项目名称:EMS,代码行数:33,代码来源:dx_script_unsorted.py

示例2: save_example

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
 def save_example(self, label, image_byte_array):
     output_file_name = label + "_" + str(java.lang.System.currentTimeMillis()) + ".png"
     save_path = File(self.dir_path, output_file_name).getCanonicalPath()
     fileos = FileOutputStream(save_path)
     for byte in image_byte_array:
         fileos.write(byte)
     fileos.flush()
     fileos.close()
开发者ID:Jonny-James,项目名称:HandReco,代码行数:10,代码来源:image_example_dir.py

示例3: run

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
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,代码行数:58,代码来源:Runner.py

示例4: getMsgDxDirect

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
def getMsgDxDirect(msgId, sl, fileName):
    storage = DXStorage(sl.getServer(), sl.getUserName(), sl.getPassword(), sl.getDomain(), "email", True, sl.getManagementServer())
    out = FileOutputStream(fileName)
    response = storage.read(str(msgId), out)
    out.flush()
    out.close()

    if not response.isSuccessful():
        printErrorToRemigrate(msgId, " from DX")
        return False
    else:
        return True
开发者ID:piyush76,项目名称:EMS,代码行数:14,代码来源:dx_script_unsorted.py

示例5: getMsgDxDirect

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
def getMsgDxDirect(someMsgId, sl, fileName, threadName):
    printQueue.add("debug("+ threadName +"): entering getMsgDxDirect() with someMsgId = " + str(someMsgId))
    storage = DXStorage(sl.getServer(), sl.getUserName(), sl.getPassword(), sl.getDomain(), "email", True, sl.getManagementServer())
    out = FileOutputStream(fileName)
    response = storage.read(str(someMsgId), out)
    printQueue.add("debug("+ threadName +"): dx response is " + str(response.toString()) + " with someMsgId = " + str(someMsgId))
    out.flush()
    out.close()

    if not response.isSuccessful():
        printErrorToRemigrate(someMsgId, " from DX")
        return False
    else:
        printQueue.add("debug("+ threadName +"): exiting successfully getMsgDxDirect() with someMsgId = " + str(someMsgId))
        return True
开发者ID:piyush76,项目名称:EMS,代码行数:17,代码来源:dx_script_sorted.py

示例6: _get_file

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
 def _get_file(self, source, dest):
     localfile = FileOutputStream(dest)
     tempstats = self._client.stat(source)
     remotefilesize = tempstats.size
     remotefile = self._client.openFileRO(source)
     size = 0
     arraysize = 4096
     data = jarray.zeros(arraysize, "b")
     while True:
         moredata = self._client.read(remotefile, size, data, 0, arraysize)
         datalen = len(data)
         if moredata == -1:
             break
         if remotefilesize - size < arraysize:
             datalen = remotefilesize - size
         localfile.write(data, 0, datalen)
         size += datalen
     self._client.closeFile(remotefile)
     localfile.flush()
     localfile.close()
开发者ID:ktan2020,项目名称:legacy-automation,代码行数:22,代码来源:javaclient.py

示例7: _get_file

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
 def _get_file(self, remote_path, local_path):
     local_file = FileOutputStream(local_path)
     remote_file_size = self._client.stat(remote_path).size
     remote_file = self._client.openFileRO(remote_path)
     array_size_bytes = 4096
     data = jarray.zeros(array_size_bytes, 'b')
     offset = 0
     while True:
         read_bytes = self._client.read(remote_file, offset, data, 0,
                                        array_size_bytes)
         data_length = len(data)
         if read_bytes == -1:
             break
         if remote_file_size - offset < array_size_bytes:
             data_length = remote_file_size - offset
         local_file.write(data, 0, data_length)
         offset += data_length
     self._client.closeFile(remote_file)
     local_file.flush()
     local_file.close()
开发者ID:DeepeshKaushal,项目名称:SSHLibrary,代码行数:22,代码来源:javaclient.py

示例8: getMsgRaw

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
def getMsgRaw(fileName, thisMsg, threadName):
    printQueue.add("debug("+ threadName +"): entering getMsgRaw() with thisMsg = " + str(thisMsg.getMessageId()))
    msgStream = None
    try:
        msgStream = thisMsg.getEncryptedCompressedContentStream()
    except:
        pass
    if msgStream is not None:
        try:
            printQueue.add("debug("+ threadName +"): processing stream with thisMsg = " + str(thisMsg.getMessageId()))
            out = FileOutputStream(fileName)
            FileUtils.copyStream(msgStream, out)
            out.flush()
            out.close()
            printQueue.add("debug("+ threadName +"): done processing stream with thisMsg = " + str(thisMsg.getMessageId()))
            return True
        except:
            printErrorToRemigrate(str(thisMsg.getMessageId()), " error reading file on AM partition.")
        return False
    else:
        printErrorToRemigrate(str(thisMsg.getMessageId()), " not found on disk for AM partition.")
        return False
开发者ID:piyush76,项目名称:EMS,代码行数:24,代码来源:dx_script_sorted.py

示例9: write_image_to_disk

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
 def write_image_to_disk(self, image_path, image):
     os = FileOutputStream(image_path)
     ImageIO.write( image, "png", os )
     os.flush()
     os.close()
开发者ID:Jonny-James,项目名称:HandReco,代码行数:7,代码来源:image_preprocessor.py

示例10: ImagePlus

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
bi = chart.createBufferedImage(600, 400)

imp = ImagePlus('My Plot Title', bi)
imp.show()

####################
# Create SVG image #
####################

#Could be open using inkscape, see https://inkscape.org
#1- Get a DOMImplementation and create an XML document
domImpl = GenericDOMImplementation.getDOMImplementation()
document = domImpl.createDocument(None, 'svg', None)
#2-Create an instance of the SVG Generator
svgGenerator = SVGGraphics2D(document)
#3-Draw the chart in the SVG generator
bounds = Rectangle(600, 400)
chart.draw(svgGenerator, bounds)
#4-Select a folder to save the SVG
dir = IJ.getDirectory('Where should the svg file be saved?')
if(dir!=None):
  #5-Write the SVG file
  svgFile = File(dir + 'test.svg')
  outputStream = FileOutputStream(svgFile)
  out = OutputStreamWriter(outputStream, 'UTF-8')
  svgGenerator.stream(out, True)
  outputStream.flush()
  outputStream.close()
  print 'Saved in %s' % (os.path.join(dir,'test.svg'))
开发者ID:bpavie,项目名称:FijiJythonScripts,代码行数:31,代码来源:JFreeChartDemo_03_SimpleHistogram.py

示例11: str

# 需要导入模块: from java.io import FileOutputStream [as 别名]
# 或者: from java.io.FileOutputStream import flush [as 别名]
         msg = 'Product ' + awipsWanPil + ' failed to be ingested and archived properly. Reason:\n' + str(e)
         resp.setMessage(msg)
         return
 
 attachedFilename = oup.getAttachedFilename()
 attachedFile = oup.getAttachedFile()
 if attachedFilename and attachedFile:
     # spaces will screw up the command line string
     attachedFilename = attachedFilename.replace(" ", "")
     # dealing with a java byte[] so write it out with java
     from java.io import File, FileOutputStream
     attachedFilename = createTargetFile("", OUT_DIR + '/' + attachedFilename)
     f = File(attachedFilename)
     fos = FileOutputStream(f)
     fos.write(attachedFile)
     fos.flush()
     fos.close()
     
 messageIdToAcknowledge = None
 #----------
 # Check if product should be distributed over WAN via NCF
 #----------
 wmoID = contents[0:6]
 splitAddr = address.split(',')
 for addr in splitAddr:
     if addr != '000': # 000 is local only
         _Logger.info("Addressee is " + addr)
         #----------
         # Check if product should be sent to the NWWS for uplink
         #----------
         if (addr.find('NWWSUP') > -1):                
开发者ID:KeithLatteri,项目名称:awips2,代码行数:33,代码来源:handleOUP.py


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