def __init__(self, redirectstderrout, appname, params, single_instance_checker, installdir, i2iport, sport): BaseApp.__init__(self, redirectstderrout, appname, params, single_instance_checker, installdir, i2iport, sport) self.videoHTTPServer = VideoHTTPServer(VIDEOHTTP_LISTENPORT) self.videoHTTPServer.background_serve() self.videoHTTPServer.register(self.videoservthread_error_callback, self.videoservthread_set_status_callback) # 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 = {} # If the BG Process is started by the plug-in notify it with an event 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?
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 self.sourcesize = os.path.getsize(self.sourcefn)
def __init__(self, redirectstderrout, appname, params, single_instance_checker, installdir, i2iport, sport): self.videoHTTPServer = VideoHTTPServer(VIDEOHTTP_LISTENPORT) self.videoHTTPServer.register(self.videoservthread_error_callback, self.videoservthread_set_status_callback) self.videoHTTPServer.background_serve() #self.searchHTTPServer = MultiHTTPServer(VIDEOHTTP_LISTENPORT+1) #self.searchHTTPServer.register(self.videoservthread_error_callback,self.videoservthread_set_status_callback) self.searchHTTPServer = self.videoHTTPServer BaseApp.__init__(self, redirectstderrout, appname, params, single_instance_checker, installdir, i2iport, sport) # 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.searchHTTPServer.add_path_mapper(self.searchmapper) self.searchHTTPServer.add_path_mapper(self.hits2anypathmapper) self.searchHTTPServer.background_serve() self.searchurl = 'http://127.0.0.1:' + str( self.searchHTTPServer.get_port()) + URLPATH_SEARCH_PREFIX # 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 if sys.platform == "win32": # If the BG Process is started by the plug-in notify it with an event 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?