예제 #1
0
def main(argv):
    script, flag, filename = sys.argv

    if flag == '-e':
        coder.encode(filename, "_Encoded4.pi", coder.getPiWithFourHex(), 4)
    elif flag == '-d':
        coder.decode(filename, "_Decoded4.pi", coder.getPiWithFourHex(), 4)
예제 #2
0
def main(argv):
    script, flag, filename = sys.argv

    if flag == '-e':
        coder.encode(filename, "_Encoded4.pi", coder.getPiWithFourHex(), 4)
    elif flag == '-d':
        coder.decode(filename, "_Decoded4.pi", coder.getPiWithFourHex(), 4)
예제 #3
0
def main(argv):
    script, flag, filename = sys.argv

    if flag == '-e':
        coder.encode(filename, filename + "_Encoded.pi",
                     coder.getPiWithTwoHex(), 2)
    elif flag == '-d':
        coder.decode(filename, "_Decoded.pi", coder.getPiWithTwoHex(), 2)
예제 #4
0
def main(argv):
    script, flag, filename = sys.argv


    if flag == '-e':
        coder.encode(filename, filename+"_Encoded.pi", coder.getPiWithTwoHex(), 2)
    elif flag == '-d':
        coder.decode(filename, "_Decoded.pi", coder.getPiWithTwoHex(), 2)
예제 #5
0
def decode_image():
    validation()
    file_name = file_entry.get()
    key = key_entry.get()
    text = decode(file_name, key)
    text_box.delete('1.0', END)
    text_box.insert('1.0', text)
    showinfo(title='Выполнено', message='Декодирование завершено')
예제 #6
0
파일: server.py 프로젝트: skarone/PipeL
def run():
	# Create a TCP/IP socket to listen on
	server = socket.socket( socket.AF_INET, socket.SOCK_STREAM )

	# Prevent from "address already in use" upon server restart
	server.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )

	# Bind the socket to port 8081 on all interfaces
	server_address = ( 'localhost', 8081 )
	print 'starting up on %s port %s' % server_address
	server.bind( server_address )

	# Listen for connections
	server.listen( 5 )


	while 1:
		# Wait for one incomming connection
		connection, client_address = server.accept()
		print 'connection from', connection.getpeername()
		# Let's receive something
		data = connection.recv( 4096 )
		if not data: break

		#send it back nicely formatted
		data      = coder.decode('monigota', data )
		dbase     = clm.ClientsManager()
		dataSplit = data.split( '/' )
		mac       = dataSplit[0]
		usr       = dataSplit[1]
		serial    = dataSplit[2]
		result    = dbase.clientInstall( serial )
		if result == True:
			print 'Received ', mac,usr,serial
			finalData = serial + '+' + mac + '+' + usr + 'monigota'
			finalData = coder.encode( 'gotamoni', finalData )
		else:
			finalData = result
		connection.send( finalData )
		print 'Response sent!'

		
		# close the connection from our side
		connection.shutdown( socket.SHUT_RD | socket.SHUT_WR )
		connection.close()
		print "Connection closed."
	# And stop listening
	server.close()
예제 #7
0
def deckFormat():
    f = open('thedeck', 'r')
    f1 = f.readlines()
    thedeck = []
    for i in f1:
        if i != '\n':
            line = decode(i, CODE_KEY)
            x = line.split(' - ', 2)
            y = x[0].split(' ')
            r = []
            for j in y:
                r.append(j)
            r.append(x[1])
            r.append(x[2])
            thedeck.append(r)
    return thedeck
예제 #8
0
def main ():
	atexit.register(goodbye)

	rover = Rover()
	lcd = LCD()

	card_idle_msg = 'Please insert   a memory card.'
	output = IdleOutput(card_idle_msg)
	input = InputHandler()
	message = LCD.get_message()

	while (True):
		message_old = message
		files = glob.glob('/media/*/rover.bin')
		if (len(files) > 0):
			try:
				with open(files[0]) as f:
						message = coder.decode(f.read()).strip().replace("\n", chr(0x17))
						if message == '*FIX*':
							if Rover.broken:
								Rover.fix()
								input.unsubscribe(output)
								output = ProgressbarOutput('Updating...')
								output = IdleOutput('Firmware has    been updated.')
						elif Rover.broken:
							pass
						elif message == '*INFECT*':
							if not Rover.virus:
								Rover.infect()
								input.unsubscribe(output)
								output = ProgressbarOutput('Infecting...')
								output = IdleOutput('System has been infected.')
						elif message == '*AID*':
							if Rover.virus:
								Rover.aid()
								input.unsubscribe(output)
								output = ProgressbarOutput('Cleaning virus..')
								output = IdleOutput('Virus has been  cleaned.')
						elif message == '*BREAK*':
							if not Rover.broken:
								Rover.corrupt()
								input.unsubscribe(output)
								output = BrokenOutput('Firmware has    been corrupted.')
								input.subscribe(output)
						elif message != message_old or not isinstance(output, CardOutput):
							print 'Switching to card output'
							input.unsubscribe(output)
							output = CardOutput(message)
							input.subscribe(output)
			except:
				message = ''
				continue
		elif Rover.broken:
			if not isinstance(output, BrokenOutput):
				print 'Going to the broken mode'
				input.unsubscribe(output)
				output = BrokenOutput('System is broken')
				input.subscribe(output)
		elif (not isinstance(output, IdleOutput) or message != card_idle_msg):
			print 'Going to idle'
			input.unsubscribe(output)
			output = IdleOutput(card_idle_msg)
			message = output.get_text()
		time.sleep(0.1)
예제 #9
0
#!/usr/bin/python

import coder

msg = "abcdefghz09'/?"

print ">\n" + coder.encode(msg) + "<\n"

print ">\n" + coder.decode(coder.encode(msg)) + "<\n"
예제 #10
0
 def test_decode_inverts_encode(self, s):
   assert decode(encode(s)) == s
예제 #11
0
    def __init__(self,motiondata,imagedata,num_instruction=None):

        self.pixels = None

        self.leftangle = 90
        self.rightangle = 90

        self.progress_ui = Progress()

        self.prev_x = -1
        self.prev_y = -1
        self.progress = -1

        self.levels = []

        self.canvas = Image.new("RGBA",(1000*PIX_PER_MM,1200*PIX_PER_MM),color=(255,255,255,255))
        self.draw = ImageDraw.Draw(self.canvas)

        self.redlayer = Image.new("RGBA",(1000*PIX_PER_MM,1200*PIX_PER_MM),color=(255,255,255,0))
        self.draw2 = ImageDraw.Draw(self.redlayer)

        self.blacklayer = Image.new("RGBA",(1000*PIX_PER_MM,1200*PIX_PER_MM),color=(255,255,255,0))
        self.draw3 = ImageDraw.Draw(self.blacklayer)

        self.model = Blackstripes_MKII()

        self.instructions_executed = 0.0
        self.num_instruction = float(num_instruction)

        if imagedata != None:
            self.pixels = []
            self.imagedata = open(imagedata,'rb')
            b_counter = 0
            try:
                byte = self.imagedata.read(1)
                while byte != "":
                    sample = struct.unpack('B',byte)
                    if b_counter > 5:
                        self.pixels.append(sample[0])
                    else:
                        self.levels.append(sample[0])
                    byte = self.imagedata.read(1)
                    b_counter += 1
            finally:
                self.imagedata.close()

        self.motiondata = open(motiondata,'rb')
        try:
            byte = self.motiondata.read(16)
            while byte != "":
                sample = struct.unpack('=LLLL',byte)
                left_engine,right_engine,p1,p2,p3,even,speed = coder.decode(sample[0])
                sol1 = sample[1]
                sol2 = sample[2] 
                sol3 = sample[3]
                self._draw(left_engine,right_engine,p1,p2,p3,even,speed,sol1,sol2,sol3)
                byte = self.motiondata.read(16)
        finally:
            self.canvas.paste(self.redlayer,self.redlayer)
            self.canvas.paste(self.blacklayer,self.blacklayer)
            self.canvas.save("blackstripes_preview.png")
            self.motiondata.close()
예제 #12
0
#!/usr/bin/env python

import coder
import sys

msg = ''

for line in sys.stdin:
    msg += line

print coder.decode(msg)