freemyipod r517 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r516‎ | r517 | r518 >
Date:01:29, 5 February 2011
Author:farthen
Status:new
Tags:
Comment:
emcore tools: Fix indentation
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)
  • /emcore/trunk/tools/libemcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -85,7 +85,7 @@
8686 logger.write(doc[function]['documentation']+"\n", 4)
8787 logger.write("\n")
8888 logger.write("\n")
89 -
 89+
9090 if errormsg:
9191 logger.error(str(errormsg)+"\n")
9292 exit(2)
@@ -134,7 +134,7 @@
135135 self.logger.error("No emCORE device found!\n")
136136 exit(1)
137137 self.getinfo("version")
138 -
 138+
139139 def _parsecommand(self, func, args):
140140 # adds self to the commandline args.
141141 # this is needed because the functions need access to their class.
@@ -182,7 +182,7 @@
183183 elif something.lower() in falselist:
184184 return False
185185 raise ArgumentTypeError("bool", "'%s'" % something)
186 -
 186+
187187 @staticmethod
188188 def _hexint(something):
189189 """
@@ -309,7 +309,7 @@
310310 f.write(self.emcore.read(addr, size))
311311 f.close()
312312 self.logger.info("done\n")
313 -
 313+
314314 @command
315315 def uploadint(self, addr, integer):
316316 """
@@ -324,7 +324,7 @@
325325 data = struct.pack("I", integer)
326326 self.emcore.write(addr, data)
327327 self.logger.info("Integer '0x%X' written successfully to 0x%X\n" % (integer, addr))
328 -
 328+
329329 @command
330330 def downloadint(self, addr):
331331 """
@@ -335,7 +335,7 @@
336336 data = self.emcore.read(addr, 4)
337337 integer = struct.unpack("I", data)[0]
338338 self.logger.info("Read '0x%X' from address 0x%X\n" % (integer, addr))
339 -
 339+
340340 @command
341341 def i2cread(self, bus, slave, addr, size):
342342 """
@@ -354,7 +354,7 @@
355355 self.logger.info("Data read from I2C:\n")
356356 for index, byte in enumerate(bytes):
357357 self.logger.info("%02X: %02X\n" % (index, byte))
358 -
 358+
359359 @command
360360 def i2cwrite(self, bus, slave, addr, *args):
361361 """
@@ -374,7 +374,7 @@
375375 self.logger.info("Writing data to I2C...\n")
376376 self.emcore.i2cwrite(bus, slave, addr, data)
377377 self.logger.info("done\n")
378 -
 378+
379379 @command
380380 def console(self):
381381 """
@@ -384,7 +384,7 @@
385385 resp = self.emcore.usbcread()
386386 self.logger.write(resp.data)
387387 time.sleep(0.1 / resp.maxsize * (resp.maxsize - len(resp.data)))
388 -
 388+
389389 @command
390390 def writeusbconsole(self, *args):
391391 """
@@ -396,7 +396,7 @@
397397 text = text[:-1]
398398 self.logger.info("Writing '%s' to the usb console\n" % text)
399399 self.emcore.usbcwrite(text)
400 -
 400+
401401 @command
402402 def readdevconsole(self, bitmask):
403403 """
@@ -422,7 +422,7 @@
423423 text = text[:-1]
424424 self.logger.info("Writing '%s' to the device consoles identified with 0x%X\n" % (text, bitmask))
425425 self.emcore.cwrite(text, bitmask)
426 -
 426+
427427 @command
428428 def flushconsolebuffers(self, bitmask):
429429 """
@@ -432,7 +432,7 @@
433433 bitmask = self._hexint(bitmask)
434434 self.logger.info("Flushing consoles identified with the bitmask 0x%X\n" % bitmask)
435435 self.emcore.cflush(bitmask)
436 -
 436+
437437 @command
438438 def getprocinfo(self):
439439 """
@@ -497,7 +497,7 @@
498498 threadaddr = self._hexint(threadaddr)
499499 self.logger.info("Suspending the thread with the threadaddr 0x%X\n" % threadaddr)
500500 self.emcore.suspendthread(threadaddr)
501 -
 501+
