-
Notifications
You must be signed in to change notification settings - Fork 253
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
Add examples #119
Add examples #119
Conversation
Hm, not sure why you can't see the tests in Travis. This is what I see locally:
Note this:
So, what I did was:
Then I added an What do you think about this approach? I also noticed the |
This reverts commit 3d6cdb0.
Hey, First off, great idea to make examples runnable. I'm not entirely keen on the idea of examples having the Would it be possible to make them simple Python files, without the need for parsing? |
Yes, I agree. I think that would make it easier for anyone to contribute as well. I'll try to come up with something which can be included in the tests. |
I also renamed the builders, because they were getting run during testing due to their name containing the magic word "test".
Hm...
|
# Conflicts: # Qt.py
Without these lines, tests may look within any Python file and throw errors unrelated to tests (in this case, SyntaxError in Python 3 for file(s) produced by build_membership.py).
This will take you into the image so you can test interactively. $ docker run -ti --rm --entrypoint bash -v $(pwd):/Qt.py mottosso/qt.py27
$ cd /Qt.py
$ python build_examples_tests.py
$ python some_test.py.. |
What do you think so far? |
Hm. I miss having an .md file with explanations. |
import sys | ||
import os | ||
|
||
os.environ["QT_PREFERRED_BINDING"] = "PySide" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come you prefer PySide here? Shouldn't this work on any binding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a weird thing in Python 2.7 if I don't specify this. Don't really understand why. I can remove it and you'll see in my next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. If unspecified, it will try and use PySide2. Maybe there's some issue there.
@mottosso what do you think? |
import os | ||
|
||
# Set preferred binding | ||
os.environ["QT_PREFERRED_BINDING"] = "PySide:PyQt4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this os.pathsep.join(["PySide", "PyQt4"])
so that it also runs on Windows?
(I would also be up for discussing an alternative syntax for this, having now seen it in the real-world, e.g. "PySide,PyQt4"
)
I like it! |
Great points, I agree on all of them. My eyes hurt as well now ;) I'll address them all, probably tomorrow. |
Fixed:
I'm also copying non-python files into the working directory, so that the ui file can be defined without the relative filepath into
Yes, I think a comma is more suitable. I always thought |
So, I'm copying files from If I put an This will also eliminate the need for If we use the
(we'd need to rename those python files to avoid the ugly naming though) What's nice about this is we've already talked about restructuring Qt.py into subfolders so that it'll be easier to maintain as it grows (but we agreed that is not the way forward). So instead of making Qt.py grow, I'll push an example of this and we can discuss. |
Edited my previous post so much if you already read it I'm afraid I'd like you to re-read it. Sorry - made more sense to consolidate, I thought. 😢 |
In the previous commit:
from examples.load_ui import baseinstance1
widget = baseinstance1.setup_ui('examples/load_ui/qwidget.ui', self) One might argue that with the importable examples, we should define our tests in I want to stress that I don't think that @mottosso what do you think about all this? |
I know you did, and having worked with it for a while now, I think your gut was right.
This sounds good to me. For the record, the
We still could not, I think, as It doesn't hurt having a package in this way in the project however, as we explicitly specify that the file
Conceptually, I like the sound of that, but am having trouble seeing how growth of any kind is helpful for such simple and de-coupled things as examples. I'll keep an open mind though.
Do you mean in the global |
I meant that one might argue to collect all tests into github.com/Qt.py/tests.py but in this case I think that, for completion purposes, it's nicer to define test in each example. Also, defining the tests in the global tests.py would decouple the test and the example a bit too much, I think. So I like this current approach that is in this PR. |
Xvfb :99 -screen 0 1024x768x16 2>/dev/null & \ | ||
sleep 3 && \ | ||
sleep 10 && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah, seems like this one has no end.
Let's find a better way of handling this. There must be some way of waiting for a signal/sign of sorts, and continuing once that happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't know if it's a memleak or what is going on... but I need to rebuild my containers at least once a day. And I have to restart XQuartz a few times too. So I'm not sure what's causing that.
But so 3 seconds isn't always enough... and that's why I increased it to something I don't have to go back and tweak with +1 second...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XQuartz
You shouldn't need anything like that on your machine; xvfb is completely isolated within the container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm giving this a go now...
xdpyinfo -display :99 >/dev/null 2>&1 && echo "In use" || echo "Free"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this was a better/simpler approach:
ps auxx | grep Xvfb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following, but glad to hear you may have found a way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm waiting until I find the process Xvfb
to be running. Works here on Docker for Mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XQuartz
You shouldn't need anything like that on your machine; xvfb is completely isolated within the container.
Ah!
So, now there's a loop waiting for the I think this could be ready for a merge. |
Xvfb :99 -screen 0 1024x768x16 2>/dev/null & \ | ||
sleep 3 && \ | ||
while ! ps aux | grep -q '[0]:00 Xvfb :99 -screen 0 1024x768x16'; do echo "Waiting for Xvfb..."; sleep 1; done && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat!
Without the 2>/dev/null
, are we getting output from xvfb at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new command just checks whether grep
finds this string from the output of the ps aux
command:
0:00 Xvfb :99 -screen 0 1024x768x16
The original command which launches Xvfb is untouched:
Xvfb :99 -screen 0 1024x768x16 2>/dev/null
So the functionality should be unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah, right, missed that, sorry.
That's great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could make the search string include that last pipe bit. I didn't do it just to shorten down the line length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to break this line?
...
Xvfb :99 -screen 0 1024x768x16 2>/dev/null & \
while ! ps aux | grep -q '[0]:00 Xvfb :99 -screen 0 1024x768x16'; \
do echo "Waiting for Xvfb..."; sleep 1; done && \
nosetests \
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could make the search string include that last pipe bit. I didn't do it just to shorten down the line length.
On second thought, I can't. ps
doesn't show piping:
root 6 0.7 1.5 207336 31256 ? Sl 10:05 0:00 Xvfb :99 -screen 0 1024x768x16
So this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to break this line?
Yes, done!
LGTM! |
Awesome, I'll merge this then! |
Docker for Mac is acting up here and I can't perform tests locally... so I'm going to have to rely on Travis. Bare (bear?) with me for a while...