Ejemplo n.º 1
0
def start_connector():
    machine_address = 'localhost'
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (machine_address, 5005)
    print(f"SERVER IP: {server_address[0]} | SERVER PORT: {server_address[1]}")
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind(server_address)
    # sock.setblocking(0)
    sock.listen(1)
    while True:
        print(f"Waiting for connection")
        time.sleep(10)
        connection, clinet_address = sock.accept()
        try:
            print(f"Connection established from: {clinet_address}")

            while True:
                time.sleep(5)
                # data = connection.recv(1024)
                # print(f"Received {data}")
                # if data:
                #     print("Sedning info back to client")
                #     connection.send(b"YOU ARE CONNECTED")
                #     continue
                # else:
                #     print("Waiting for client info")

                if guli.GuliVariable("on_modified").get() == "true":
                    print("CHANGED!")
                    guli.GuliVariable("on_modified").setValue("false")

                    connection.send(b"/K ping wp.pl")

        except Exception as e:
            print(e)
        finally:
            print("CLOSED")
            connection.close()
            break
Ejemplo n.º 2
0
def StopThread():
    guli.GuliVariable("stop").setValue(1)
Ejemplo n.º 3
0
def ViewResults():

    ViewResults = Toplevel()
    ViewResults.title('Induction Motor Desing Tool - Results')

    start = mclass(ViewResults)


def PopUpWindow():

    PopUpWindow1 = Toplevel()
    PopUpWindow1.title('Pop-Up Window')
    start1 = PopUpWindow_class(PopUpWindow1)


guli.GuliVariable("bar").setValue(0)
guli.GuliVariable("stop").setValue(0)


def StopThread():
    guli.GuliVariable("stop").setValue(1)


while 1:
    try:
        progress['value'] = guli.GuliVariable("bar").get()
    except ValueError:
        pass
    if progress['value'] == 100 and temp == 0:
        PopUpWindow()
        temp = 1
Ejemplo n.º 4
0
def rec_msg(conn):
    msg = conn.recv()
    guli.GuliVariable("msg").setValue(msg)
Ejemplo n.º 5
0
#library for passing variables through processes
import guli

address = ('127.0.0.1', 5005)


def print_msg(msg):
    print(msg)


def rec_msg(conn):
    msg = conn.recv()
    guli.GuliVariable("msg").setValue(msg)


if __name__ == '__main__':
    listener = Listener(address, authkey=b"pass")
    conn = listener.accept()

    while True:
        proc_get = Process(target=print_msg,
                           args=(guli.GuliVariable("msg").get(), ))
        proc_print = Process(target=rec_msg, args=(conn, ))
        proc_get.start()
        proc_print.start()
        proc_get.join()
        proc_print.join()
        if guli.GuliVariable("msg").get() == "close":
            conn.close()
            break
Ejemplo n.º 6
0
def on_moved(event):
    print(f"moved {event.src_path} to {event.dest_path}")
    guli.GuliVariable("on_created").setValue(event.src_path)
Ejemplo n.º 7
0
def on_modified(event):
    guli.GuliVariable("on_modified").setValue("true")
Ejemplo n.º 8
0
def on_deleted(event):
    print(f"{event.src_path} deleted")
    guli.GuliVariable("on_created").setValue(event.src_path)
Ejemplo n.º 9
0
import time
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
from multiprocessing.connection import Client
from multiprocessing import Process, Event
import socket
import guli
import os

from tools.config_reader import ConfigReader
from tools.xml_tools import return_xml_attribute_value
from server import MachineConnector

guli.GuliVariable("on_modified").setValue("false")


def start_connector():
    machine_address = 'localhost'
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (machine_address, 5005)
    print(f"SERVER IP: {server_address[0]} | SERVER PORT: {server_address[1]}")
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind(server_address)
    # sock.setblocking(0)
    sock.listen(1)
    while True:
        print(f"Waiting for connection")
        time.sleep(10)
        connection, clinet_address = sock.accept()
        try:
            print(f"Connection established from: {clinet_address}")