Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease output to stdout #68

Open
bruckbond opened this issue Jun 24, 2019 · 3 comments
Open

Decrease output to stdout #68

bruckbond opened this issue Jun 24, 2019 · 3 comments

Comments

@bruckbond
Copy link

Hello, I've already seen this THIS issue
But using the code from there I still have no success on Win 10 and Ubuntu 18. Can anyone help me with decreasing output?
The code, I'm using, is:

async def parser():
    import os
    browser = browsers.Chrome(chromeOptions={'args': ['--whitelisted-ips', '--headless', '--disable-gpu', '--no-sandbox']})
    async with get_session(services.Chromedriver(log_file=os.devnull), browser) as session:
        await session.get("https://www.google.com")
@ojii
Copy link
Contributor

ojii commented Jun 25, 2019

See this comment and this comment in the linked issue. the log_file argument to a driver only controls the output of the driver, not of arsenic itself. arsenic uses structlog for logging, so you need to follow its instructions for controlling output.

@bruckbond
Copy link
Author

bruckbond commented Jun 26, 2019

See this comment and this comment in the linked issue. the log_file argument to a driver only controls the output of the driver, not of arsenic itself. arsenic uses structlog for logging, so you need to follow its instructions for controlling output.

using construction like this:

    service = services.Geckodriver(log_file=os.devnull)
    async with get_session(Geckodriver(service), Firefox()) as session:

I receive this output:

Traceback (most recent call last):
  File "all_in_one.py", line 325, in pushka
    await parser()
  File "all_in_one.py", line 371, in parser
    async with get_session(Geckodriver(service), Firefox()) as session:
  File "/usr/local/lib/python3.7/dist-packages/arsenic/__init__.py", line 16, in __aenter__
    self.session = await start_session(self.service, self.browser, self.bind)
  File "/usr/local/lib/python3.7/dist-packages/arsenic/__init__.py", line 28, in start_session
    driver = await service.start()
  File "/usr/local/lib/python3.7/dist-packages/arsenic/services.py", line 96, in start
    self.log_file,
  File "/usr/local/lib/python3.7/dist-packages/arsenic/services.py", line 34, in subprocess_based_service
    process = await impl.start_process(cmd, log_file)
  File "/usr/local/lib/python3.7/dist-packages/arsenic/subprocess.py", line 57, in start_process
    *cmd, stdout=log_file, stderr=log_file, stdin=DEVNULL
  File "/usr/lib/python3.7/asyncio/subprocess.py", line 217, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1533, in subprocess_exec
    bufsize, **kwargs)
  File "/usr/lib/python3.7/asyncio/unix_events.py", line 190, in _make_subprocess_transport
    **kwargs)
  File "/usr/lib/python3.7/asyncio/base_subprocess.py", line 37, in __init__
    stderr=stderr, bufsize=bufsize, **kwargs)
  File "/usr/lib/python3.7/asyncio/unix_events.py", line 763, in _start
    universal_newlines=False, bufsize=bufsize, **kwargs)
  File "/usr/lib/python3.7/subprocess.py", line 728, in __init__
    errread, errwrite) = self._get_handles(stdin, stdout, stderr)
  File "/usr/lib/python3.7/subprocess.py", line 1359, in _get_handles
    c2pwrite = stdout.fileno()
AttributeError: 'Geckodriver' object has no attribute 'fileno'

@ojii
Copy link
Contributor

ojii commented Jun 27, 2019

You can't pass a driver to a driver. Try this instead

    service = services.Geckodriver(log_file=os.devnull)
    async with get_session(service, Firefox()) as session:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants