本文整理汇总了Python中sys.exc_info函数的典型用法代码示例。如果您正苦于以下问题:Python exc_info函数的具体用法?Python exc_info怎么用?Python exc_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exc_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: sources
def sources(self, url, hostDict, hostprDict):
try:
sources = []
if url == None: return sources
year = url['year']
h = {'User-Agent': client.randomagent()}
title = cleantitle.geturl(url['title']).replace('-', '+')
url = urlparse.urljoin(self.base_link, self.search_link % title)
r = requests.get(url, headers=h)
r = BeautifulSoup(r.text, 'html.parser').find('div', {'class': 'item'})
r = r.find('a')['href']
r = requests.get(r, headers=h)
r = BeautifulSoup(r.content, 'html.parser')
quality = r.find('span', {'class': 'calidad2'}).text
url = r.find('div', {'class':'movieplay'}).find('iframe')['src']
if not quality in ['1080p', '720p']:
quality = 'SD'
valid, host = source_utils.is_host_valid(url, hostDict)
sources.append({'source': host, 'quality': quality, 'language': 'en', 'url': url, 'direct': False, 'debridonly': False})
return sources
except:
print("Unexpected error in Furk Script: check_api", sys.exc_info()[0])
exc_type, exc_obj, exc_tb = sys.exc_info()
print(exc_type, exc_tb.tb_lineno)
return sources
开发者ID:varunrai,项目名称:repository.magicality,代码行数:28,代码来源:movie4kis.py
示例2: testMarkExceptionChange
def testMarkExceptionChange(self):
state = State(self.tempdir, 'repo')
state._gmtime = lambda: (2012, 8, 13, 12, 15, 0, 0, 0, 0)
state.markStarted()
try:
raise ValueError("the same exception")
except:
exType, exValue, exTraceback = exc_info()
state.markException(exType, exValue, "9999/9999/9999/9999")
state.close()
self.assertEquals({"changedate": "2012-08-13 12:15:00", "status": "Error", "message": "the same exception"}, jsonLoad(open(join(self.tempdir, 'repo.running'))))
state = State(self.tempdir, 'repo')
state._gmtime = lambda: (2012, 8, 13, 12, 17, 0, 0, 0, 0)
state.markStarted()
try:
raise ValueError("the same exception")
except:
exType, exValue, exTraceback = exc_info()
state.markException(exType, exValue, "9999/9999/9999/9999")
state.close()
self.assertEquals({"changedate": "2012-08-13 12:15:00", "status": "Error", "message": "the same exception"}, jsonLoad(open(join(self.tempdir, 'repo.running'))))
state = State(self.tempdir, 'repo')
state._gmtime = lambda: (2012, 8, 13, 12, 19, 0, 0, 0, 0)
state.markStarted()
try:
raise ValueError("the other exception")
except:
exType, exValue, exTraceback = exc_info()
state.markException(exType, exValue, "9999/9999/9999/9999")
state.close()
self.assertEquals({"changedate": "2012-08-13 12:19:00", "status": "Error", "message": "the other exception"}, jsonLoad(open(join(self.tempdir, 'repo.running'))))
开发者ID:seecr,项目名称:meresco-harvester,代码行数:33,代码来源:statetest.py
示例3: __init__
def __init__(self, body=None, delivery_tag=None,
content_type=None, content_encoding=None, delivery_info=None,
properties=None, headers=None, postencode=None,
accept=None, channel=None, **kwargs):
delivery_info = {} if not delivery_info else delivery_info
self.errors = [] if self.errors is None else self.errors
self.channel = channel
self.delivery_tag = delivery_tag
self.content_type = content_type
self.content_encoding = content_encoding
self.delivery_info = delivery_info
self.headers = headers or {}
self.properties = properties or {}
self._decoded_cache = None
self._state = 'RECEIVED'
self.accept = accept
compression = self.headers.get('compression')
if not self.errors and compression:
try:
body = decompress(body, compression)
except Exception:
self.errors.append(sys.exc_info())
if not self.errors and postencode and isinstance(body, text_t):
try:
body = body.encode(postencode)
except Exception:
self.errors.append(sys.exc_info())
self.body = body
开发者ID:celery,项目名称:kombu,代码行数:30,代码来源:message.py
示例4: nested
def nested(*managers):
exits = []
vars = []
exc = (None, None, None)
try:
for mgr in managers:
exit = mgr.__exit__
enter = mgr.__enter__
vars.append(enter())
exits.append(exit)
yield vars
except:
exc = sys.exc_info()
finally:
while exits:
exit = exits.pop()
try:
if exit(*exc):
exc = (None, None, None)
except:
exc = sys.exc_info()
if exc != (None, None, None):
# PEP 3109
e = exc[0](exc[1])
e.__traceback__ = e[2]
raise e
开发者ID:bpc,项目名称:wand,代码行数:26,代码来源:compat.py
示例5: main
def main():
#for p in range(1,intGetMaxPage +1):
#soup = BeautifulSoup()
try:
resp = urllib2.urlopen(getUrl,timeout=10)
soup = BeautifulSoup(resp)
soup = soup.find('div' ,{'id':'prodlist'})
#for k in soup.findAll("div", {'class': 'p-name'}): # 抓< div class='p=name'>...< /div>
for k in soup.findAll('a', href=True):
try:
url = k.get('href')
print k.text
print url
page_url = homeUrl + url
print page_url
resp_text_page = urllib2.urlopen(homeUrl + url, timeout=10)
soup_text_page = BeautifulSoup(resp_text_page)
contextPageUrl(soup_text_page,page_url)
except:
print "Unexpected error:", sys.exc_info()[0]
print "Unexpected error:", sys.exc_info()[1]
continue
except:
#continue
print "Unexpected error:", sys.exc_info()[0]
print "Unexpected error:", sys.exc_info()[1]
pass
开发者ID:choakai,项目名称:thesis,代码行数:33,代码来源:Crawler_PPT_Politic.py
示例6: tokenize
def tokenize(n, tagsDict):
cleaner = Cleaner()
cleaner.javascript = True
cleaner.style = True
i = 0
df = pandas.DataFrame(columns=[list(tagsDict)])
while (i < n):
allVector = {}
if (os.path.isfile("spam/%d.txt" % i)):
try:
for word in tagsDict:
allVector[word] = 0
readInFile = open("spam/%d.txt" % i)
content = readInFile.read()
noSymbols = re.sub('[^A-Za-z-]+', ' ', content.lower()) # noSymbols is stripped of symbols
allCopy = noSymbols.split() # allCopy is the set of words without symbols
for tag in allCopy:
df.ix[i[tag]] = df.ix[i[tag]] + 1
df.ix[i['isSpam']] = 'spam'
except Exception, err:
print traceback.format_exc()
print sys.exc_info()[0]
i = i + 1
开发者ID:0x0mar,项目名称:Fishing-for-Phishing,代码行数:26,代码来源:tokenizer2.py
示例7: _marshaled_dispatch
def _marshaled_dispatch(self, address, data):
params, method = xmlrpclib.loads(data)
if not self.instance.check_acls(address, method):
raise XMLRPCACLCheckException
try:
if '.' not in method:
params = (address, ) + params
response = self.instance._dispatch(method, params, self.funcs)
# py3k compatibility
if type(response) not in [bool, str, list, dict]:
response = (response.decode('utf-8'), )
else:
response = (response, )
raw_response = xmlrpclib.dumps(response, methodresponse=True,
allow_none=self.allow_none,
encoding=self.encoding)
except xmlrpclib.Fault:
fault = sys.exc_info()[1]
raw_response = xmlrpclib.dumps(fault, methodresponse=True,
allow_none=self.allow_none,
encoding=self.encoding)
except:
err = sys.exc_info()
self.logger.error("Unexpected handler error", exc_info=1)
# report exception back to server
raw_response = xmlrpclib.dumps(
xmlrpclib.Fault(1, "%s:%s" % (err[0].__name__, err[1])),
methodresponse=True, allow_none=self.allow_none,
encoding=self.encoding)
return raw_response
开发者ID:AlexanderS,项目名称:bcfg2,代码行数:30,代码来源:SSLServer.py
示例8: sendData
def sendData(sock, data):
"""
Send some data over a socket.
Some systems have problems with ``sendall()`` when the socket is in non-blocking mode.
For instance, Mac OS X seems to be happy to throw EAGAIN errors too often.
This function falls back to using a regular send loop if needed.
"""
if sock.gettimeout() is None:
# socket is in blocking mode, we can use sendall normally.
try:
sock.sendall(data)
return
except socket.timeout:
raise TimeoutError("sending: timeout")
except socket.error:
x=sys.exc_info()[1]
raise ConnectionClosedError("sending: connection lost: "+str(x))
else:
# Socket is in non-blocking mode, use regular send loop.
retrydelay=0.0
while data:
try:
sent = sock.send(data)
data = data[sent:]
except socket.timeout:
raise TimeoutError("sending: timeout")
except socket.error:
x=sys.exc_info()[1]
err=getattr(x, "errno", x.args[0])
if err not in ERRNO_RETRIES:
raise ConnectionClosedError("sending: connection lost: "+str(x))
time.sleep(0.00001+retrydelay) # a slight delay to wait before retrying
retrydelay=__nextRetrydelay(retrydelay)
开发者ID:killkill,项目名称:Pyro4,代码行数:33,代码来源:socketutil.py
示例9: handle
def handle(self, *args, **options):
def get_tmdb_ids():
def get_args():
if args:
movie_id = args[0]
try:
batch = args[1]
except:
batch = False
else:
movie_id = None
batch = None
return movie_id, batch
movie_id, batch = get_args()
movies = Movie.objects.all()
if movie_id is not None:
if batch:
movies = movies.filter(pk__gte=movie_id)
else:
movies = movies.filter(pk=movie_id)
return movies.values_list("tmdb_id", flat=True)
for tmdb_id in get_tmdb_ids():
try:
print add_movie_to_db(tmdb_id, True)
except TMDBRequestInvalid:
print "Movie id - %d" % Movie.objects.get(tmdb_id=tmdb_id).id
print sys.exc_info()[1]
开发者ID:TonyGu423,项目名称:movies,代码行数:30,代码来源:update_movie_data.py
示例10: create_pplan
def create_pplan(self, topologyName, pplan):
""" create physical plan """
if not pplan or not pplan.IsInitialized():
raise StateException("Physical Plan protobuf not init properly",
StateException.EX_TYPE_PROTOBUF_ERROR), None, sys.exc_info()[2]
path = self.get_pplan_path(topologyName)
LOG.info("Adding topology: {0} to path: {1}".format(
topologyName, path))
pplanString = pplan.SerializeToString()
try:
self.client.create(path, value=pplanString, makepath=True)
return True
except NoNodeError:
raise StateException("NoNodeError while creating pplan",
StateException.EX_TYPE_NO_NODE_ERROR), None, sys.exc_info()[2]
except NodeExistsError:
raise StateException("NodeExistsError while creating pplan",
StateException.EX_TYPE_NODE_EXISTS_ERROR), None, sys.exc_info()[2]
except ZookeeperError:
raise StateException("Zookeeper while creating pplan",
StateException.EX_TYPE_ZOOKEEPER_ERROR), None, sys.exc_info()[2]
except Exception:
# Just re raise the exception.
raise
开发者ID:qingniufly,项目名称:heron,代码行数:25,代码来源:zkstatemanager.py
示例11: create_execution_state
def create_execution_state(self, topologyName, executionState):
""" create execution state """
if not executionState or not executionState.IsInitialized():
raise StateException("Execution State protobuf not init properly",
StateException.EX_TYPE_PROTOBUF_ERROR), None, sys.exc_info()[2]
path = self.get_execution_state_path(topologyName)
LOG.info("Adding topology: {0} to path: {1}".format(
topologyName, path))
executionStateString = executionState.SerializeToString()
try:
self.client.create(path, value=executionStateString, makepath=True)
return True
except NoNodeError:
raise StateException("NoNodeError while creating execution state",
StateException.EX_TYPE_NO_NODE_ERROR), None, sys.exc_info()[2]
except NodeExistsError:
raise StateException("NodeExistsError while creating execution state",
StateException.EX_TYPE_NODE_EXISTS_ERROR), None, sys.exc_info()[2]
except ZookeeperError:
raise StateException("Zookeeper while creating execution state",
StateException.EX_TYPE_ZOOKEEPER_ERROR), None, sys.exc_info()[2]
except Exception:
# Just re raise the exception.
raise
开发者ID:qingniufly,项目名称:heron,代码行数:25,代码来源:zkstatemanager.py
示例12: run
def run(self):
"""Starts or resumes the generator, running until it reaches a
yield point that is not ready.
"""
if self.running or self.finished:
return
try:
self.running = True
while True:
future = self.future
if not future.done():
return
self.future = None
try:
orig_stack_contexts = stack_context._state.contexts
exc_info = None
try:
value = future.result()
except Exception:
self.had_exception = True
exc_info = sys.exc_info()
if exc_info is not None:
yielded = self.gen.throw(*exc_info)
exc_info = None
else:
yielded = self.gen.send(value)
if stack_context._state.contexts is not orig_stack_contexts:
self.gen.throw(
stack_context.StackContextInconsistentError(
'stack_context inconsistency (probably caused '
'by yield within a "with StackContext" block)'))
except (StopIteration, Return) as e:
self.finished = True
self.future = _null_future
if self.pending_callbacks and not self.had_exception:
# If we ran cleanly without waiting on all callbacks
# raise an error (really more of a warning). If we
# had an exception then some callbacks may have been
# orphaned, so skip the check in that case.
raise LeakedCallbackError(
"finished without waiting for callbacks %r" %
self.pending_callbacks)
self.result_future.set_result(_value_from_stopiteration(e))
self.result_future = None
self._deactivate_stack_context()
return
except Exception:
self.finished = True
self.future = _null_future
self.result_future.set_exc_info(sys.exc_info())
self.result_future = None
self._deactivate_stack_context()
return
if not self.handle_yield(yielded):
return
finally:
self.running = False
开发者ID:heewa,项目名称:tornado,代码行数:60,代码来源:gen.py
示例13: editar_campania
def editar_campania(cid, nombre_empresa, ruc, text_content, fecha_publicacion, img_banner, url_banner, subject_email):
m = get_mailchimp_api()
campania = mailchimp.Campaigns(m)
direccion = get_lan_ip()
img_banner = img_banner[1:]
try:
result = campania.update(cid, 'content',
{'sections': {
'banner_img': '<a target="_blank" href="{0}"><img src="http://{1}/{2}" /></a>'.format(url_banner, direccion, img_banner),
'text_content': text_content,
}})
except:
print ('Error al editar campania:', sys.exc_info()[0])
try:
result = campania.update(cid, 'options', {'list_id': '25be04f5d4',
'subject': subject_email,
'from_email': '[email protected]',
'from_name': 'Innobee - Facturación electrónica',
'to_name': 'Subscriptores Innobee Portal',
'template_id': 111625,
'title': 'campania---{0}---{1}'.format(nombre_empresa, hoy),
'tracking': {'opens': True, 'html_clicks': True, 'text_clicks': True}
},)
print result
campania.schedule(cid, fecha_publicacion)
except:
print ('Error al editar campania:', sys.exc_info()[0])
开发者ID:rraidel89,项目名称:portal,代码行数:28,代码来源:mail_chimp.py
示例14: _handle_request_exception
def _handle_request_exception(self, e):
if not isinstance(e, Interruption):
return tornado.web.RequestHandler._handle_request_exception(self, e)
# copy of tornado.web.RequestHandler._handle_request_exception
# but remove exception report
if isinstance(e, tornado.web.Finish):
# Not an error; just finish the request without logging.
if not self._finished:
self.finish()
return
# this is not an error
# do not report exception
# self.log_exception(*sys.exc_info())
if self._finished:
# Extra errors after the request has been finished should
# be logged, but there is no reason to continue to try and
# send a response.
return
if isinstance(e, tornado.web.HTTPError):
if e.status_code not in tornado.httputil.responses and not e.reason:
gen_log.error("Bad HTTP status code: %d", e.status_code)
else:
self.send_error(e.status_code, exc_info=sys.exc_info())
return
self.send_error(500, exc_info=sys.exc_info())
开发者ID:SakuraSa,项目名称:TenhouLoggerX,代码行数:28,代码来源:Page.py
示例15: write
def write(self,text,last=False):
try:
raise "Dummy"
except:
lineText = str(sys.exc_info()[2].tb_frame.f_back.f_lineno)
codeObject = sys.exc_info()[2].tb_frame.f_back.f_code
fileName = codeObject.co_filename
funcName = codeObject.co_name
if not hasattr(self,'text'):
self.text=""
self.text+=text
lines=self.text.split("\n")
linestoprint=lines if last else lines[:-1]
self.text=lines[-1]
for l in linestoprint:
r=self.func(l.strip(),fileName,lineText,funcName)
if r.strip()!="":
self.get_origOut().write(r+"\n")
开发者ID:volodymyrss,项目名称:data-analysis,代码行数:26,代码来源:printhook.py
示例16: exception_info
def exception_info(current_filename=None, index=-1):
"Analizar el traceback y armar un dict con la info amigable user-friendly"
# guardo el traceback original (por si hay una excepción):
info = sys.exc_info() # exc_type, exc_value, exc_traceback
# importante: no usar unpacking porque puede causar memory leak
if not current_filename:
# genero un call stack para ver quien me llamó y limitar la traza:
# advertencia: esto es necesario ya que en py2exe no tengo __file__
try:
raise ZeroDivisionError
except ZeroDivisionError:
f = sys.exc_info()[2].tb_frame.f_back
current_filename = os.path.normpath(os.path.abspath(f.f_code.co_filename))
# extraer la última traza del archivo solicitado:
# (útil para no alargar demasiado la traza con lineas de las librerías)
ret = {'filename': "", 'lineno': 0, 'function_name': "", 'code': ""}
try:
for (filename, lineno, fn, text) in traceback.extract_tb(info[2]):
if os.path.normpath(os.path.abspath(filename)) == current_filename:
ret = {'filename': filename, 'lineno': lineno,
'function_name': fn, 'code': text}
else:
print filename
except Exception, e:
pass
开发者ID:MatiasNAmendola,项目名称:pyafipws,代码行数:26,代码来源:utils.py
示例17: buildDicts
def buildDicts(n):
cleaner = Cleaner()
cleaner.javascript = True
cleaner.style = True
i = 0
tagsDict = set()
while (i < n):
if (os.path.isfile("spam/%d.txt" % i)):
try:
readInFile = open("spam/%d.txt" % i)
content = readInFile.read()
noSymbols = re.sub('[^A-Za-z-]+', ' ', content.lower()) # noSymbols is stripped of symbols
tags = set(noSymbols.split()) # allCopy is the set of words without symbols
tagsDict = tagsDict.union(tags)
except Exception, err:
print traceback.format_exc()
print sys.exc_info()[0]
if (os.path.isfile("notspam/%d.txt" % i)):
try:
readInFile = open("notspam/%d.txt" % i)
content = readInFile.read()
noSymbols = re.sub('[^A-Za-z-]+', ' ', content.lower()) # noSymbols is stripped of symbols
tags = set(noSymbols.split()) # allCopy is the set of words without symbols
tagsDict = tagsDict.union(tags)
except Exception, err:
print traceback.format_exc()
print sys.exc_info()[0]
开发者ID:0x0mar,项目名称:Fishing-for-Phishing,代码行数:27,代码来源:tokenizer2.py
示例18: nested
def nested(*managers):
# Code from `contextlib`
exits = []
vars = []
exc = (None, None, None)
try:
for mgr in managers:
exit = mgr.__exit__
enter = mgr.__enter__
vars.append(enter())
exits.append(exit)
yield vars
except:
exc = sys.exc_info()
finally:
while exits:
exit = exits.pop()
try:
if exit(*exc):
exc = (None, None, None)
except:
exc = sys.exc_info()
if exc != (None, None, None):
# Don't rely on sys.exc_info() still containing
# the right information. Another exception may
# have been raised and caught by an exit method
raise exc[1].with_traceback(exc[2])
开发者ID:drawcode,项目名称:python_toolbox,代码行数:27,代码来源:functions.py
示例19: run
def run(self, result=None):
orig_result = result
if result is None:
result = self.defaultTestResult()
startTestRun = getattr(result, 'startTestRun', None)
if startTestRun is not None:
startTestRun()
self._resultForDoCleanups = result
result.startTest(self)
if getattr(self.__class__, "__unittest_skip__", False):
# If the whole class was skipped.
try:
result.addSkip(self, self.__class__.__unittest_skip_why__)
finally:
result.stopTest(self)
return
testMethod = getattr(self, self._testMethodName)
try:
success = False
try:
self.setUp()
except SkipTest, e:
result.addSkip(self, str(e))
except Exception:
result.addError(self, sys.exc_info())
else:
try:
testMethod()
except self.failureException:
result.addFailure(self, sys.exc_info())
except _ExpectedFailure, e:
result.addExpectedFailure(self, e.exc_info)
except _UnexpectedSuccess:
result.addUnexpectedSuccess(self)
开发者ID:Aaron1011,项目名称:oh-mainline,代码行数:35,代码来源:case.py
示例20: getAnyChecksum
def getAnyChecksum(self, info, username=None, password=None, session=None, is_source=0):
""" returns checksum info of available packages
also does an existance check on the filesystem.
"""
log_debug(3)
pkg_infos = info.get('packages')
channels = info.get('channels', [])
force = info.get('force', 0)
orgid = info.get('org_id')
if orgid == 'null':
null_org = 1
else:
null_org = None
if not session:
org_id, force = rhnPackageUpload.authenticate(username, password,
channels=channels,
null_org=null_org,
force=force)
else:
try:
org_id, force = rhnPackageUpload.authenticate_session(
session, channels=channels, null_org=null_org, force=force)
except rhnSession.InvalidSessionError:
raise_with_tb(rhnFault(33), sys.exc_info()[2])
except rhnSession.ExpiredSessionError:
raise_with_tb(rhnFault(34), sys.exc_info()[2])
if is_source:
ret = self._getSourcePackageChecksum(org_id, pkg_infos)
else:
ret = self._getPackageChecksum(org_id, pkg_infos)
return ret
开发者ID:m47ik,项目名称:uyuni,代码行数:35,代码来源:packages.py
注:本文中的sys.exc_info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论