502502 @command
503503 def resumethread(self, threadaddr):
504504 """
@@ -506,7 +506,7 @@
507507 threadaddr = self._hexint(threadaddr)
508508 self.logger.info("Resuming the thread with the threadaddr 0x%X\n" % threadaddr)
509509 self.emcore.resumethread(threadaddr)
510 -
 510+
511511 @command
512512 def killthread(self, threadaddr):
513513 """
@@ -515,7 +515,7 @@
516516 threadaddr = self._hexint(threadaddr)
517517 self.logger.info("Killing the thread with the threadaddr 0x%X\n" % threadaddr)
518518 self.emcore.killthread(threadaddr)
519 -
 519+
520520 @command
521521 def createthread(self, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state):
522522 """
@@ -552,7 +552,7 @@
553553 with f:
554554 data = self.emcore.run(f.read())
555555 self.logger.info("Executed emCORE application as thread 0x%X\n" % data.thread)
556 -
 556+
557557 @command
558558 def execimage(self, addr):
559559 """
@@ -674,7 +674,7 @@
675675 data = self.emcore.read(destination, sha1size)
676676 hash = ord(data)
677677 self.logger.info("The generated hash is 0x%X\n" % hash)
678 -
 678+
679679 @command
680680 def ipodnano2g_getnandinfo(self):
681681 """
@@ -687,7 +687,7 @@
688688 self.logger.info("Number of blocks: %d\n" % data["blocks"])
689689 self.logger.info("Number of user blocks: %d\n" % data["userblocks"])
690690 self.logger.info("Pages per block: %d\n" % data["pagesperblock"])
691 -
 691+
692692 @command
693693 def ipodnano2g_nandread(self, addr, start, count, doecc=True, checkempty=True):
694694 """
@@ -708,7 +708,7 @@
709709 (count, start, addr))
710710 self.emcore.ipodnano2g_nandread(addr, start, count, doecc, checkempty)
711711 self.logger.info("done\n")
712 -
 712+
713713 @command
714714 def ipodnano2g_nandwrite(self, addr, start, count, doecc=True):
715715 """
@@ -727,7 +727,7 @@
728728 (count, start, addr))
729729 self.emcore.ipodnano2g_nandwrite(addr, start, count, doecc)
730730 self.logger.info("done\n")
731 -
 731+
732732 @command
733733 def ipodnano2g_nanderase(self, addr, start, count):
734734 """
@@ -744,7 +744,7 @@
745745 (count, start, addr))
746746 self.emcore.ipodnano2g_nanderase(addr, start, count)
747747 self.logger.info("done\n")
748 -
 748+
749749 @command
750750 def ipodnano2g_dumpnand(self, filenameprefix):
751751 """
@@ -777,7 +777,7 @@
778778 sparefile.close()
779779 statusfile.close()
780780 self.logger.info("done\n")
781 -
 781+
782782 @command
783783 def ipodnano2g_wipenand(self, filename, force=False):
784784 """
@@ -805,7 +805,7 @@
806806 statusfile.write(self.emcore.read(0x08000000, 0x00000100))
807807 statusfile.close()
808808 self.logger.info("done\n")
809 -
 809+
810810 @command
811811 def ipodclassic_writebbt(self, tempaddr, filename):
812812 """
@@ -822,7 +822,7 @@
823823 data = self.emcore.ipodclassic_writebbt(f.read(), tempaddr)
824824 f.close()
825825 self.logger.info(" done\n")
826 -
 826+
827827 @command
828828 def getvolumeinfo(self, volume):
829829 """
@@ -836,7 +836,7 @@
837837 self.logger.info("Vendor: %s\n" % data["vendor"])
838838 self.logger.info("Product: %s\n" % data["product"])
839839 self.logger.info("Revision: %s\n" % data["revision"])
840 -
 840+
841841 @command
842842 def readrawstorage(self, volume, sector, count, addr):
843843 """
@@ -849,7 +849,7 @@
850850 self.logger.info("Reading volume %s sectors %X - %X to %08X..." % (volume, sector, sector + count - 1, addr))
851851 self.emcore.storage_read_sectors_md(volume, sector, count, addr)
852852 self.logger.info("done\n")
853 -
 853+
854854 @command
855855 def writerawstorage(self, volume, sector, count, addr):
856856 """
@@ -862,7 +862,7 @@
863863 self.logger.info("Writing %08X to volume %s sectors %X - %X..." % (addr, volume, sector, sector + count - 1))
864864 self.emcore.storage_write_sectors_md(volume, sector, count, addr)
865865 self.logger.info("done\n")
866 -
 866+
867867 @command
868868 def readrawstoragefile(self, volume, sector, count, file, buffsize = 0x100000, buffer = None):
869869 """
@@ -900,7 +900,7 @@
901901 finally:
902902 f.close()
903903 self.logger.info("done\n")
904 -
 904+
905905 @command
906906 def writerawstoragefile(self, volume, sector, count, file, buffsize = 0x100000, buffer = None):
907907 """
@@ -942,7 +942,7 @@
943943 finally:
944944 f.close()
945945 self.logger.info("done\n")
946 -
 946+
947947 @command
948948 def mkdir(self, dirname):
949949 """
@@ -951,7 +951,7 @@
952952 self.logger.info("Creating directory %s..." % dirname)
953953 self.emcore.dir_create(dirname)
954954 self.logger.info(" done\n")
955 -
 955+
956956 @command
957957 def rmdir(self, dirname):
958958 """
@@ -960,7 +960,7 @@
961961 self.logger.info("Removing directory %s..." % dirname)
962962 self.emcore.dir_remove(dirname)
963963 self.logger.info(" done\n")
964 -
 964+
965965 @command
966966 def rm(self, filename):
967967 """
@@ -969,7 +969,7 @@
970970 self.logger.info("Removing file %s..." % filename)
971971 self.emcore.file_unlink(filename)
972972 self.logger.info(" done\n")
973 -
 973+
974974 @command
975975 def rmtree(self, path):
976976 """
@@ -987,7 +987,7 @@
988988 except: break
989989 self.emcore.dir_close(handle)
990990 self.rmdir(path)
991 -
 991+
992992 @command
993993 def mv(self, oldname, newname):
994994 """
@@ -996,7 +996,7 @@
997997 self.logger.info("Renaming %s to %s..." % (oldname, newname))
998998 self.emcore.file_rename(oldname, newname)
999999 self.logger.info(" done\n")
1000 -
 1000+
10011001 @command
10021002 def get(self, remotename, localname, buffsize = 0x10000, buffer = None):
10031003 """
@@ -1036,7 +1036,7 @@
10371037 finally:
10381038 f.close()
10391039 self.logger.info(" done\n")
1040 -
 1040+
10411041 @command
10421042 def gettree(self, remotepath, localpath, buffsize = 0x10000, buffer = None):
10431043 """
@@ -1071,7 +1071,7 @@
10721072 self.emcore.free(buffer)
10731073 finally:
10741074 self.emcore.dir_close(handle)
1075 -
 1075+
10761076 @command
10771077 def put(self, localname, remotename, buffsize = 0x10000, buffer = None):
10781078 """
@@ -1113,7 +1113,7 @@
11141114 finally:
11151115 f.close()
11161116 self.logger.info(" done\n")
1117 -
 1117+
11181118 @command
11191119 def puttree(self, localpath, remotepath, buffsize = 0x10000, buffer = None):
11201120 """
@@ -1146,7 +1146,7 @@
11471147 finally:
11481148 if malloc == True:
11491149 self.emcore.free(buffer)
1150 -
 1150+
11511151 @command
11521152 def ls(self, path = "/"):
11531153 """
Index: emcore/trunk/tools/libemcore.py
@@ -617,7 +617,7 @@
618618 self.lib.monitorcommand(struct.pack("IIII", 58, state, 0, 0), "III", (None, None, None))
619619 if state != 0: self.logger.debug("Enabled FAT flushing\n")
620620 else: self.logger.debug("Disabled FAT flushing\n")
621 -
 621+
622622 @command(timeout = 30000)
623623 def file_open(self, filename, mode):
624624 """ Opens a file and returns the handle """
@@ -902,8 +902,8 @@
903903 """ Frees all memory allocations created by the monitor thread """
904904 self.logger.debug("Freeing all memory allocations created by the monitor thread\n")
905905 return self.lib.monitorcommand(struct.pack("IIII", 57, 0, 0, 0), "III", (None, None, None))
906 -
907906
 907+
908908 class Lib(object):
909909 def __init__(self, logger):
910910 self.logger = logger
@@ -966,7 +966,7 @@
967967
968968 self.interface = 0
969969 self.timeout = 100
970 -
 970+
971971 self.connect()
972972 self.findEndpoints()
973973