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


Python FileInputStream.close方法代码示例

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


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

示例1: addPropertiesFromFile

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def addPropertiesFromFile(props, filename, site_home):
    addProps = Properties()
    input = FileInputStream(filename)
    addProps.load(input)
    input.close()

    baseFileList = addProps.getProperty('base')
    
    if not baseFileList is None:
        baseFiles = baseFileList.split(",")
        for baseFile in baseFiles:
            baseFileResolved=getBaseFile(baseFile, site_home)
            if baseFileResolved=='':
                log.error('Configuration inherits from properties file that does not exist: ' + baseFile)
                log.info('Suggested Fix: Update the base property within ' + filename + ' to the correct file path')
                sys.exit()
            log.debug('Attempting to load properties from ' + baseFile)
            addPropertiesFromFile(addProps, baseFileResolved, site_home)
            addProps.remove('base')

    enum = addProps.keys()
    while enum.hasMoreElements():
        key = enum.nextElement()
        if props.getProperty(key) is None:
            props.setProperty(key, addProps.getProperty(key))
            addDataLinage(key,filename,addProps.getProperty(key))
开发者ID:Integral-Technology-Solutions,项目名称:ConfigNOW,代码行数:28,代码来源:config_loader.py

示例2: process

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
    def process(self):
        #We'll return a list with 1 JsonSimple object
        jsonList = []
        data = None
        reader = None
        inStream = None
        document = None
        
        # Run the XML through our parser
        try:
            inStream = FileInputStream(File(self.file))
            reader = InputStreamReader(inStream, "UTF-8")
            document = self.saxReader.read(reader)
        # Parse fails
        except:
            raise
        # Close our file access objects
        finally:
            if reader is not None:
                reader.close()
            if inStream is not None:
                inStream.close()

        # Now go looking for all our data
        data = JsonObject()
        data.put("workflow_source", "XML Alert") # Default
        self.__mapXpathToFields(document, self.map, data)
        
        if data is None:
            return None
        
        jsonList.append(JsonSimple(data))
        return jsonList
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:35,代码来源:XMLAlertHandler.py

示例3: process

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
    def process(self):
        '''Read the XML file and map xpath items to metadata
        Return a list with 1 JsonSimple object (at most)
        '''
        jsonList = []
        data = None
        reader = None
        inStream = None
        document = None
        
        # Run the XML through our parser
        try:
            inStream = FileInputStream(File(self.file))
            reader = InputStreamReader(inStream, "UTF-8")
            document = self.saxReader.read(reader)
        # Parse fails
        except:
            raise
        # Close our file access objects
        finally:
            if reader is not None:
                reader.close()
            if inStream is not None:
                inStream.close()

        # Now go looking for all our data
        data = self.getNewJsonObject()
        self.__mapXpathToFields(document, self.map, data)
        
        if data is None:
            return None
        
        jsonList.append(JsonSimple(data))
        return jsonList
开发者ID:lloyd-h,项目名称:redbox,代码行数:36,代码来源:XMLAlertHandler.py

示例4: transformReport

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
class report_generation:
  'Test Report Generation'

  def transformReport(self,stylesheet,xml,output,params):
    from java.io import FileInputStream
    from java.io import FileOutputStream
    from java.io import ByteArrayOutputStream

    from javax.xml.transform import TransformerFactory
    from javax.xml.transform.stream import StreamSource
    from javax.xml.transform.stream import StreamResult

    self.xsl   = FileInputStream("%s" % stylesheet)
    self.xml   = FileInputStream("%s" % xml)
    self.html  = FileOutputStream("%s" % output)

    try:
      self.xslSource   = StreamSource(self.xsl)
      self.tfactory    = TransformerFactory.newInstance()
      self.xslTemplate = self.tfactory.newTemplates(self.xslSource)
      self.transformer = self.xslTemplate.newTransformer()

      self.source = StreamSource(self.xml)
      self.result = StreamResult(self.html)

      for self.key,self.value in params.items():
        self.transformer.setParameter(self.key, self.value)

      self.transformer.transform(self.source, self.result)

    finally:
      self.xsl.close()
      self.xml.close()
      self.html.close()
开发者ID:SmarterApp,项目名称:IM_OpenDJ,代码行数:36,代码来源:common.py

示例5: intialize

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def intialize():
        global domainProps;
        global userConfigFile;
        global userKeyFile;

        # test arguments
        if len(sys.argv) != 3:
                print 'Usage:  stopDomain.sh  <default.properties_file> <property_file>';
                exit();

				
		print 'Starting the initialization process';                                                                                                                                                    

    	try:
    		domainProps = Properties()

		# load DEFAULT properties                                                                                                                                                                               
		input = FileInputStream(sys.argv[1])
		domainProps.load(input)
		input.close()
			
		
		# load properties and overwrite defaults
		input = FileInputStream(sys.argv[2])
		domainProps.load(input)
		input.close()

                userConfigFile = File(sys.argv[2]).getParent()+'/'+domainProps.getProperty('domainName')+'.userconfig'
                userKeyFile = File(sys.argv[2]).getParent()+'/'+domainProps.getProperty('domainName')+'.userkey'

        except:
                print 'Cannot load properties  !';
                exit();

        print 'Initialization completed';
开发者ID:eshanaka,项目名称:Weblogic-Automation,代码行数:37,代码来源:stopDomain.py

示例6: load_redback_registry

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def load_redback_registry():
    reg = Properties()
    reg_file = 'redback.properties'
    if os.path.isfile(reg_file):
        reg_fd = FileInputStream(reg_file)
        reg.load(reg_fd)
        reg_fd.close()
    return reg
开发者ID:Integral-Technology-Solutions,项目名称:ConfigNOW,代码行数:10,代码来源:redback.py

示例7: loadProperties

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def loadProperties(fileName):
	properties = Properties()
	input = FileInputStream(fileName)
	properties.load(input)
	input.close()
	result= {}
	for entry in properties.entrySet(): result[entry.key] = entry.value
	return result
开发者ID:osanchezhuerta,项目名称:weblogicjmsclustered-module,代码行数:10,代码来源:weblogicjms-cluster.py

示例8: read_versions

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
 def read_versions(self):
     versionsProperties = Properties()
     fin = FileInputStream(self.versionsFileName)
     versionsProperties.load(fin)
     scriptVersion = versionsProperties.getProperty("script")
     toolsVersion = versionsProperties.getProperty("tools")
     fin.close()
     return scriptVersion, toolsVersion
开发者ID:alex85k,项目名称:qat_script,代码行数:10,代码来源:config_reader.py

示例9: getPushProperties

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def getPushProperties():
    pushProperties          = HashMap()
    pushPropertiesFileStr   = "%s%s%s" % (adapterConfigBaseDir, FILE_SEPARATOR, PUSH_PROPERTIES_FILE)
    properties              = Properties()
    debugMode               = 0
    sortCSVFields           = ""
    smartUpdateIgnoreFields = ""
    testConnNameSpace       = "BMC.CORE"
    testConnClass           = "BMC_ComputerSystem"
    try:
        logger.debug("Checking push properties file for debugMode [%s]" % pushPropertiesFileStr)
        fileInputStream = FileInputStream(pushPropertiesFileStr)
        properties.load(fileInputStream)

        # Property: debugMode
        try:
            debugModeStr    = properties.getProperty("debugMode")
            if isNoneOrEmpty(debugModeStr) or string.lower(string.strip(debugModeStr)) == 'false':
                debugMode   = 0
            elif string.lower(string.strip(debugModeStr)) == 'true':
                debugMode   = 1
        except:
            logger.debugException("Unable to read debugMode property from push.properties")

        if debugMode:
            logger.debug("Debug mode = TRUE. XML data pushed to Remedy/Atrium will be persisted in the directory: %s" % adapterResBaseDir)
        else:
            logger.debug("Debug mode = FALSE")

        # Property: smartUpdateIgnoreFields
        try:
            smartUpdateIgnoreFields = properties.getProperty("smartUpdateIgnoreFields")
        except:
            logger.debugException("Unable to read smartUpdateIgnoreFields property from push.properties")

        # Property: sortCSVFields
        try:
            sortCSVFields = properties.getProperty("sortCSVFields")
        except:
            logger.debugException("Unable to read sortCSVFields property from push.properties")

        # Property: testConnNameSpace
        try:
            testConnNameSpace = properties.getProperty("testConnNameSpace")
        except:
            logger.debugException("Unable to read testConnNameSpace property from push.properties")

        # Property: testConnClass
        try:
            testConnClass = properties.getProperty("testConnClass")
        except:
            logger.debugException("Unable to read testConnClass property from push.properties")

        fileInputStream.close()
    except:
        logger.debugException("Unable to process %s file." % PUSH_PROPERTIES_FILE)

    return debugMode, smartUpdateIgnoreFields, sortCSVFields, testConnNameSpace, testConnClass
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:60,代码来源:pushToAtrium.py

