Beispiel #1
0
   def initialiseComponent(self):

      if self.requestmessage == ".mpg":
         self.requestmessage = ".jpg"

      myPacketCombiner = combinePackets()
      myFile = createFile(self.tempDir, self.requestmessage)
      myDisplay = show(self.requestmessage, self.tempDir, self.delay, self.demo_mode)

      "Linkages for myPacketCombiner"
      self.link(source=(self, "inbox"), sink=(myPacketCombiner, "inbox"), passthrough=1)
      self.link(source=(self, "_filteredControlMessages"), sink=(myPacketCombiner, "control"), passthrough=0)

      "Linkages for myFile"
      self.link(source=(myPacketCombiner, "outbox"), sink=(myFile, "inbox"), passthrough=0)
      self.link(source=(myPacketCombiner, "signal"), sink=(myFile, "control"), passthrough=0)

      "Linkages for myDisplay"
      self.link(source=(myFile, "outbox"), sink=(myDisplay, "inbox"), passthrough=0)
      self.link(source=(myFile, "signal"), sink=(myDisplay, "control"), passthrough=0)
      
      self.link(source=(myDisplay, "signal"), sink=(self, "_displayFinished"), passthrough=0)
      
      self.addChildren(myPacketCombiner, myFile, myDisplay)
      return newComponent(myPacketCombiner, myFile, myDisplay)
Beispiel #2
0
    def initialiseComponent(self):
        self.mimehandler = MimeRequestComponent()
        self.httphandler = HTTPReqestHandler()
        #      toString = ToStringComponent()
        #      myDataSource = ReadFileAdaptor(command="afortune.pl",
        #                              readmode="bitrate",
        #                              bitrate=95200, chunkrate=25)
        assert self.debugger.note("HTTPServer.initialiseComponent", 1,
                                  "Initialising HTTPServer protocol handler ",
                                  self.__class__)
        #      self.link(        source=(self,"inbox"),
        #               sink=(mimehandler,"inbox"),
        #               passthrough=2)
        self.link(source=(self, "_pass"), sink=(self.mimehandler, "inbox"))
        #      self.link(  source=(mimehandler,"outbox"),
        #                  sink=(toString,"inbox"))
        self.link(source=(self.mimehandler, "outbox"),
                  sink=(self.httphandler, "inbox"))
        self.link(source=(self.httphandler, "outbox"),
                  sink=(self, "_frommime"))
        self.link(source=(self.mimehandler, "signal"), sink=(self, "_errmon"))
        #      self.link(	source=(toString,"outbox"),
        #              sink=(self,"outbox"),
        #               passthrough=1)
        self.addChildren(self.mimehandler, self.httphandler)

        return newComponent(self.mimehandler,
                            self.httphandler)  #, toString ] )
Beispiel #3
0
   def initialiseComponent(self):
      self.mimehandler = MimeRequestComponent()
      self.httphandler = HTTPReqestHandler()
#      toString = ToStringComponent()
#      myDataSource = ReadFileAdaptor(command="afortune.pl",
#                              readmode="bitrate",
#                              bitrate=95200, chunkrate=25)
      assert self.debugger.note("HTTPServer.initialiseComponent", 1, "Initialising HTTPServer protocol handler ", self.__class__)
#      self.link(        source=(self,"inbox"),
#               sink=(mimehandler,"inbox"),
#               passthrough=2)
      self.link(  source=(self,"_pass"),
                  sink=(self.mimehandler,"inbox"))
#      self.link(  source=(mimehandler,"outbox"),
#                  sink=(toString,"inbox"))
      self.link(  source=(self.mimehandler,"outbox"),
                  sink=(self.httphandler,"inbox"))
      self.link(  source=(self.httphandler,"outbox"),
                  sink=(self,"_frommime"))
      self.link(  source=(self.mimehandler,"signal"),
                  sink=(self,"_errmon"))
#      self.link(	source=(toString,"outbox"),
#              sink=(self,"outbox"),
#               passthrough=1)
      self.addChildren(self.mimehandler, self.httphandler)

      return newComponent( self.mimehandler, self.httphandler )#, toString ] )
	def initialiseComponent(self):
		myDataSource = ReadFileAdaptor(filename="/video/sample-100.mpg",
					readmode="bitrate",
					bitrate=375000, chunkrate=24 )
		linkage(myDataSource,self,"outbox","datain", self.postoffice)
		self.addChildren(myDataSource)

		return newComponent( myDataSource )
Beispiel #5
0
	def initialiseComponent(self):
		myDataSource = ReadFileAdaptor(filename="/video/sample-100.mpg",
					readmode="bitrate",
					bitrate=375000, chunkrate=24 )
		linkage(myDataSource,self,"outbox","datain", self.postoffice)
		self.addChildren(myDataSource)

		return newComponent( myDataSource )
Beispiel #6
0
   def initialiseComponent(self):

      self.client = ThreadedTCPClient.ThreadedTCPClient(self.IP_toConnectTo,self.serverport, delay=1, initialsendmessage=self.requestmessage)
      self.display = ClientProtocolHandler(self.tempDir, self.requestmessage, self.delay, self.demo_mode)
       
      self.addChildren(self.client, self.display)
      
      self.link((self.client,"outbox"), (self.display,"inbox") )
      self.link((self.display,"outbox"), (self.client,"inbox") )
      self.link((self.client,"signal"), (self.display,"control") )
      self.link((self.display,"signal"), (self,"control") )
     
      return newComponent( self.client, self.display)
      def main(self):

         reader = ReadFileAdaptor(filename="Support/SampleMIMERequest.txt")
         decoder = MimeRequestComponent()
         self.link((reader,"outbox"), (decoder, "inbox"))
         self.link((decoder, "outbox"), (self, "inbox"))

         self.addChildren(reader,decoder)
         yield newComponent(*(self.children))

         while 1:
            if self.dataReady("inbox"):
               message = self.recv("inbox")
               print ("MIME decoded:", repr(message))
               return
            yield 1
Beispiel #8
0
        def main(self):

            reader = ReadFileAdaptor(filename="Support/SampleMIMERequest.txt")
            decoder = MimeRequestComponent()
            self.link((reader, "outbox"), (decoder, "inbox"))
            self.link((decoder, "outbox"), (self, "inbox"))

            self.addChildren(reader, decoder)
            yield newComponent(*(self.children))

            while 1:
                if self.dataReady("inbox"):
                    message = self.recv("inbox")
                    print("MIME decoded:", repr(message))
                    return
                yield 1
Beispiel #9
0
 def initialiseComponent(self):
     self.link((self.source, "outbox"), (self.transform, "recvsrc"))
     self.link((self.transform, "output"), (self.sink, "inbox"))
     return newComponent(self.source, self.transform, self.sink)
Beispiel #10
0
   def mainBody(self):
      self.setTempDir()
      #UserInterface
      if self.tempDir != "E:\\Ciaran's Files\\Temp":
         if self.demo_mode == True:
             if self.displaySet == False:             
                try: text_button = pygame.image.load("UI_Pics\\Text button.jpg")
                except: raise "ErrorLoadingImage", "couldn't load text button"
             
                try: image_button = pygame.image.load("UI_Pics\Image button.jpg")
                except: raise "ErrorLoadingImage", "couldn't load image button"
              
                try: movie_button = pygame.image.load("UI_Pics\\Movie button.jpg")             
                except: raise "ErrorLoadingImage", "couldn't load movie button"

                self.textRect = text_button.get_rect()
                self.imageRect = image_button.get_rect()
                self.movieRect = movie_button.get_rect()               

                self.textRect = self.textRect.move(100, 200)
                self.imageRect = self.imageRect.move(350, 200)
                self.movieRect = self.movieRect.move(600, 200)

                font = pygame.font.Font(None,18) 
                self.string_surface = font.render("What request would you like to make?", 1, [255,255,255])
                self.string_rect = self.string_surface.get_rect()

                self.string_rect = self.string_rect.move(300, 150)

                self.screen.fill(self.black)
                self.screen.blit(self.string_surface, self.string_rect)
                self.screen.blit(text_button, self.textRect)
                self.screen.blit(image_button, self.imageRect)
                self.screen.blit(movie_button, self.movieRect)
                
                pygame.display.flip()
                self.displaySet = True

             for event in pygame.event.get():
               if event.type == pygame.QUIT:
                  pygame.quit()
                  return 0
               if event.type == pygame.MOUSEBUTTONDOWN:
                  pos = pygame.mouse.get_pos()
                  mouseRect = [[pos[0],pos[1]],[5,5]]
                  mouseRect = pygame.Rect(mouseRect)
                  
                  if pygame.mouse.get_pressed() == (1,0,0):                     
                     clickedText = mouseRect.colliderect(self.textRect)
                     clickedImage = mouseRect.colliderect(self.imageRect)
                     clickedMovie = mouseRect.colliderect(self.movieRect)
                     
                     if clickedText == True:
                        self.screen.fill(self.black)
                        pygame.display.flip()
                        self.requestmessage = ".txt"
                        self.client = Client(self.IP_toConnectTo, self.serverport, self.delay, self.requestmessage, self.tempDir, self.demo_mode)
                        self.addChildren(self.client)
                        return newComponent(self.client)
                        
                     if clickedImage == True:
                        self.screen.fill(self.black)
                        pygame.display.flip()
                        self.requestmessage = ".jpg"
                        self.client = Client(self.IP_toConnectTo, self.serverport, self.delay, self.requestmessage, self.tempDir, self.demo_mode)
                        self.addChildren(self.client)
                        return newComponent(self.client)
                        
                     if clickedMovie == True:
                        self.screen.fill(self.black)
                        pygame.display.flip()
                        self.requestmessage = ".mpg"
                        self.client = Client(self.IP_toConnectTo, self.serverport, self.delay, self.requestmessage, self.tempDir, self.demo_mode)
                        self.addChildren(self.client)
                        return newComponent(self.client)
                        
                  if pygame.mouse.get_pressed() == (0,0,1):
                     clickedFont = mouseRect.colliderect(self.string_rect)
                     pygame.quit()
                     return 0
                
         elif self.demo_mode == False:
            print "Enter Server IP"
            self.IP_toConnectTo = raw_input()

            print "Enter port (1616)"
            self.serverport = raw_input()
            
            print "Enter delay value"
            self.delay = raw_input()

            print "Enter request (.txt .jpg or .mpg)"
            self.requestmessage = raw_input()
      else:
         self.IP_toConnectTo = appuifw.query(u"Enter Server IP", "text", u"132.185.133.36")
         self.serverport = appuifw.query(u"Enter port", "number")
         self.delay = appuifw.query(u"Enter delay value.", "number")
         self.requestmessage = appuifw.query(u"Enter request ('.txt', '.jpg' or '.mpg')", "text", u".")
         
      return 1 
 def initialiseComponent(self):
    self.link( (self.source, "outbox"), (self.transform, "recvsrc"))
    self.link( (self.transform, "output"), (self.sink, "inbox"))
    return newComponent(self.source, self.transform, self.sink)