def update_view(request): jsondata = request.json_body spifileprefix = jsondata['spifileprefix'] memo = jsondata['memo'] project = jsondata['project'] dspace.tiff_name("/tmp/test.tiff") dspace.scan_description("test description") now = datetime.datetime.utcnow() outfile = ("/home/brian/scan/%s" % now.strftime("SPI_%Y%m%d%H%M%S") + ".jpg") lastscanfile = ("/home/brian/spiscanconfig/lastscan.jpg") scan_event = Event(spifileprefix , now,'SPI',outfile, memo ,project) DBSession.add(scan_event) #adds record of scan event to database but not committed until successful return done = 0 # Start actual scan dspace.scan_description("test description") print "called dspace.scan_description successfully" while done == 0: dspace.scan_start(2); # 0 is prescan 1 is loscan 2 is hiscan while dspace.scan_done()==0 : time.sleep(1) print "scan done" done=1 inpfile = "/tmp/scan.jpg" tfile = "/home/.spiscan/runtime.conf" label = ("SPIScan Surveyor SN7 %s" % now.strftime("%Y%m%d%H%M%S")) rotparm = [] rotparm += ["-rotate", "-90"] subprocess.call(["convert",inpfile] + rotparm + [lastscanfile]) args = [] args += ["-background", "White"] args += ["-pointsize","42"] args += ["label: "+ label] args += ["-gravity", "Southeast"] args += ["-append"] subprocess.call(["convert",inpfile] + args + [inpfile]) time.sleep(1) imp = [] imp += ["-dissolve", "25"] imp += ["-gravity", "Southeast"] subprocess.call(["composite"] + imp + [tfile] + [inpfile] + [inpfile]) time.sleep(1) rotparm = [] rotparm += ["-rotate", "-90"] subprocess.call(["convert",inpfile] + rotparm + [outfile]) thmbfile = ("/home/brian/scan/thumbs/%s" % now.strftime("SPI_%Y%m%d%H%M%S") + ".jpg") thmb = [] thmb += ["-resize","80x80"] subprocess.call(["convert",outfile] + thmb + [thmbfile]) return []
def preview_view(request): dspace.tiff_name("/tmp/test.tiff"); dspace.scan_description("test description") now = datetime.datetime.utcnow() lastscanfile = ("/home/brian/spiscanconfig/lastscan.jpg") done = 0 # Start actual scan dspace.scan_description("test description") print "called dspace.scan_description successfully" while done == 0: dspace.scan_start(1) # 0 is prescan 1 is loscan 2 is hiscan while dspace.scan_done() == 0: time.sleep(1) print "scan done" done=1 inpfile = "/tmp/scan.jpg" rotparm = [] rotparm += ["-rotate", "-90"] subprocess.call(["convert",inpfile] + rotparm + [lastscanfile]) return []
import dspace import time done = 0 dspace.tiff_name("/tmp/test.tiff"); dspace.scan_description("test description"); while done==0: dspace.scan_start(0); while dspace.scan_done()==0 : time.sleep(1) print "scan done" done=1
import dspace import time done = 0 dspace.tiff_name("/tmp/hirestest.tiff"); dspace.scan_description("test description"); while done==0: dspace.scan_start(2); while dspace.scan_done()==0 : time.sleep(1) print "scan done" done=1
import dspace import time done = 0 dspace.scan_description("test description"); while done==0: dspace.scan_start(0,"/var/www/scans/lastScan.jpeg"); while dspace.scan_done()==0 : time.sleep(1) print "scan done" done=1
import dspace import time done = 0 dspace.scan_description("test description"); while done==0: dspace.scan_start(1); while dspace.scan_done()==0 : time.sleep(1) print "scan done" done=1
if dpi_number==75: scan_array_pos=1 elif dpi_number==100: scan_array_pos=2 elif dpi_number==150: scan_array_pos=3 elif dpi_number==200: scan_array_pos=4 elif dpi_number==300: scan_array_pos=5 elif dpi_number==600: scan_array_pos=6 elif dpi_number==1200: scan_array_pos=7 elif dpi_number==2400: scan_array_pos=8 elif dpi_number==4800: scan_array_pos=9 print ("Scan array position: ", scan_array_pos) print ("\nDPI_number: ", dpi_number) ## Do the actual referencing of the C functions while done==0: dspace.scan_start(scan_array_pos, jpg_filename); while dspace.scan_done()==0: time.sleep(1) print ("scan done") done=1