예제 #1
0
    def UDPBroadcast(self, port, recipient, message):
        finalmsg = recipient + '%' + message

        s = socket(AF_INET, SOCK_DGRAM)
        s.bind(('', 0))
        s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
        s.sendto(finalmsg, ('<broadcast>', port))

        printMessage('Success', 'Message "' + message + '" is broadcasted!')
예제 #2
0
    def __init__(self):
        self.directory = os.path.abspath(__file__).rsplit('/', 1)[0] + '/'
        if len(sys.argv) > 1:
            # UDPBroadcastPort = 7011

            param = self.get_parameters(sys.argv)
            self.UDPBroadcast(int(param[0]), str(param[1]), str(param[2]))
        else:
            errorstr = 'python ' + __file__ + ' -port UDPReceivePort -recipient name -message custom message'
            printMessage('ERROR args', errorstr)
예제 #3
0
	def __init__(self):
		self.directory = os.path.abspath(__file__).rsplit('/',1)[0] + '/' 
		self.iconpath = 'dialog-information'
		try:
			if len(sys.argv) == 2:
				# self.UDPBroadcastReceivePort = 4090

				self.UDPBroadcastReceivePort = int(sys.argv[1])
				self.UDPBroadcastReceiver()
			else:
				printMessage('ERROR args','python ' + __file__ + ' UDPBroadcastReceivePort')
				# call(['sudo','-u',getpass.getuser(),'-H','notify-send', '-u', 'critical', 'ERROR args'])
				call(['notify-send', '-u', 'critical', '-i', self.iconpath, 'Error', 'ERROR args'])
		except Exception as e:
			call(['notify-send', '-u', 'critical', '-i', self.iconpath, 'Error', str(e)])
예제 #4
0
	def UDPBroadcastReceiver(self):
		self.sock = socket(AF_INET, SOCK_DGRAM)
		self.sock.bind(('',self.UDPBroadcastReceivePort))

		call(['notify-send', '-u', 'critical', '-i', self.iconpath, 'Enabled' ,"TextMessage notify enabled on port "+str(self.UDPBroadcastReceivePort)])

		while True:
			msg = self.getInputUDP()
			if (msg is None):
				continue
				
			message = msg['msg']
			sender = msg['address']
			senderIP = sender[0]
			senderPort = sender[1]
		
			printMessage(senderIP,message)

			self.sendMessage(message)
예제 #5
0
    def __init__(self):
        self.directory = os.path.abspath(__file__).rsplit('/', 1)[0] + '/'
        self.iconpath = ''
        try:
            if len(sys.argv) == 2:
                # self.UDPBroadcastReceivePort = 4090

                self.UDPBroadcastReceivePort = int(sys.argv[1])
                self.UDPBroadcastReceiver()
            else:
                printMessage('ERROR args',
                             'python ' + __file__ + ' UDPBroadcastReceivePort')
                call([
                    'osascript', '-e',
                    'display notification "Error" with title "ERROR args"'
                ])
        except Exception as e:
            call([
                'osascript', '-e',
                'display notification "Error" with title "' + str(e) + '"'
            ])
예제 #6
0
    def __init__(self):
        try:
            self.directory = os.path.abspath(__file__).rsplit('\\', 1)[0] + '/'
            self.file_name = self.directory + 'notifscript.ps1'
            if len(sys.argv) == 2:
                # self.UDPBroadcastReceivePort = 4090

                self.UDPBroadcastReceivePort = int(sys.argv[1])
                self.UDPBroadcastReceiver()
            else:
                printMessage('ERROR args',
                             'python ' + __file__ + ' UDPBroadcastReceivePort')
                call([
                    'powershell', '-ExecutionPolicy', 'Bypass', '-File',
                    self.file_name, '-name', 'Error', 'Error args'
                ])
        except Exception as e:
            call([
                'powershell', '-ExecutionPolicy', 'Bypass', '-File',
                self.file_name, '-name', 'Error',
                str(e)
            ])
예제 #7
0
    def UDPBroadcastReceiver(self):
        self.sock = socket(AF_INET, SOCK_DGRAM)
        self.sock.bind(('', self.UDPBroadcastReceivePort))

        messg = 'Textcast enabled on port ' + str(self.UDPBroadcastReceivePort)
        call([
            'osascript', '-e',
            'display notification "' + messg + '" with title "Enabled"'
        ])

        while True:
            msg = self.getInputUDP()
            if (msg is None):
                continue

            message = msg['msg']
            sender = msg['address']
            senderIP = sender[0]
            senderPort = sender[1]

            printMessage(senderIP, message)

            self.sendMessage(message)
예제 #8
0
    def UDPBroadcastReceiver(self):
        self.sock = socket(AF_INET, SOCK_DGRAM)
        self.sock.bind(('', self.UDPBroadcastReceivePort))

        call([
            'powershell', '-ExecutionPolicy', 'Bypass', '-File',
            self.file_name, '-name', 'Enabled',
            'TextMessage notify enabled on port ' +
            str(self.UDPBroadcastReceivePort)
        ])

        while True:
            msg = self.getInputUDP()
            if (msg is None):
                continue

            message = msg['msg']
            sender = msg['address']
            senderIP = sender[0]
            senderPort = sender[1]

            printMessage(senderIP, message)

            self.sendMessage(message)