def proxy_build( stream, list ): #because build_dic and build_list is simaliar,so I def a proxy-function while True: ch = stream.next() if ch >= '0' and ch <= '9': #I think ch==0 is not very valid,but just do this. str_len = int(ch) while True: ch = stream.next() if ch == ':': break elif ch >= '0' and ch <= '9': str_len = str_len * 10 + int(ch) else: raise Exception("invalid torrent file") list.append(build_str(stream, str_len)) elif ch == 'l': list.append(build_list(stream)) elif ch == 'i': list.append(build_num(stream)) elif ch == 'd': list.append(build_dic(stream)) elif ch == 'e': break else: raise Exception("invalid torrent file")
def __init__(self, message=None, cause=None): """Constructs a new throwable. Args: message (str): The detail message (which is saved for later retrieval by the getMessage() method). cause (Throwable): The cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.). """ PyException.__init__(self, message) self._cause = cause
def f(): # Try to eliminate as much non-exception stuff as possible: from __builtin__ import Exception e = Exception() for i in xrange(100000): try: raise e except Exception: pass
def proxy_dump(stream, item): if isinstance(item, types.DictionaryType): dump_dic(stream, item) elif isinstance(item, types.ListType): dump_list(stream, item) elif isinstance(item, types.StringType): dump_str(stream, item) elif isinstance(item, types.IntType) or isinstance(item, types.LongType): dump_num(stream, item) else: raise Exception("dump info error")
def get_token(UserName, UserPass, IdpName): PowerShellPath = r'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe' PowerShellCmd = r'C:\\Program Files\\Splunk\\etc\\apps\\waf_ta_idp\\bin\\otc-get-token.ps1' p = subprocess.Popen([ PowerShellPath, '-ExecutionPolicy', 'Bypass', '-file', PowerShellCmd, UserName, UserPass, IdpName ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) TokenID, err = p.communicate() rc = p.returncode if (err): raise Exception('Error: ' + str(err)) return TokenID.strip()
def build_num(stream): #call after symbol 'i' found num = 0 minus = False while True: ch = stream.next() if ch >= '0' and ch <= '9': num = num * 10 + int(ch) elif ch == '-': minus = True elif ch == 'e': break else: raise Exception("invalid torrent file") num = -num if minus else num return num
def __init__(self, description, errorCode): _StandardException.__init__(self, description, errorCode)