Skip to main content

Posts

Implementing heartbeat in stomp.py

I am seeing behavior in our stomp.py client (listener only) where after some idle time of not receiving messages the AMQ broker seems to drop the client i.e. looking at the AMQ management console shows zero consumers. The odd thing is the on_disconnected handler of the client never gets called and we have a health check on the client service that checks the connection is_connected() , however it still returns true. Based on my understanding/research (please correct if any of this is false) this is due to the broker trying to clean-up resources it perceives as inactive. Also based on my research "heartbeating" can be used to avoid this perception on the broker. I know how to send the heartbeat header from the client and how to check the response from the server/broker (as far as what it expects) in on_connected but my question is how do I send the actual heartbeat from the client to the server/broker? Do I need to send a message on the queue I am listening to? If so how do

JS this dynamic scoping [duplicate]

When trying to execute the following snippet, I expected the doFoo.call(obj, obj.foo) call to return "inside obj" as the dynamic scope of the previous element in the call stack has a reference to a but the call has the global context instead. What am I missing here? function foo() { // debugger console.log(this, this.a); } function doFoo(fn) { // `fn` is just another reference to `foo` // debugger fn() // <-- call-site! } var obj = { a: 'inside obj', foo: foo }; var a = "oops, global"; // `a` also property on global object doFoo(obj.foo); // "oops, global" doFoo.call(obj, obj.foo) // "oops, global"``` Via Active questions tagged javascript - Stack Overflow https://ift.tt/BpEImlW

Bundle Python package to a single file

I'm in a system where I cannot install any package nor create files/directories and I don't have anything but Python installed. However, I can copy-paste some code at the top of my script. I would like to use the pathfinding library, so I was thinking if there is any way to bundle a library, like in JavaScript, and get all the exports in the global scope, so I can use them in my code. source https://stackoverflow.com/questions/71161649/bundle-python-package-to-a-single-file

QDialog with QScrollArea adjustSize on widget hide

File: search.py # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/chris/Documents/papinhio-player/ui/menu-3/radio-stations/search/search.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(837, 556) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/main-window/assets/images/main-window/search.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) Dialog.setWindowIcon(icon) Dialog.setStyleSheet("QScrollArea{\n" " border:0px;\n" "}") self.gridLayout = QtWidgets.QGridLayout(Dialog) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLa

how to update a tkinter label

i wrote a programm, that gets weather data from a api, and now im working on a interface, but when i want a new temperature in the same label it doesnt work. import requests from tkinter import * global stadt TOKEN = "rrrrrrrrrr" a = "jaaa" root = Tk() root.title("Wetter") root.geometry("300x150") def get_entry(): stadt = Entry1.get() url = f"https://api.openweathermap.org/data/2.5/weather?q={stadt}&appid={TOKEN}" f = requests.get(url).json() temperatur = f["main"]["temp"] temperatur = temperatur - 273.15 luftdruck = f["main"]["pressure"] alltext= f"Die Temperatur in {stadt} beträgt {round(temperatur)}°C\nDer Luftdruck in {stadt} beträgt {luftdruck}Ba" string = StringVar() lab = Label(root, text=alltext) lab.pack() string.set(alltext) Label1 = Label(root, text="Bitte Stadt eingeben") Label1.pack() Entry1 = E

Getting quadPoints from selected text having multiple lines in ng2-pdf-viewer

I'm making a web-based PDF annotation tool using Angular, annotpdf library and ng2-pdf-viewer. All the annotations work fine except when I try annotating multiple lines. So I found out, in order to annotate(underline/highlight/strike through) multiple lines, I have to pass quadPoints as a parameter into the createAnnotation() functions. quadPoints are coordinates of rectangles that together form the selection of multiple lines. They are arrays having length multiples of 8. So my question is how do I get these quadPoints from a selection? I think I can use the mouse click/drag/up/down event but can't figure out how. Any solutions to this? Via Active questions tagged javascript - Stack Overflow https://ift.tt/O1SvydL

How would I use a regular expression to match a string with or without parentheses at the end in Python3

I've never used regular expressions but know a little bit of the syntax after reading a bit on the python website. I'm trying to write a regular expression that would match to entries in a text document. Each entry is on a newline. For example here's a portion of the document I'm searching: ABSOLVE AH0 B Z AA1 L V ABSOLVE(1) AE0 B Z AA1 L V ABSOLVED AH0 B Z AA1 L V D ABSOLVED(1) AE0 B Z AA1 L V D ABSOLVES AH0 B Z AA1 L V Z ABSOLVES(1) AE0 B Z AA1 L V Z if I had the string 'ABSOLVE' that I'm searching the document for I want to find 'ABSOLVE' , 'ABSOLVE(1)' , but NOT 'ABSOLVED' or anything else listed. Each line in this text document has a word followed by 2 spaces then some other data that should be collected after a match is found. I'm just not sure if I should use $ or \b flags in an re or what. My idea was to use something like re.sub(r'([A-Z])(.*?)( )', r'\1\3', text) Then just search from the