Guest User

Untitled

a guest
Apr 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import MySQLdb
  2. dbconn = MySQLdb.connect( host='192.168.100.85', port=3306, user='zope', passwd='zope', db='zb_logs' )
  3. cursor = dbconn.cursor()
  4.  
  5. #########################################
  6.  
  7. def getDBFilename(zbfile_id):
  8. query = "select file_nm from zbfile where zbfile_id = '%s'" % zbfile_id
  9. cursor.execute(query)
  10. result = cursor.fetchone()
  11. try:
  12. return result[0]
  13. except:
  14. return ""
  15.  
  16. #########################################
  17.  
  18. def no_zbfile_id(self):
  19. """
  20. if obj.zbfile_id doesn't exist
  21. """
  22. pcat = self.portal_catalog
  23. zbfiles = pcat(portal_type='ZBFile')
  24. count = 0
  25. print "file_nm, start_date, end_date, size, duration, client_id, project_id, media_id"
  26. for f in zbfiles:
  27. obj = f.getObject()
  28. if not obj.zbfile_id or obj.zbfile_id == "":
  29. print ",".join([obj.Title(),str(obj.start_date),str(obj.end_date),str(obj.get_size()), str(obj.duration), str(obj.client_id), str(obj.project_id), str(obj.media_id)])
  30.  
  31.  
  32.  
  33. def incorrect_zbfile_id(self):
  34. """
  35. if obj.Title() != zbfile.file_nm
  36. """
  37. pcat = self.portal_catalog
  38. zbfiles = pcat(portal_type='ZBFile')
  39. print "zbfile_id, file_nm, start_date, end_date, size, duration, client_id, project_id, media_id"
  40. for f in zbfiles:
  41. obj = f.getObject()
  42.  
  43. if not obj.zbfile_id:continue
  44.  
  45. dbfilename = getDBFilename(obj.zbfile_id)
  46. if dbfilename != obj.Title():
  47. print ",".join([str(obj.zbfile_id), obj.Title(),str(obj.start_date),str(obj.end_date),str(obj.get_size()), str(obj.duration), str(obj.client_id), str(obj.project_id), str(obj.media_id)])
Add Comment
Please, Sign In to add comment