iwla

iwla Commit Details

Date:2015-05-23 16:38:39 (6 years 2 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:79b58f2e1c37a54a3d747748890a5923d5ade6cf
Parents: f3fc24e45ebf1d549c27d1ae1f88975457db9bc3
Message:Add -z option (don't compress)

Changes:
Miwla.py (3 diffs)

File differences

iwla.py
235235
236236
237237
238
239
240
241
242
243
238244
239245
240246
241247
242248
243
244
245
246
249
247250
248251
249252
......
253256
254257
255258
256
259
257260
258261
259262
......
805808
806809
807810
811
812
813
814
808815
809816
810817
def getDBFilename(self, time):
return os.path.join(conf.DB_ROOT, str(time.tm_year), '%02d' % (time.tm_mon), conf.DB_FILENAME)
def _openDB(self, filename, prot='r'):
if self.args.dont_compress:
return open(filename, prot)
else:
return gzip.open(filename, prot)
def _serialize(self, obj, filename):
base = os.path.dirname(filename)
if not os.path.exists(base):
os.makedirs(base)
# TODO : remove return
#return
with open(filename + '.tmp', 'wb+') as f, gzip.open(filename, 'w') as fzip:
with open(filename + '.tmp', 'wb+') as f, self._openDB(filename, 'w') as fzip:
pickle.dump(obj, f)
f.seek(0)
fzip.write(f.read())
if not os.path.exists(filename):
return None
with gzip.open(filename, 'r') as f:
with self._openDB(filename) as f:
return pickle.load(f)
return None
default=False,
help='Reset analysis to a specific date (month/year)')
parser.add_argument('-z', '--dont-compress', dest='dont_compress', action='store_true',
default=False,
help='Don\'t compress databases (bigger but faster)')
args = parser.parse_args()
# Load user conf

Archive Download the corresponding diff file

Branches

Tags