Esempio n. 1
0
	def send_text(self):
		if self.send_msg == True:
			server = TextMessage()
			server.send_message(self.message)			
			print('message '+str(self.message_counter)+' sent @: '+self._get_current_datetime())
			print('message '+str(self.message_counter)+' info: '+self.message)
			print('\n')
			self.message_counter += 1			
Esempio n. 2
0
	def notify(self):
		for stock_info in self._stock_dict.items():
			stock_name = stock_info[0]
			wanted_stock_price = stock_info[1]
			if (self._stock_is_greater(stock_name, wanted_stock_price)):
				message = self._message_to_send(stock_name)
				server = TextMessage()
				server.send_message(message)
				print(message)
				self._message_sent = True
Esempio n. 3
0
class TextMessageTest(unittest.TestCase):

    tm = TextMessage()

    def test_normalizes_strings(self):
        test = {
            "Menu ": "MENU",
            "Menù": "MENU",
            "A, B": "A B",
            "A,B": "A B",
        }
        for str_in, str_out in test.items():
            self.assertEqual(self.tm.normalize_string(str_in), str_out)

    def test_encodes_menu(self):
        [can1, can2] = self.tm.encode_instpanel("ABCDEFGHIJ", True)

        self.assertEqual(can1.arbitration_id, 0xA394021)
        self.assertEqual(self.byte_to_string(can1.data), "101A30D38F411493")

        self.assertEqual(can2.arbitration_id, 0xA394021)
        self.assertEqual(self.byte_to_string(can2.data), "111A515000000000")

    def test_encodes_string(self):
        [can1, can2] = self.tm.encode_instpanel("ABCDEFGHIJ", False)

        self.assertEqual(can1.arbitration_id, 0xA394021)
        self.assertEqual(self.byte_to_string(can1.data), "101630D38F411493")

        self.assertEqual(can2.arbitration_id, 0xA394021)
        self.assertEqual(self.byte_to_string(can2.data), "1116515000000000")

    def byte_to_string(self, bytearray):
        return ''.join('{:02x}'.format(x) for x in bytearray).upper()
#Use this to call the sms function
#It is for sending SMS using AT commands - version v3
"""
## The packges below must be installed in advance
## install python-setuptools
## install pyserial
 
import serial
import time
import sys

from TextMessage import TextMessage

if len(sys.argv) > 2:
	for i in range( 0,int(sys.argv[2]) ):
		sms = TextMessage(i)
		sms.getSimNumber()
		sms.connectDevice()
		sms.getPrep()
		sms.deleteAllMessage()
else:
	sms = TextMessage(int(sys.argv[1]))
	sms.getSimNumber()
	sms.connectDevice()
	sms.getPrepDaemon()
	sms.deleteAllMessage()


#Main function that calls other functions - Makes script reusable
def main():
	pass
Esempio n. 5
0
#!/usr/bin/env python
"""
#Use this to call the sms function
#It is for sending SMS using AT commands - version v3
"""
## The packges below must be installed in advance
## install python-setuptools
## install pyserial
 
import serial
import time
import sys

from TextMessage import TextMessage

sms = TextMessage( int(sys.argv[1]) )
sms.connectDevice()
sms.getSimNumber()
sms.storeMessageDaemon()
sms.disconnectDevice()


 
def main():
	pass
 
if __name__ == "__main__":
	main()
Esempio n. 6
0
#Use this to call the sms function
#It is for sending SMS using AT commands - version v3
"""
## The packges below must be installed in advance
## install python-setuptools
## install pyserial

import serial
import time
import sys

from TextMessage import TextMessage

if len(sys.argv) > 2:
    for i in range(0, int(sys.argv[2])):
        sms = TextMessage(i)
        sms.connectDevice()
        sms.getPrep()
        sms.deleteAllMessage()
else:
    sms = TextMessage(int(sys.argv[1]))
    sms.connectDevice()
    sms.getPrep()
    sms.deleteAllMessage()


#Main function that calls other functions - Makes script reusable
def main():
    pass

#Use this to call the sms function
#It is for sending SMS using AT commands - version v3
"""
## The packges below must be installed in advance
## install python-setuptools
## install pyserial

import serial
import time
import sys

from TextMessage import TextMessage

if len(sys.argv) > 2:
    for i in range(0, int(sys.argv[2])):
        sms = TextMessage(i)
        sms.connectDevice()
        sms.getPrep()
        sms.deleteAllMessage()
else:
    sms = TextMessage(int(sys.argv[1]))
    sms.connectDevice()
    sms.getPrep()
    sms.deleteAllMessage()


# Main function that calls other functions - Makes script reusable
def main():
    pass

Esempio n. 8
0
#Use this to call the sms function
#It is for sending SMS using AT commands - version v3
"""
## The packges below must be installed in advance
## install python-setuptools
## install pyserial

import serial
import time
import sys

from TextMessage import TextMessage

if len(sys.argv) > 2:
    for i in range(0, int(sys.argv[2])):
        sms = TextMessage(i)
        sms.getSimNumber()
        sms.connectDevice()
        sms.getPrep()
        sms.deleteAllMessage()
else:
    sms = TextMessage(int(sys.argv[1]))
    sms.getSimNumber()
    sms.connectDevice()
    sms.getPrepDaemon()
    sms.deleteAllMessage()


#Main function that calls other functions - Makes script reusable
def main():
    pass
Esempio n. 9
0
#!/usr/bin/env python
"""
#Use this to call the sms function
#It is for sending SMS using AT commands - version v3
"""
## The packges below must be installed in advance
## install python-setuptools
## install pyserial

import serial
import time
import sys

from TextMessage import TextMessage

sms = TextMessage(int(sys.argv[1]))
sms.connectDevice()
sms.getSimNumber()
sms.storeMessageDaemon()
sms.disconnectDevice()


def main():
    pass


if __name__ == "__main__":
    main()
Esempio n. 10
0
import time
import sys

from TextMessage import TextMessage
 
if len(sys.argv) > 1:
	portNumber = sys.argv[1]
	phoneNumber = sys.argv[2]
	message = ""	
	if len(sys.argv) >= 3:
		for i in range(3, len(sys.argv)):
			message = message + " " + sys.argv[i] 
 
		message = message.strip()
	print "echo "+"'number = " + phoneNumber + ", message = " + message + "'"
	sms = TextMessage(portNumber,phoneNumber, message)
else:
	sms = TextMessage('0')	

 
sms.connectDevice()
sms.getSimNumber()
sms.sendMessage()
sms.storeSentMessage()
sms.disconnectDevice()
 
#Main function that calls other functions - Makes script reusable
def main():
	pass
 
if __name__ == "__main__":
Esempio n. 11
0
from TextMessage import TextMessage
from FiatProtocol import *
import argparse
import re


parser = argparse.ArgumentParser()
parser.add_argument("candump_trace", help="path to the log file generated by candump")
parser.add_argument("--retime", help="shift timestamps starting from zero", action="store_true")
parser.add_argument("--nospam", help="does not print spam messages", action="store_true")
args = parser.parse_args()
p = re.compile('\(([0-9]+)\.([0-9]+)\) (.+) ([A-Z0-9]+)#([A-Z0-9]*)')

initial_timestamp = None
text_message = []
text_decoder = TextMessage()
known = 0
unknown = 0


with open(args.candump_trace) as trace:
    for line in trace:
        matches = p.match(line)
        timestamp_int = int(matches[1])
        timestamp_dec = matches[2]
        can_interface = matches[3]
        arb_id_hex = matches[4]
        payload_hex = matches[5]

        arb_id = int(arb_id_hex, 16)
        topic_hex = arb_id_hex[0:4]