(path)
| 123 | |
| 124 | |
| 125 | def dir_json(path): |
| 126 | d = list() |
| 127 | for entry in os.listdir(path): |
| 128 | e = {'name': entry} |
| 129 | if os.path.isdir(entry): |
| 130 | e['type'] = "directory" |
| 131 | else: |
| 132 | e['type'] = "file" |
| 133 | if os.path.splitext(entry)[1] == '.bin': |
| 134 | fn = os.path.join(path, entry) |
| 135 | try: |
| 136 | f = open(fn, 'rb') |
| 137 | c = f.read(1) |
| 138 | f.close() |
| 139 | except Exception, e: |
| 140 | logger.info(unicode(e)) |
| 141 | c = '\x00' |
| 142 | if c == '\xe9': |
| 143 | e['type'] = "bin" |
| 144 | mtime = os.path.getmtime(fn) |
| 145 | e['date'] = time.strftime('%x', time.localtime(mtime)) |
| 146 | e['time'] = time.strftime('%X', time.localtime(mtime)) |
| 147 | e['size'] = os.path.getsize(fn) |
| 148 | d.append(e) |
| 149 | return d |
| 150 | |
| 151 | |
| 152 | def get_MD5(filename): |
no test coverage detected