示例10: intialize

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def intialize():
        global domainLocation;
        global jvmLocation;
        global domainTemplate;
        global domainProps;
        global adminUserName;
        global adminPassword;
        global userConfigFile;
        global userKeyFile;

        # test arguments
        if len(sys.argv) != 6:
                print 'Usage:  createDomain.sh <template-file> <default.properties_file> <property_file> <wls_username> <wls_password>';
                exit();

        print 'Starting the initialization process';

        domainTemplate = sys.argv[1];
        print 'Using Domain Template: ' + domainTemplate;
        try:
                domainProps = Properties()

                # load DEFAULT properties
                # print 'Reading default properties from '+sys.argv[2];
                input = FileInputStream(sys.argv[2])
                domainProps.load(input)
                input.close()


                # load properties and overwrite defaults
                input = FileInputStream(sys.argv[3])
                domainProps.load(input)
                input.close()

                adminUserName = sys.argv[4];
                adminPassword = sys.argv[5];

		# Files for generating secret key

		userConfigFile = File(sys.argv[3]).getParent()+'/'+domainProps.getProperty('domainName')+'.userconfig'
                print userConfigFile
		userKeyFile = File(sys.argv[3]).getParent()+'/'+domainProps.getProperty('domainName')+'.userkey'
	        print userKeyFile			

                domainLocation = domainProps.getProperty('domainsDirectory') + pathSeparator + domainProps.getProperty('domainName');
                print 'Domain Location: ' + domainLocation;
                if len(domainProps.getProperty('jvmLocation')) == 0:
                        print 'JVM location property not defined - cancel creation !';
                        exit();
                print 'JVM Location: ' + domainProps.getProperty('jvmLocation');

        except:
                dumpStack()
                print 'Cannot initialize creation process !';
                exit();

        print 'Initialization completed';
开发者ID:eshanaka,项目名称:Weblogic-Automation,代码行数:59,代码来源:createDomain.py

示例11: readBinaryFile

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
 def readBinaryFile(cls, rootFile):
     """ generated source for method readBinaryFile """
     in_ = FileInputStream(rootFile)
     out = ByteArrayOutputStream()
     #  Transfer bytes from in to out
     buf = [None]*1024
     while in_.read(buf) > 0:
         out.write(buf)
     in_.close()
     return out.toByteArray()
开发者ID:hobson,项目名称:ggpy,代码行数:12,代码来源:LocalGameRepository.py

示例12: read_tools_list

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def read_tools_list(tmpToolsListFile):
    """Read the tools names and tools data urls
       from the downlaoded tools list
    """
    properties = Properties()
    fin = FileInputStream(tmpToolsListFile)
    properties.load(fin)
    toolsRefs = properties.getProperty("tools.list").split("|")
    fin.close()
    return toolsRefs
开发者ID:floscher,项目名称:qat_script,代码行数:12,代码来源:update_checker.py

示例13: loadPropertiesFromFile

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def loadPropertiesFromFile(filename,props):
    newprops=Properties()
    inputstr = FileInputStream(filename)
    newprops.load(inputstr)
    inputstr.close()
    enum = newprops.keys()
    while enum.hasMoreElements():
        key = enum.nextElement()
        if props.getProperty(key) is None:
            props.setProperty(key, newprops.getProperty(key))
    return props
开发者ID:Integral-Technology-Solutions,项目名称:ConfigNOW,代码行数:13,代码来源:runexternal.py

示例14: run

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
def run():
    versionFile = File(os.getcwd(), 'core/resources/version.properties')
    log.debug('Checking if ' + str(versionFile) + ' exists')
    if os.path.exists(str(versionFile)):
        versionProperties = Properties()
        input = FileInputStream(versionFile)
        versionProperties.load(input)
        input.close()
        versionInfo=getVersionInfo(versionProperties)
    else:
    	versionInfo=getVersionInfo(None)
    log.info('this')
    log.info(versionInfo)
开发者ID:Integral-Technology-Solutions,项目名称:ConfigNOW,代码行数:15,代码来源:version.py

示例15: test_read_file

# 需要导入模块: from java.io import FileInputStream [as 别名]
# 或者: from java.io.FileInputStream import close [as 别名]
    def test_read_file(self):
        from java.io import FileInputStream
        from java.lang import String

        filename = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'data/read_file.txt')
        fin = FileInputStream(filename)
        ar = jarray(20, JBYTE_ID)
        count = fin.read(ar)
        fin.close()
        s = String(ar, 0, count)
        self.assertEqual(str(s).strip(), 'aewrv3v')
开发者ID:mrj0,项目名称:jep,代码行数:15,代码来源:test_array.py


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