Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def images(qty):
- conn = None
- conn_string = "host=" +db_host + " dbname=" +db_name + " user=" +db_user + " password=" +db_pass
- conn = psycopg2.connect(conn_string)
- conn.autocommit=False
- cursor = conn.cursor()
- #select records as path/to/check (does not return side or extension)
- imgsql = "query removed"
- cursor.execute(imgsql)
- records = cursor.fetchall()
- conn.rollback()
- cursor.close()
- conn.close()
- return(records)
- # build list of potential files
- imagename = []
- filename = []
- filename = images(3)
- for entry in filename:
- print entry
- file_types = [ ".tif", ".jpg", ".jp2" ]
- side = [ "-1", "-2" ]
- for filebase in filename:
- for ftype in file_types:
- for iside in side:
- fpath = (str(filebase) + iside + ftype)
- ifile = Path(fpath)
- if ifile.exists():
- ifile = (filebase + iside + ftype)
- imagename.append(ifile)
- returns:
- ('/path/to/file/100064',)-1.tif
- ('/path/to/file/100064',)-2.tif
- ('/path/to/file/100064',)-1.jpg
- ('/path/to/file/100064',)-2.jpg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement