Exemplo n.º 1
0
def main():
	# read the config file. We'll need this later.
	# also caches the file for stages
	configrc = config.read_config()
	
	#load the logger
	plogger = logger.Logger('pipeline')
	
	if len(sys.argv) == 1:
		plogger.log("Error: no model given to pipeline")
		return
	infile = sys.argv[1]
	
	job = pipeline.PrintJob(infile, "*****@*****.**")

	job.status = 'converting'
	converter.convert(job)
	
	#replaced by slic3r automatic validation
	#job.status = 'validating'
	#validator.validate(job)
	
	job.status = 'slicing'	
	slicer.slice(job)
	
	job.status = 'printing'
	printer.send_job(job)
Exemplo n.º 2
0
def main():
    # read the config file. We'll need this later.
    # also caches the file for stages
    configrc = config.read_config()
    
    udb = users.UserDB()
    
    # set up mailfetch. Just fetches the password for now.
    # v option is temporary, and prevents pipeline from flooding console
    # should eventually be replaced by proper logging system
    plogger = logger.Logger('pipeline')
    mailfetch.initialize()
    
    while True:
        try:
            poll = mailfetch.poll()     
            # mailfetch.poll gets list of printjobs to work on
            for job in poll:
                
                email = job.sender
                
                '''user = udb.find_user(email)
                
                if user != None:
                    user.jobs_submitted += 1
                else:
                    user = users.User(email, 1)
                    
                udb.add_user(user)'''
            
                #pipeline goes here
                #each step of the pipeline sets the status and then runs the stage
                #the stage should store a new file if one is created, but nothing else.
                job.status = 'converting'
                converter.convert(job)
                
                #job.status = 'validating'
                #validator.validate(job)
                
                job.status = 'slicing'
                slicer.slice(job)
                
                job.status = 'printing'
                printer.send_job(job)
        except TypeError:
            return  
        # wait a while. This lets the computer do something else
        delay_time = float(configrc['Pipeline']['poll_frequency'])
        time.sleep(delay_time)
Exemplo n.º 3
0
def draw_button():
	source_img = Image.open("white.jpg")
	#start=random.randint(0,150)
	start=85
	chars = "".join( [random.choice(string.letters[:26]) for i in xrange(random.randint(1,10))] )
	draw = ImageDraw.Draw(source_img)
	draw.rectangle(((120, 150), (120+random.randint(100,350), 150+random.randint(50,150))), fill="black")
	draw.text((120+random.randint(10,40),150+random.randint(20,30)),chars, font=ImageFont.truetype("Arial.ttf",20))
	source_img.save("temp.jpg")
	source_img = Image.open("temp.jpg")
	slicer.slice("temp.jpg")
	source_img = Image.open("temp.jpg")
	source_img=source_img.resize((28,28),Image.ANTIALIAS)
	source_img=source_img.convert('1')
	#os.remove("temp.jpg")
	data=list(source_img.getdata())
	data=(np.asfarray(data)/255.0*0.99)+0.01
	return data
Exemplo n.º 4
0
 def pushSlicer(self, slicer, obj):
     if self.debugSend: print "push", slicer
     assert len(self.slicerStack) < 10000 # failsafe
     topSlicer = self.slicerStack[-1][0]
     slicer.parent = topSlicer
     itr = slicer.slice(topSlicer.streamable, self)
     next = iter(itr).next
     openID = None
     if slicer.sendOpen:
         openID = self.sendOpen()
         if slicer.trackReferences:
             topSlicer.registerReference(openID, obj)
     slicertuple = (slicer, next, openID)
     self.slicerStack.append(slicertuple)
Exemplo n.º 5
0
    def pushSlicer(self, slicer, obj):
        if self.debugSend:
            print "push", slicer
        assert len(self.slicerStack) < 10000  # failsafe

        # if this method raises a Violation, it means that .slice failed,
        # and neither the OPEN nor the stack-push has occurred

        topSlicer = self.slicerStack[-1][0]
        slicer.parent = topSlicer

        # we start the Slicer (by getting its iterator) first, so that if it
        # fails we can refrain from sending the OPEN (hence we do not have
        # to send an ABORT and CLOSE, which simplifies the send logic
        # considerably). slicer.slice is the only place where a Violation
        # can be raised: it is caught and passed cleanly to the parent. If
        # it happens anywhere else, or if any other exception is raised, the
        # connection will be dropped.

        # the downside to this approach is that .slice happens before
        # .registerReference, so any late-validation being done in .slice
        # will not be able to detect the fact that this object has already
        # begun serialization. Validation performed in .next is ok.

        # also note that if .slice is a generator, any exception it raises
        # will not occur until .next is called, which happens *after* the
        # slicer has been pushed. This check is only useful for .slice
        # methods which are *not* generators.

        itr = slicer.slice(topSlicer.streamable, self)
        next = iter(itr).next

        # we are now committed to sending the OPEN token, meaning that
        # failures after this point will cause an ABORT/CLOSE to be sent

        openID = None
        if slicer.sendOpen:
            openID = self.sendOpen()
            if slicer.trackReferences:
                topSlicer.registerReference(openID, obj)
            # note that the only reason to hold on to the openID here is for
            # the debug/optional copy in the CLOSE token. Consider ripping
            # this code out if we decide to stop sending that copy.

        slicertuple = (slicer, next, openID)
        self.slicerStack.append(slicertuple)
Exemplo n.º 6
0
    def pushSlicer(self, slicer, obj):
        if self.debugSend: print "push", slicer
        assert len(self.slicerStack) < 10000  # failsafe

        # if this method raises a Violation, it means that .slice failed,
        # and neither the OPEN nor the stack-push has occurred

        topSlicer = self.slicerStack[-1][0]
        slicer.parent = topSlicer

        # we start the Slicer (by getting its iterator) first, so that if it
        # fails we can refrain from sending the OPEN (hence we do not have
        # to send an ABORT and CLOSE, which simplifies the send logic
        # considerably). slicer.slice is the only place where a Violation
        # can be raised: it is caught and passed cleanly to the parent. If
        # it happens anywhere else, or if any other exception is raised, the
        # connection will be dropped.

        # the downside to this approach is that .slice happens before
        # .registerReference, so any late-validation being done in .slice
        # will not be able to detect the fact that this object has already
        # begun serialization. Validation performed in .next is ok.

        # also note that if .slice is a generator, any exception it raises
        # will not occur until .next is called, which happens *after* the
        # slicer has been pushed. This check is only useful for .slice
        # methods which are *not* generators.

        itr = slicer.slice(topSlicer.streamable, self)
        next = iter(itr).next

        # we are now committed to sending the OPEN token, meaning that
        # failures after this point will cause an ABORT/CLOSE to be sent

        openID = None
        if slicer.sendOpen:
            openID = self.sendOpen()
            if slicer.trackReferences:
                topSlicer.registerReference(openID, obj)
            # note that the only reason to hold on to the openID here is for
            # the debug/optional copy in the CLOSE token. Consider ripping
            # this code out if we decide to stop sending that copy.

        slicertuple = (slicer, next, openID)
        self.slicerStack.append(slicertuple)
Exemplo n.º 7
0
from slicer import slice

slice('puzzle.jpg', cols=44, rows=34)