Errors in red are so cool.
This commit is contained in:
@ -10,7 +10,6 @@ from bonobo.core.stats import WithStatistics
|
||||
from bonobo.util.lifecycle import get_initializer, get_finalizer
|
||||
from bonobo.util.tokens import BEGIN, END, NEW, RUNNING, TERMINATED, NOT_MODIFIED
|
||||
|
||||
|
||||
class ExecutionContext:
|
||||
def __init__(self, graph, plugins=None):
|
||||
self.graph = graph
|
||||
@ -96,7 +95,10 @@ class AbstractLoopContext:
|
||||
:param trace: Hercule Poirot's logbook.
|
||||
:return: to hell
|
||||
"""
|
||||
print('\U0001F4A3 {} in {}'.format(type(exc).__name__, self.wrapped))
|
||||
|
||||
from blessings import Terminal
|
||||
term = Terminal()
|
||||
print(term.bold(term.red('\U0001F4A3 {} in {}'.format(type(exc).__name__, self.wrapped))))
|
||||
print(trace)
|
||||
|
||||
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
try:
|
||||
import selenium
|
||||
except ImportError as e:
|
||||
import logging
|
||||
|
||||
logging.exception(
|
||||
'You must install selenium to use the bonobo selenium extension. Easiest way is to install the '
|
||||
'optional "selenium" dependencies with «pip install bonobo[selenium]», but you can also install a '
|
||||
'specific version by yourself.')
|
||||
|
||||
from bonobo import service
|
||||
|
||||
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4'
|
||||
|
||||
|
||||
def create_profile(use_tor=False):
|
||||
_profile = selenium.webdriver.FirefoxProfile()
|
||||
_profile.set_preference("toolkit.startup.max_resumed_crashes", "-1")
|
||||
|
||||
if use_tor:
|
||||
# tor connection
|
||||
_profile.set_preference('network.proxy.type', 1)
|
||||
_profile.set_preference('network.proxy.socks', '127.0.0.1')
|
||||
_profile.set_preference('network.proxy.socks_port', 9050)
|
||||
|
||||
# user agent
|
||||
_profile.set_preference("general.useragent.override", USER_AGENT)
|
||||
|
||||
return _profile
|
||||
|
||||
|
||||
def create_browser(profile):
|
||||
_browser = selenium.webdriver.Firefox(profile)
|
||||
_browser.implicitly_wait(10)
|
||||
_browser.set_page_load_timeout(10)
|
||||
return _browser
|
||||
|
||||
|
||||
@service
|
||||
def browser():
|
||||
return create_browser(create_profile(use_tor=False))
|
||||
|
||||
|
||||
@service
|
||||
def torbrowser():
|
||||
return create_browser(create_profile(use_tor=True))
|
||||
Reference in New Issue
Block a user