def setUp(self):
     """ unittest test setup code """
     self.port = 6789
     self.serv = VideoHTTPServer(self.port)
     self.serv.background_serve()
     self.serv.register(self.videoservthread_error_callback,self.videoservthread_set_status_callback)
     
     self.sourcefn = os.path.join("API","file.wmv") # 82KB or 82948 bytes
     self.sourcesize = os.path.getsize(self.sourcefn)
Exemplo n.º 2
0
    def __init__(self, redirectstderrout, appname, appversion, params,
                 single_instance_checker, installdir, i2iport, sport,
                 httpport):

        # Almost generic HTTP server
        self.videoHTTPServer = VideoHTTPServer(httpport)
        self.videoHTTPServer.register(self.videoservthread_error_callback,
                                      self.videoservthread_set_status_callback)

        BaseApp.__init__(self, redirectstderrout, appname, appversion, params,
                         single_instance_checker, installdir, i2iport, sport)
        self.httpport = httpport

        # SEARCH:P2P
        # Maps a query ID to the original searchstr, timestamp and all hits (local + remote)
        self.id2hits = Query2HitsMap()

        # Maps a URL path received by HTTP server to the requested resource,
        # reading or generating it dynamically.
        #
        # For saving .torrents received in hits to P2P searches using
        # SIMPLE+METADATA queries
        self.tqueue = TimedTaskQueue(nameprefix="BGTaskQueue")
        self.searchmapper = SearchPathMapper(self.s, self.id2hits, self.tqueue)
        self.hits2anypathmapper = Hits2AnyPathMapper(self.s, self.id2hits)

        self.videoHTTPServer.add_path_mapper(self.searchmapper)
        self.videoHTTPServer.add_path_mapper(self.hits2anypathmapper)

        # WEB Interface
        # Maps a URL path received by HTTP server to the requested resource,
        # reading or generating it dynamically.
        self.webIFmapper = WebIFPathMapper(self, self.s)

        self.videoHTTPServer.add_path_mapper(self.webIFmapper)

        # Generic HTTP server start. Don't add mappers dynamically afterwards!
        self.videoHTTPServer.background_serve()

        # Maps Downloads to a using InstanceConnection and streaminfo when it
        # plays. So it contains the Downloads in VOD mode for which there is
        # active interest from a plugin.
        #
        # At the moment each Download is used/owned by a single IC and a new
        # request for the same torrent will stop playback to the original IC
        # and resume it to the new user.
        #
        self.dusers = {}
        self.approxplayerstate = MEDIASTATE_STOPPED

        self.counter = 0  # counter for the stats reported periodically
        self.interval = 120  # report interval
        self.iseedeadpeople = False

        if sys.platform == "win32":
            # If the BG Process is started by the plug-in notify it with an event
            try:
                startupEvent = win32event.CreateEvent(None, 0, 0,
                                                      'startupEvent')
                win32event.SetEvent(startupEvent)
                win32api.CloseHandle(
                    startupEvent
                )  # TODO : is it possible to avoid importing win32api just to close an handler?
            except:
                pass
Exemplo n.º 3
0
 def __init__(self):
     self.videoHTTPServer = VideoHTTPServer(VIDEOHTTP_LISTENPORT)
     self.videoHTTPServer.register(self.videoservthread_error_callback,
                                   self.videoservthread_set_status_callback)
     self.videoHTTPServer.background_serve()