daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Nov 8th, 2018 146 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def images(qty):
  2.   conn = None
  3.   conn_string = "host=" +db_host + " dbname=" +db_name + " user=" +db_user + " password=" +db_pass
  4.   conn = psycopg2.connect(conn_string)
  5.   conn.autocommit=False
  6.   cursor = conn.cursor()
  7.   #select records as path/to/check (does not return side or extension)
  8.   imgsql = "query removed"
  9.   cursor.execute(imgsql)
  10.   records = cursor.fetchall()
  11.   conn.rollback()
  12.   cursor.close()
  13.   conn.close()
  14.   return(records)
  15.  
  16.  
  17. # build list of potential files
  18. imagename = []
  19. filename = []
  20. filename = images(3)
  21.  
  22. for entry in filename:
  23.  print entry
  24.  
  25. file_types = [ ".tif", ".jpg", ".jp2" ]
  26. side = [ "-1", "-2" ]
  27. for filebase in filename:
  28.   for ftype in file_types:
  29.     for iside in side:
  30.       fpath = (str(filebase) + iside + ftype)
  31.       ifile = Path(fpath)
  32.       if ifile.exists():
  33.         ifile = (filebase + iside + ftype)
  34.         imagename.append(ifile)
  35.  
  36.  
  37. returns:
  38. ('/path/to/file/100064',)-1.tif
  39. ('/path/to/file/100064',)-2.tif
  40. ('/path/to/file/100064',)-1.jpg
  41. ('/path/to/file/100064',)-2.jpg
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top