xvfbwrapper icon indicating copy to clipboard operation
xvfbwrapper copied to clipboard

Support for unary args

Open cjauvin opened this issue 8 years ago • 7 comments

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

cjauvin avatar Apr 01 '16 13:04 cjauvin

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

cgoldberg avatar Apr 02 '16 17:04 cgoldberg

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.

cjauvin avatar Apr 02 '16 17:04 cjauvin

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')

cgoldberg avatar Apr 04 '16 01:04 cgoldberg

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!

cjauvin avatar Apr 04 '16 14:04 cjauvin

@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

alkuzad avatar May 09 '18 09:05 alkuzad

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’)

colllin avatar Mar 03 '19 22:03 colllin

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.

ranasats avatar Aug 05 '20 18:08 ranasats