Index: embios/trunk/tools/embios.py |
— | — | @@ -947,6 +947,24 @@ |
948 | 948 | self.logger.info(" done\n")
|
949 | 949 |
|
950 | 950 | @command
|
| 951 | + def rmtree(self, path):
|
| 952 | + """
|
| 953 | + Recursively removes a folder
|
| 954 | + <path>: the folder to be removed
|
| 955 | + """
|
| 956 | + handle = self.embios.dir_open(path)
|
| 957 | + while True:
|
| 958 | + try:
|
| 959 | + entry = self.embios.dir_read(handle)
|
| 960 | + if entry.name == "." or entry.name == "..": continue
|
| 961 | + elif entry.attributes & 0x10:
|
| 962 | + self.rmtree(path + "/" + entry.name)
|
| 963 | + else: self.rm(path + "/" + entry.name)
|
| 964 | + except: break
|
| 965 | + self.embios.dir_close(handle)
|
| 966 | + self.rmdir(path)
|
| 967 | +
|
| 968 | + @command
|
951 | 969 | def mv(self, oldname, newname):
|
952 | 970 | """
|
953 | 971 | Renames or moves file or directory <oldname> to <newname>
|
— | — | @@ -983,11 +1001,37 @@ |
984 | 1002 | self.logger.info(" done\n")
|
985 | 1003 |
|
986 | 1004 | @command
|
| 1005 | + def gettree(self, remotepath, localpath, buffer = False, buffsize = "10000"):
|
| 1006 | + """
|
| 1007 | + Downloads a directory tree
|
| 1008 | + <remotepath>: path on the device
|
| 1009 | + <localpath>: path on the computer
|
| 1010 | + [buffer]: buffer address (optional)
|
| 1011 | + [buffsize]: buffer size (optional)
|
| 1012 | + """
|
| 1013 | + if buffer == False: buffer = self.embios.lib.dev.usermem.lower
|
| 1014 | + else: buffer = self._hexint(buffer)
|
| 1015 | + buffsize = self._hexint(buffsize)
|
| 1016 | + try: os.mkdir(localpath)
|
| 1017 | + except: pass
|
| 1018 | +
|
| 1019 | + handle = self.embios.dir_open(remotepath)
|
| 1020 | + while True:
|
| 1021 | + try:
|
| 1022 | + entry = self.embios.dir_read(handle)
|
| 1023 | + if entry.name == "." or entry.name == "..": continue
|
| 1024 | + elif entry.attributes & 0x10:
|
| 1025 | + self.gettree(remotepath + "/" + entry.name, localpath + "/" + entry.name, buffer, buffsize)
|
| 1026 | + else: self.get(remotepath + "/" + entry.name, localpath + "/" + entry.name, buffer, buffsize)
|
| 1027 | + except: break
|
| 1028 | + self.embios.dir_close(handle)
|
| 1029 | +
|
| 1030 | + @command
|
987 | 1031 | def put(self, localname, remotename, buffer = False, buffsize = "10000"):
|
988 | 1032 | """
|
989 | 1033 | Uploads a file
|
| 1034 | + <localname>: filename on the computer
|
990 | 1035 | <remotename>: filename on the device
|
991 | | - <localname>: filename on the computer
|
992 | 1036 | [buffer]: buffer address (optional)
|
993 | 1037 | [buffsize]: buffer size (optional)
|
994 | 1038 | """
|
— | — | @@ -1012,6 +1056,31 @@ |
1013 | 1057 | self.logger.info(" done\n")
|
1014 | 1058 |
|
1015 | 1059 | @command
|
| 1060 | + def puttree(self, localpath, remotepath, buffer = False, buffsize = "10000"):
|
| 1061 | + """
|
| 1062 | + Uploads a directory tree
|
| 1063 | + <localpath>: path on the computer
|
| 1064 | + <remotepath>: path on the device
|
| 1065 | + [buffer]: buffer address (optional)
|
| 1066 | + [buffsize]: buffer size (optional)
|
| 1067 | + """
|
| 1068 | + if buffer == False: buffer = self.embios.lib.dev.usermem.lower
|
| 1069 | + else: buffer = self._hexint(buffer)
|
| 1070 | + buffsize = self._hexint(buffsize)
|
| 1071 | + try: self.mkdir(remotepath)
|
| 1072 | + except: pass
|
| 1073 | + pathlen = len(localpath)
|
| 1074 | + for d in os.walk(localpath):
|
| 1075 | + prefix = remotepath + "/" + d[0].replace("\\", "/")[pathlen:] + "/"
|
| 1076 | + for dir in d[1]:
|
| 1077 | + if dir != ".svn":
|
| 1078 | + try: self.mkdir(prefix + dir)
|
| 1079 | + except: pass
|
| 1080 | + for f in d[2]:
|
| 1081 | + if not prefix.find("/.svn/") > -1:
|
| 1082 | + self.put(d[0] + "/" + f, prefix + f, buffer, buffsize)
|
| 1083 | +
|
| 1084 | + @command
|
1016 | 1085 | def ls(self, path = "/"):
|
1017 | 1086 | """
|
1018 | 1087 | Lists all files in the specified path
|