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


Python io.IOException方法代码示例

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


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

示例1: test_catch

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def test_catch(self):
        from java.lang import Integer
        from java.lang import RuntimeException, IllegalArgumentException, NumberFormatException
        with self.assertRaises(NumberFormatException):      # Actual class
            Integer.parseInt("hello")
        with self.assertRaises(IllegalArgumentException):   # Parent class
            Integer.parseInt("hello")
        with self.assertRaises(RuntimeException):           # Grandparent class
            Integer.parseInt("hello")

        from java.lang import System
        from java.io import IOException
        try:
            System.getProperty("")
        except IOException:                                 # Unrelated class
            self.fail()
        except NumberFormatException:                       # Child class
            self.fail()
        except IllegalArgumentException:                    # Actual class
            pass 
开发者ID:chaquo,项目名称:chaquopy,代码行数:22,代码来源:test_exception.py

示例2: execute

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def execute( self, cmd ):
        """Execute cmd in a shell, and return the java.lang.Process instance.
        Accepts either a string command to be executed in a shell,
        or a sequence of [executable, args...].
        """
        shellCmd = self._formatCmd( cmd )

        env = self._formatEnvironment( self.environment )
        try:
            p = Runtime.getRuntime().exec( shellCmd, env, File(os.getcwd()) )
            return p
        except IOException, ex:
            raise OSError(
                0,
                "Failed to execute command (%s): %s" % ( shellCmd, ex )
                )

    ########## utility methods 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:20,代码来源:javashell.py

示例3: _extract_certs_for_paths

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def _extract_certs_for_paths(paths, password=None):
    # Go from Bouncy Castle API to Java's; a bit heavyweight for the Python dev ;)
    key_converter = JcaPEMKeyConverter().setProvider("BC")
    cert_converter = JcaX509CertificateConverter().setProvider("BC")
    certs = []
    private_key = None
    for path in paths:
        err = None
        with open(path) as f:
            # try to load the file as keystore file first
            try:
                _certs = _extract_certs_from_keystore_file(f, password)
                certs.extend(_certs)
            except IOException as err:
                pass  # reported as 'Invalid keystore format'
        if err is not None:  # try loading pem version instead
            with open(path) as f:
                _certs, _private_key = _extract_cert_from_data(f, password, key_converter, cert_converter)
                private_key = _private_key if _private_key else private_key
                certs.extend(_certs)
    return certs, private_key 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:23,代码来源:_sslcerts.py

示例4: execute

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def execute( self, cmd ):
        """Execute cmd in a shell, and return the java.lang.Process instance.
        Accepts either a string command to be executed in a shell,
        or a sequence of [executable, args...].
        """
        shellCmd = self._formatCmd( cmd )

        env = self._formatEnvironment( self.environment )
        try:
            p = Runtime.getRuntime().exec( shellCmd, env, File(os.getcwdu()) )
            return p
        except IOException, ex:
            raise OSError(
                0,
                "Failed to execute command (%s): %s" % ( shellCmd, ex )
                )

    ########## utility methods 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:20,代码来源:javashell.py

示例5: connectToJMX

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def connectToJMX(args):
    # Basic JMX connection, always required
    trust_managers = array([TrustAllX509TrustManager()], TrustManager)

    sc = SSLContext.getInstance("SSL")
    sc.init(None, trust_managers, None)
    SSLContext.setDefault(sc)
    jmx_url = JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + args.targetHost + ":" + args.targetPort + "/jmxrmi")
    print "[+] Connecting to: " + str(jmx_url)
    try:
        jmx_connector = JMXConnectorFactory.connect(jmx_url)
        print "[+] Connected: " + str(jmx_connector.getConnectionId())
        bean_server = jmx_connector.getMBeanServerConnection()
        return bean_server
    except IOException:
        print "[-] Error: Can't connect to remote service"
        sys.exit(-1)
##########

### INSTALL MODE ### 
开发者ID:siberas,项目名称:sjet,代码行数:22,代码来源:sjet.py

示例6: throws_java

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def throws_java(msg="abc olé 中文"):
    from java.io import IOException
    raise IOException(msg) 
开发者ID:chaquo,项目名称:chaquopy,代码行数:5,代码来源:pyobjecttest.py

示例7: _excmd

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def _excmd(self, sshcmd):
        '''
        return (connected_ok, response_array)
        '''        
        connected_ok=True
        resp = []        
        try:
            conn = Connection(self.hostname)
            conn.connect()
            self.logger.info('ssh connection created.')
            isAuthenticated = conn.authenticateWithPassword(self.user, self.password)
            if not isAuthenticated:
                connected_ok=False
                self.logger.error('ssh failed to authenticatd.')
            else:
                self.logger.info('ssh authenticated.')
                sess = conn.openSession()
                
                self.logger.info('ssh session created.')
                sess.execCommand(sshcmd)
                self.logger.info('ssh command issued. cmd is %s'%sshcmd)
    
                stdout = StreamGobbler(sess.getStdout())
                br = BufferedReader(InputStreamReader(stdout))
                while True:
                    line = br.readLine()
                    if line is None:
                        break
                    else :
                        resp.append(line)
                self.logger.warning('ssh command output: '%resp)
        except IOException ,ex:
            connected_ok=False
            #print "oops..error,", ex            
            self.logger.error('ssh exception: %s'% ex) 
开发者ID:harryliu,项目名称:edwin,代码行数:37,代码来源:__init__.py

示例8: connectToHub

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def connectToHub(adr, port, pollMillis, user, password):
	"""connectToHub(adr, port, pollMillis, user, password) connects to a specific non-legacy hub """
	print("Connecting")

	try:
		iofun.connectToHub(adr, port, pollMillis, user, password)
		
		print("Connected")
	except IOException as e:
		err(e.getMessage()) 
开发者ID:pfrommerd,项目名称:insteon-terminal,代码行数:12,代码来源:console_commands.py

示例9: connectToLegacyHub

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def connectToLegacyHub(adr, port):
	"""connectToLegacyHub(adr, port) connects to a specific legacy hub"""
	print("Connecting")

	try:
		iofun.connectToLegacyHub(adr, port)
		
		print("Connected")
	except IOException as e:
		err(e.getMessage()) 
开发者ID:pfrommerd,项目名称:insteon-terminal,代码行数:12,代码来源:console_commands.py

示例10: connectToSerial

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import IOException [as 别名]
def connectToSerial(dev):
	"""connectToSerial("/path/to/device") connects to specific serial port """
	print("Connecting")

	try:
		iofun.connectToSerial(dev)
		
		print("Connected")
	except IOException as e:
		err(e.getMessage()) 
开发者ID:pfrommerd,项目名称:insteon-terminal,代码行数:12,代码来源:console_commands.py


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