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