def check_integrity(): s3 = Offsite.get_s3_interface() offsite_keys = s3.list_files() for key in offsite_keys: filename = key.name filename_on_disk = os.path.join(settings.NIMBUS_DEFAULT_ARCHIVE, filename) if os.path.exists(filename_on_disk): print "Checking",filename,"...", s3_md5 = key.metadata.get('nimbus-md5', None) local_md5 = outils.md5_for_large_file(filename_on_disk) is_ok = True if s3_md5: if s3_md5 != local_md5: is_ok = False else: if not '-' in key.etag: s3_md5 = key.etag.strip('"\'') if local_md5 != s3_md5: is_ok = False else: size = os.path.getsize(filename_on_disk) if size != key.size: is_ok = False if is_ok: print "Ok" else: print "Error" f = utils.filesizeformat size = os.path.getsize(filename_on_disk) print "Local file size: {0}. Remote file size: {1}".format(f(size), f(f.size)) print "Local file md5: {0}. Remote file md5: {1}".format(local_md5, s3_md5)
def update_db(self): """Metodo obrigatorio para todas as classes Graphics""" offsite = self.offsite_if_active() if offsite: plan_total = offsite.plan_size try: s3 = Offsite.get_s3_interface() now_used = s3.get_size() except (URLError, S3AuthError), error: now_used = 0.0 new_data = OffsiteGraphicsData() new_data.total = plan_total new_data.used = now_used new_data.save()
def update_db(self): """Metodo obrigatorio para todas as classes Graphics""" offsite = self.offsite_if_active() if offsite: plan_total = offsite.plan_size try: s3 = Offsite.get_s3_interface() now_used = s3.get_size() except (URLError, S3AuthError), error: now_used = 0.0 new_data = OffsiteGraphicsData() new_data.total = plan_total new_data.used = now_used new_data.save()
def __init__(self): self.s3 = Offsite.get_s3_interface()