pytest_runtest_makereport(item, call) receive item as object of _pytest.python.Function instead of _pytest.nodes.Node - pytest

I have few stations which run my automation system based on pytest.
For some reason I have one station which running same Python version and same packages installed but when trying to run it fails since:
pytest_runtest_makereport(item, call) receive item as object of _pytest.python.Function instead of _pytest.nodes.Node
I use this hook in my code to do some stuffs and see that item received incorrectly and while trying to get some info from the test item it fails since the info I look for does not exists.
If someone knows why does it happen I will be glad to hear :-)

Related

fly watch on current job inside on_error?

I want to get the results of the fly watch command for the current build on the on_error hook so I can report the details of the error into Slack.
I found a way to do this using a custom resource, however, since the job is still running during the on_error, it just loops endlessly which effectively hangs the concourse build and VM.
Is there a way to get the fly watch output for a pipeline? Alternatively, is there a way to tell the fly watch command to just return the data is has and not continue to query for more output?

how to run bpy callback on workspace tools change

How to add a pre-draw hook to current context workspace.tools change?
I attempted to get there using bpy.types.SpaceView3D.draw_handler_add(...) which as it runs on every draw, checks if workspace.tools changed, and if it changed, run my callback, but my callback wants to add its own SpaceView3D.draw_handler_add and doing it this way adds it a frame-too-late, leaving the view port undrawn until a user event repaints the screen.
I found this post online
https://devtalk.blender.org/t/update-property-when-active-tool-changes/11467/12
summary: maybe there is a mainline callback new
https://developer.blender.org/D10635
AFWS Jan '20
#kaio
This seem like a better solution. It’s kind of a mystery code, cause I
couldn’t figure out where you got that code info ,but then started
looking at the space_toolsystem_common.py file. kaio AFWS Jan '20
Just realized there might be a cleaner way of getting callbacks for
active tools using the msgbus. Since workspace tools aren’t rna
properties themselves, figured it’s possible to monitor the
bpy_prop_collection which changes with the tool.
The handle is the workspace itself, so shouldn’t have to worry about
keeping a reference. The subscription lasts until a new file is
loaded, so add a load_post callback which reapplies it.
Note this doesn’t proactively subscribe to workspaces added
afterwards. Might need a separate callback for that :joy:
import bpy
def rna_callback(workspace):
idname = workspace.tools[-1].idname
print(idname)
def subscribe(workspace):
bpy.msgbus.subscribe_rna(
key=ws.path_resolve("tools", False),
owner=workspace,
args=(workspace,),
notify=rna_callback)
if __name__ == "__main__":
ws = bpy.context.workspace
subscribe(bpy.context.workspace)
# Subscribe to all workspaces: if 0:
for ws in bpy.data.workspaces:
subscribe(bpy.context.workspace)
# Clear all workspace subscriptions if 0:
for ws in bpy.data.workspaces:
bpy.msgbus.clear_by_owner(ws)

python Gtk app failed with this error xcb xlib threads sequence lost failed

I had a pyGObject app and I run that. all things work fine until on a button clicked signal I need to run a def. it has a long loop and I run that with the
def on_launch_btn_clicked(self,button):
_thread.start_new_thread(launch,["thread"])
def launch(thread):
lines_list = open("../line.txt").split()
for line in lines_list:
select = machinestate.objects.get(id=1)
if not select.pause:
#my process
else:
def pause_lcd()
return "pause" #it for come out of def and close thread but I don't know it close that or not
this loop is in another .py file
function it works like a charm, next I had a pause button it changes database pause field to True and my loop every iteration check database to saw what is changed. when it saw pause is True it run
def pause_lcd():
app = app_list[0]
app.pause_action()
I run Gtk app in this def
app_list = list()
def main(thread):
app = GUI()
app_list.append(app)
Gdk.threads_init()
Gtk.main()
in my GUI class I have pause_action method
def pause_action(self):
self.pause_btn.set_sensitive(True)
self.pause_btn.hide()
self.resume_btn.show()
when I clicked on pause button some time I got this error
[xcb] Unknown sequence number while processing queen
[xcb] Most likely this is a mulity-threaded client and XinitThreads has not been called
[xcb] Aborting, sorry about that
pyhton: ../../src/xcb_io.c:263 poll_for_event: Assertion '!xcb_xlib_threads_sequence_lost failed.
I had a bunch of thread side this threads like machine info, clock, machine temp and ...
what I do wrongs??
PS: this app run in a Django project and I use Django model in this it is an app of Django but it runs a Gtk app
I suspect that something with the XCB or the X11 server is wrong (bug). I received the same error message from different applications on a specific X server (using X11 over ssh).
Error message with emacs:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
emacs: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Error message with eclipse:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

Connecting FluidEnter/FluidExit at run-time

I am toying with the FluidEnter/FluidExit. So in a simple form, here is what I am trying to do:
I created in Main an empty population of agent called Terminal. For now, in Terminal, there is only a fluidEnter connected to a fluidExit (very simple)
enter image description here
Now, on startup, I want to fill this population and set up the proper connections (the terminals are ordered).
So, on startup, I call a function init(), whose body start with Terminal t = add_terminals(); (I have only one terminal for now, just toying with things)
In Main, obviously, I also have a fluidEnter and a fluidExit. I would like to connect the fluidExit of Main to the fluidEnter of the terminal t, and the fluidExit of the terminal t to the fluidEnter of Main, so code (still in init()) looks like
fluidExit.set_fluidEnter(t.fluidEnter);
t.fluidExit.set_fluidEnter(fluidEnter);
I get an exception so obviously, I am doing something wrong. Any idea?
I think the set_fluidEnter function is deprecated or just non-functional.
Instead, you should do:
fluidExit.connect(t.fluidEnter);
So just replace set_fluidEnter with connect... nothing else.
That should do the trick
I was going down the same path as you a couple of months ago. Yes... .connect() works great. It even works as a gate. If it is disconnected, then fluid stops at the exit. Once connected, fluid starts to flow again. It is very slick.

Haskell Yesod Running a Handler at a specific Day of Week and at a specific Time

I will create a Handler that, when called, it will send HTML reports to my customer emails, I would like to know the cleanest way to schedule it, for instance, Friday at 08:00AM. I can use Linux crontab to call a URL at a specific time, but it will need to be exposed... (Even though I will make it available to myself to send reports whenever I want, at least in the beginning)
Here's what I would do:
main = do
forkIO . forever $ do
waitUntilFridayAt0800
sendOutReports
waitUntilItIsNotFridayAt0800JustToBeSafe
startYesod