<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import core, subprocess, os, threading, signal

is_sam_plugin = 1
name = "433MHz"
keywords = ["433"]
has_toggle = 0
has_set = 0

class Plugin_Thread(threading.Thread):

    def __init__(self, name):
        threading.Thread.__init__(self)
        self.name = name + "_Thread"
        self.process = None
        
    def run(self):
        core.log(self.name, "Started")
        #self.process = subprocess.Popen("/home/pi/Desktop/PersonalAssistant/Samantha/plugins/433_plugin.sh", stdout=subprocess.PIPE)
        self.process = subprocess.Popen("/home/pi/Desktop/libraries/433Utils/RPi_utils/RFSniffer", stdout=subprocess.PIPE, bufsize=1)
        core.log(self.name, "Subprocess started")
        '''
        This doesn't really work.. will have to look into it.
        while True:
            core.log(self.name, "Getting Output.")
            output = self.process.stdout.read(1)
            core.log(self.name, "Got Output.")
            if output == '' and self.process.poll() is not None:
                break
            if output:
                core.log(name, output)
            core.log(self.name, "Processed Output.")
        '''
        core.log(self.name, "Not running anymore.")
        
    def stop(self):
        os.kill(self.process.pid, signal.SIGTERM)
        core.log(self.name, "Exited")
        
if is_sam_plugin:
    t = Plugin_Thread(name)

def initialize():
    global t
    core.log(name, "Starting thread.")
    t.start()

def stop():
    global t
    core.log(name, "Exiting")
    t.stop()
    t.join()<commit_msg>guess i don't have to grab that output anymore<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import core, subprocess, os, threading, signal

is_sam_plugin = 1
name = "433MHz"
keywords = ["433"]
has_toggle = 0
has_set = 0

class Plugin_Thread(threading.Thread):

    def __init__(self, name):
        threading.Thread.__init__(self)
        self.name = name + "_Thread"
        self.process = None
        
    def run(self):
        core.log(self.name, "Started")
        self.process = subprocess.Popen("/home/pi/Desktop/libraries/433Utils/RPi_utils/RFSniffer")
        core.log(self.name, "Subprocess started")
        while True:
            if self.process.poll() is not None: 
                #Would return the process' return code once it's terminated. 
                #Will return None if the process is still running.
                break
            time.sleep(1)
        core.log(self.name, "Not running anymore.")
        
    def stop(self):
        os.kill(self.process.pid, signal.SIGTERM)
        core.log(self.name, "Exited")
        
if is_sam_plugin:
    t = Plugin_Thread(name)

def initialize():
    global t
    core.log(name, "Starting thread.")
    t.start()

def stop():
    global t
    core.log(name, "Exiting")
    t.stop()
    t.join()
{'fraction_non_alphanumeric': 0.12919986144786977, 'fraction_numerical': 0.011084170419120194, 'mean_word_length': 2.2559188275084554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '99052', 'n_tokens_mistral': 959, 'n_tokens_neox': 906, 'n_words': 214}