From 570323f017715a323a63e510484568dbfd242bf8 Mon Sep 17 00:00:00 2001 From: David Voswinkel Date: Sun, 2 Aug 2009 16:30:01 +0200 Subject: [PATCH] add convert and webpy --- scripts/conv_rle.py | 56 +++++++++++++++++++++++++++++++++++++++++++ scripts/dev_server.py | 40 +++++++++++++++++++++++++++++++ scripts/link_webpy.sh | 2 ++ scripts/webpy | 1 + 4 files changed, 99 insertions(+) create mode 100644 scripts/conv_rle.py create mode 100644 scripts/dev_server.py create mode 100644 scripts/link_webpy.sh create mode 160000 scripts/webpy diff --git a/scripts/conv_rle.py b/scripts/conv_rle.py new file mode 100644 index 0000000..219c20b --- /dev/null +++ b/scripts/conv_rle.py @@ -0,0 +1,56 @@ +import binascii +import os +import sys +import time + + +LEN = 2**16+8 +TARGET="/Users/david/Devel/arch/avr/code/quickdev16/avr/usbload" +data = open(sys.argv[1],"r").read() + +print "Load %s (%i) bytes" % (sys.argv[1],len(data)) +data = data[:LEN] +print "Use (%i) bytes" % (len(data)) +data = binascii.rlecode_hqx(data) +print "RLE crunch (%i) bytes" % (len(data)) +binfile = open("/tmp/loader.rle","w") +binfile.write(data) +binfile.close() +cfile = open("/tmp/loader.c","w") +hfile = open("/tmp/loader.h","w") + +hfile.write(''' +#ifndef __FIFO_H__ +#define __FIFO_H__ + +#define ROM_SIZE %i + +#endif +''' % len(data)) + +cfile.write('''/* +File: %s +Time: %s +*/ +#include +#include + +const char _rom[ROM_SIZE] PROGMEM = { +''' % (sys.argv[1],time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()))) + +for idx,c in enumerate(data): + c = ord(c) + if idx +
+ +
+ +
+""" + + def POST(self): + obj = web.input(myfile={}) + filedir = '/Users/david/Devel/arch/avr/code/quickdev16/roms' # change this to the directory you want to store the file in. + if 'myfile' in obj: + web.debug("Upload file %s" % obj['myfile'].filename) + filepath = obj.myfile.filename.replace('\\','/') + filename = filepath.split('/')[-1] + foutname = filedir +'/'+ filename + web.debug("Write to %s" % foutname) + fout = open(foutname,'w') + fout.write( obj.myfile.file.read()) + fout.close() + + cmd = "ucon64 --port=usb --xsnesram %s " % foutname + web.debug("Execute: %s" % cmd) + p = Popen(cmd, shell=True, bufsize=128, + stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + stdout,stderr = p.communicate() + return '''Out: %s
Err: %s''' % ( + stdout.replace("\n","
").replace("\r","
"), + stderr.replace("\n","
")) + raise web.seeother('/upload') + +if __name__ == "__main__": + app = web.application(urls, globals()) + app.run() diff --git a/scripts/link_webpy.sh b/scripts/link_webpy.sh new file mode 100644 index 0000000..4283ceb --- /dev/null +++ b/scripts/link_webpy.sh @@ -0,0 +1,2 @@ +ln -s `pwd`/webpy/web . + diff --git a/scripts/webpy b/scripts/webpy new file mode 160000 index 0000000..2a5acf5 --- /dev/null +++ b/scripts/webpy @@ -0,0 +1 @@ +Subproject commit 2a5acf5a834f9c2fd98d5c2be563429821feab3b