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

Function dir_json

src/updateserver/python2/updateserver.py:125–149  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

123
124
125def 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
152def get_MD5(filename):

Callers 1

__send_dirMethod · 0.70

Calls 2

appendMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected