def text2blob(self): #DOC,errno,why = ESSMETS.parseMetsFromFile('/ESSArch/bin/src/testdata/X0000001_METS.xml') DOC,errno,why = ESSMD.parseFromFile('/ESSArch/bin/src/testdata/X0000001_METS.xml') if errno: print why METSstr = etree.tostring(DOC,encoding='UTF-8', xml_declaration=True, pretty_print=True) blob = MySQLdb.escape_string(METSstr) print 'METSstr',METSstr print 'blob',blob #self.table = 'IngestObjectMetadata' ArchiveObjectMetadata_obj = ArchiveObjectMetadata() ArchiveObjectMetadata_obj.ObjectIdentifierValue = ObjectIdentifierValue ArchiveObjectMetadata_obj.ObjectMetadataType = 26 ArchiveObjectMetadata_obj.ObjectMetadataBLOB = blob ArchiveObjectMetadata_obj.save()
def text2blob(self): #DOC,errno,why = ESSMETS.parseMetsFromFile('/ESSArch/bin/src/testdata/X0000001_METS.xml') DOC, errno, why = ESSMD.parseFromFile( '/ESSArch/bin/src/testdata/X0000001_METS.xml') if errno: print why METSstr = etree.tostring(DOC, encoding='UTF-8', xml_declaration=True, pretty_print=True) blob = MySQLdb.escape_string(METSstr) print 'METSstr', METSstr print 'blob', blob #self.table = 'IngestObjectMetadata' ArchiveObjectMetadata_obj = ArchiveObjectMetadata() ArchiveObjectMetadata_obj.ObjectIdentifierValue = ObjectIdentifierValue ArchiveObjectMetadata_obj.ObjectMetadataType = 26 ArchiveObjectMetadata_obj.ObjectMetadataBLOB = blob ArchiveObjectMetadata_obj.save()
return '', 50, 'errno: %s, why: %s' % (str(errno), str(why)) if DBflag: #print 'DOC',DOC blob = MySQLdb.escape_string(DOC) #print 'blobStart#%s#END' % blob blob_mssql = ESSMSSQL.escape_string(DOC) #print 'blob_MSSQL2 Start#%s#END' % blob_mssql if FTPflag and DBflag: self.timestamp_utc = datetime.datetime.utcnow().replace( microsecond=0, tzinfo=pytz.utc) self.timestamp_dst = self.timestamp_utc.astimezone(self.tz) ArchiveObject_obj = ArchiveObject.objects.get( ObjectUUID=ObjectUUID) ArchiveObjectMetadata_obj = ArchiveObjectMetadata() ArchiveObjectMetadata_obj.ObjectUUID = ArchiveObject_obj ArchiveObjectMetadata_obj.ObjectIdentifierValue = ObjectIdentifierValue ArchiveObjectMetadata_obj.ObjectMetadataType = ObjectMetadataType ArchiveObjectMetadata_obj.ObjectMetadataServer = self.ftp_res[0] ArchiveObjectMetadata_obj.ObjectMetadataURL = self.ftp_res[1] ArchiveObjectMetadata_obj.ObjectMetadataBLOB = blob ArchiveObjectMetadata_obj.linkingAgentIdentifierValue = AgentIdentifierValue ArchiveObjectMetadata_obj.LocalDBdatetime = self.timestamp_utc ArchiveObjectMetadata_obj.save() # res,errno,why = ESSDB.DB().action('IngestObjectMetadata','INS',('ObjectUUID',ObjectUUID, # 'ObjectIdentifierValue',ObjectIdentifierValue, # 'ObjectMetadataType',ObjectMetadataType, # 'ObjectMetadataServer',self.ftp_res[0], # 'ObjectMetadataURL',self.ftp_res[1], # 'ObjectMetadataBLOB',blob,
if FTPflag: self.ftp_res,errno,why = prod().FTPput(ObjectIdentifierValue=ObjectIdentifierValue,FileName=FILENAME,FTPFileName=FTPFileName) if errno: return '',50,'errno: %s, why: %s' % (str(errno),str(why)) if DBflag: #print 'DOC',DOC blob = MySQLdb.escape_string(DOC) #print 'blobStart#%s#END' % blob blob_mssql = ESSMSSQL.escape_string(DOC) #print 'blob_MSSQL2 Start#%s#END' % blob_mssql if FTPflag and DBflag: self.timestamp_utc = datetime.datetime.utcnow().replace(microsecond=0,tzinfo=pytz.utc) self.timestamp_dst = self.timestamp_utc.astimezone(self.tz) ArchiveObject_obj = ArchiveObject.objects.get(ObjectUUID = ObjectUUID) ArchiveObjectMetadata_obj = ArchiveObjectMetadata() ArchiveObjectMetadata_obj.ObjectUUID = ArchiveObject_obj ArchiveObjectMetadata_obj.ObjectIdentifierValue = ObjectIdentifierValue ArchiveObjectMetadata_obj.ObjectMetadataType = ObjectMetadataType ArchiveObjectMetadata_obj.ObjectMetadataServer = self.ftp_res[0] ArchiveObjectMetadata_obj.ObjectMetadataURL = self.ftp_res[1] ArchiveObjectMetadata_obj.ObjectMetadataBLOB = blob ArchiveObjectMetadata_obj.linkingAgentIdentifierValue = AgentIdentifierValue ArchiveObjectMetadata_obj.LocalDBdatetime = self.timestamp_utc.replace(tzinfo=None) ArchiveObjectMetadata_obj.save() # res,errno,why = ESSDB.DB().action('IngestObjectMetadata','INS',('ObjectUUID',ObjectUUID, # 'ObjectIdentifierValue',ObjectIdentifierValue, # 'ObjectMetadataType',ObjectMetadataType, # 'ObjectMetadataServer',self.ftp_res[0], # 'ObjectMetadataURL',self.ftp_res[1], # 'ObjectMetadataBLOB',blob,