<commit_before>#Pastry v0.1
#Written for Python 2.7.5

#Imports
import pyperclip #Awesome library for cross-platform copy/paste
import time #I love importing time. It sounds very fancy
import socket #Networking so the clipboard can be multicast
import changeDetails #The settings dialog area, only one thing in there right now but that can change
import threading #Multithreading
import signal #Handle Ctrl + C
import sys #Exiting

#Setup variables
currentClipboard = pyperclip.paste()

#Get the users ID
#Do we have a config file?
try:
	#Yes we do
	open('settings.py')
except:
	#No we don't
	changeDetails.changeDetails()
import settings

#Send out the new clipboard
def sendClipboard(clipboard):
	#Hook up the multicast
	ANY = '0.0.0.0'
	MCAST_ADDR = '172.16.31.10'
	MCAST_PORT = 8946
	sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
	SENDERPORT=1501
	sock.bind((ANY,SENDERPORT))
	sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)

	#Send the clipboard
	sock.sendto(settings.login['id']+"##"+clipboard, (MCAST_ADDR,MCAST_PORT))

	#End the connection
	sock.close()

def listen():
	global currentClipboard
	while 1:
		time.sleep(0.1)
		#Check for external messages
		ANY = '0.0.0.0'
		MCAST_ADDR = '172.16.31.10'
		MCAST_PORT = 8946
		sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
		sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
		sock.bind((ANY,MCAST_PORT))
		sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)<commit_msg>Some error handling until #1 is fixed<commit_after>#Pastry v0.1
#Written for Python 2.7.5

#Imports
import pyperclip #Awesome library for cross-platform copy/paste
import time #I love importing time. It sounds very fancy
import socket #Networking so the clipboard can be multicast
import changeDetails #The settings dialog area, only one thing in there right now but that can change
import threading #Multithreading
import signal #Handle Ctrl + C
import sys #Exiting
import easygui as eg #Graphics

#Setup variables
currentClipboard = pyperclip.paste()

#Get the users ID
#Do we have a config file?
try:
	#Yes we do
	open('settings.py')
except:
	#No we don't
	changeDetails.changeDetails()
import settings

#Send out the new clipboard
def sendClipboard(clipboard):
	#Hook up the multicast
	ANY = '0.0.0.0'
	MCAST_ADDR = '172.16.31.10'
	MCAST_PORT = 8946
	sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
	SENDERPORT=1501
	sock.bind((ANY,SENDERPORT))
	sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)

	#Send the clipboard
	try:
		sock.sendto(settings.login['id']+"##"+clipboard, (MCAST_ADDR,MCAST_PORT))
	except:
		eg.msgbox("There was an error sending this copy across the network.", "Pastry")

	#End the connection
	sock.close()

def listen():
	global currentClipboard
	while 1:
		time.sleep(0.1)
		#Check for external messages
		ANY = '0.0.0.0'
		MCAST_ADDR = '172.16.31.10'
		MCAST_PORT = 8946
		sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
		sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
		sock.bind((ANY,MCAST_PORT))
		sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)
{'fraction_non_alphanumeric': 0.10234741784037558, 'fraction_numerical': 0.03348982785602504, 'mean_word_length': 5.1226053639846745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, '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': '5228890', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1128, 'n_words': 319}