Esempio n. 1
0
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 []
Esempio n. 2
0
 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 []
Esempio n. 3
0
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