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

Support for unary args #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

cjauvin
Copy link

@cjauvin cjauvin commented Apr 1, 2016

This adds support for Xvfb arguments which do not have values (e.g. -noreset).

@cgoldberg
Copy link
Owner

thanks!

could you create a new test for unary_args, rather than how you added it to the existing test_start_with_arbitrary_kwargs test? If you make that change, I'll be happy to merge this.

-Corey

@cjauvin
Copy link
Author

cjauvin commented Apr 2, 2016

Done, thanks a lot! Also, I have another small change I've been using in my particular context, where I want to control the display variable explicitly (instead of auto-assigning it): if you think it would make sense to add it, let me know.

@cgoldberg
Copy link
Owner

thanks much.

hmm.. so to add a unary arg, you have to pass it as a kwarg with a None value? (like my_arg=None). That's not very obvious (it took me a few mins to figure it out). At the least, we should update the README with some nice examples showing use of binary and unary args, so it's clear. You can add that to this PR if you'd like. (If that's not convenient, I can just merge as-is and write the examples myself sometime this week).

One other thought.... couldn't we use *args for passing arbitrary unary args?

would something like this work as a signature:

def __init__(self, width=800, height=680, colordepth=24, *args, **kwargs)

then you could for example, initialize the Xvfb object like:

Xvfb(width=1024, height=768, 'noreset', nolisten='tcp')

@cjauvin
Copy link
Author

cjauvin commented Apr 4, 2016

Rethinking about it, I now totally agree that using an argument with a None value (an empty string would make a little bit more sense, and it also works btw) is not the most intuitive interface.

I find your idea of using *args very clever, although there's a part of me thinking that it wouldn't be 100% pythonic as well.. But then the only other alternative remaining would be an explicit server_args argument, with which we would have essentially the same design problems (i.e. it would need to support both unary and binary arguments in the same data structure).

So I vote for your *args idea, I will propose a PR with it soon!

@alkuzad
Copy link
Contributor

alkuzad commented May 9, 2018

@cgoldberg actually I also had problem with argument that does not use "-",
have you thought of supporting passing full args list instead of kwargs ? Xvfb supports at least 4 parameter types:

  • starting with -
  • starting with +
  • without any prefix and parameter
  • without any prefix and not parameter

For now you only support first ones. And altough it's easy to overcome it via:

    xvfb = Xvfb(width=width, height=height, colordepth=depth)
    xvfb.extra_xvfb_args += ['+extension', 'RANDR', 'c', '20']

It's kinda hacky and not documented

@colllin
Copy link

colllin commented Mar 3, 2019

I also need this to add the GLX extension, e.g. Xvfb ... +extension GLX. Another idea might be to just accept a string for the extra command-line args, i.e. Xvfb(extra_args=‘+extension GLX -noreset’)

@ranasats
Copy link

ranasats commented Aug 5, 2020

Can someone suggest how to properly supply extensions using this? Right now I have this, but I can't seem to add in +extension RANDR

   with Xvfb(width=1920, height=1080, colordepth=24, nolisten='tcp') as xvfb:
         xvfb.extra_xvfb_args += ['+extension', 'RANDR']

I still get the randr missing warning.

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

Successfully merging this pull request may close these issues.

None yet

5 participants