MCPcopy Create free account
hub / github.com/Hieromon/AutoConnect / dir_json

Function dir_json

src/updateserver/python3/updateserver.py:121–145  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

119
120
121def 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
148def get_MD5(filename):

Callers 1

__send_dirMethod · 0.70

Calls 2

appendMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected