Posts

Showing posts from July, 2022

[Python] PyQt Threads

Image
  Define the Thread: class ThreadWorker(QThread): updateValueSignal = pyqtSignal( str ) updateTextEditSignal = pyqtSignal( str ) def run ( self ): #self.updateTextEditSignal.emit("Started MODBUS Read...\r\n\r\n") self .updateTextEditSignal.emit( "emit text signal" ) print ( "emit text signal" ) #buttonReply = QMessageBox.question(self, 'READ PASS', f"Reading from {modbus_ip} > Serial no.: {regs[0]}", # QMessageBox.Ok) def stop ( self ): self .terminate() Running the thread: def RunThread ( self ): self .threadworker = ThreadWorker() #self.threadworker.updateValueSignal.connect(self.showdialog) self .threadworker.updateTextEditSignal.connect( self .updateText) # self.modbusworker.updateListSignal.connect(self.updateList) self .threadworker.start()

[RPi] Setting up a NAS with openmediavault and Plex Media Server

Image
  What you need: Raspberry Pi 4 External Hard Drive STEP 1  Raspberry Pi Imager:  https://www.raspberrypi.org/software/ Update your Pi sudo apt update && sudo apt upgrade STEP 2 - Install OpenMediaVault Run this command: wget -O - https://raw.githubusercontent.com/OpenMediaVault-Plugin-Developers/installScript/master/install | sudo bash INSTALL PLEX MEDIA SERVER Install the https-transport package sudo apt-get install apt-transport-https Add the Plex repositories curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add - echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list sudo apt-get update Install Plex sudo apt install plexmediaserver If this doesn't work, download the compilied binary pagckage .deb manually as explained in the artcle given here : https://www.linuxbabe.com/debian/install-plex-media-server-debian-10-buster .

[Linux] Using grep command with pattern input from a file

Image
grep <text pattern> <file to be checked> grep -f<pattern file> <file to be checked> example: grep -f pattern.txt /var/log/apache2/access.log -f to input search patterns one search pattern per line do not include space/enter empty lines at the end - it will result displaying the whole file as it has enter '\r, '\n' characters contents of pattern.txt : /admin/system-monitor/flood-protect HTTP/1.1" 200 582 /admin/system-monitor/flood-protect HTTP/1.1" 200 590

[Python] PyQt5 Message Boxes

buttonReply = QMessageBox.question( self , 'Shutdown Server' , "Shutdown Server VM, Continue?" , QMessageBox.Yes | QMessageBox.No , QMessageBox.No) if buttonReply == QMessageBox.Yes: operation_num = 2 self .operationsThread = Operations_Thread() self .operationsThread.updateTextEditSignal.connect( self .updateText) self .operationsThread.start() self .updateText( "[{}]Shutting down VM - Please wait..." .format(time.strftime( "%Y.%m.%d-%H:%M:%S" ))) def showdialog ( self , text): global mon_config if text != 'FAIL' : msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setWindowTitle( f"MODBUS TCP Read from: { self .selectedDevice } " ) msg.setText( f"Sensor serial no: { text } " ) msg.setInformativeText( "For more info. click 'Show Details'" ) msg.setDetailedText( f"Serial no. from IP address : { self .selectedDevic...