rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.playVideoInMode(1)
if VideoDisplayController.getInstance().isPlaying: VideoDisplayController.getInstance().goFullscreen_(sender) else: self.playVideoInMode(1)
def playVideoFullScreen_(self, sender): self.playVideoInMode(1)
"Video player that can be shown in a MainFrame's right-hand pane." controller = nil def __init__(self, firstItemId, view, previousDisplay, mode): app.VideoDisplayDB.__init__(self, firstItemId, view)
"Video player shown in a MainFrame's right-hand pane." _instance = None @classmethod def getInstance(cls, controller=None): if VideoDisplay._instance is None: VideoDisplay._instance = VideoDisplay(controller) return VideoDisplay._instance def __init__(self, controller): app.VideoDisplayDB.__init__(self)
def showItem(self, id): elt = self.findElt(id) if not elt: print "warning: showItem: missing element %s" % id else: elt.getAttribute_("style").setAttribute_("display", "") #print "show item %s (new style '%s')" % (id, elt.getAttribute_("style"))
VideoDisplay.controller.previousDisplay = previousDisplay
self.controller = controller self.initialMode = None def configure(self, view, firstItemId, previousDisplay, mode): self.setPlaylist(view, firstItemId) self.controller.previousDisplay = previousDisplay
def __init__(self, firstItemId, view, previousDisplay, mode): app.VideoDisplayDB.__init__(self, firstItemId, view) app.Display.__init__(self) VideoDisplay.controller.previousDisplay = previousDisplay self.initialMode = mode
VideoDisplay.controller.frame = frame VideoDisplay.controller.enableControls(YES) VideoDisplay.controller.setPlaylist(self)
self.controller.frame = frame self.controller.enableControls(YES) self.controller.setPlaylist(self)
def onSelected(self, frame): VideoDisplay.controller.frame = frame VideoDisplay.controller.enableControls(YES) VideoDisplay.controller.setPlaylist(self) if self.initialMode == 0: VideoDisplay.controller.play_(nil) else: VideoDisplay.controller.goFullscreen_(nil)
VideoDisplay.controller.play_(nil) else: VideoDisplay.controller.goFullscreen_(nil)
self.controller.play_(nil) else: self.controller.goFullscreen_(nil)
def onSelected(self, frame): VideoDisplay.controller.frame = frame VideoDisplay.controller.enableControls(YES) VideoDisplay.controller.setPlaylist(self) if self.initialMode == 0: VideoDisplay.controller.play_(nil) else: VideoDisplay.controller.goFullscreen_(nil)
VideoDisplay.controller.pause_(nil) VideoDisplay.controller.enableControls(False) VideoDisplay.controller.reset()
self.controller.pause_(nil) self.controller.enableControls(False) self.controller.reset() self.reset()
def onDeselected(self, frame): VideoDisplay.controller.pause_(nil) VideoDisplay.controller.enableControls(False) VideoDisplay.controller.reset()
return VideoDisplay.controller.rootView
return self.controller.rootView
def getView(self): return VideoDisplay.controller.rootView
VideoDisplay.controller = self
VideoDisplay.getInstance(self) VideoDisplayController._instance = self
def awakeFromNib(self): self.reset() self.forwardButton.sendActionOn_(NSLeftMouseDownMask) self.backwardButton.sendActionOn_(NSLeftMouseDownMask) nc.addObserver_selector_name_object_( self, 'handleWatchableDisplayNotification:', 'displayIsWatchable', nil) nc.addObserver_selector_name_object_( self, 'handleNonWatchableD...
m = re.compile('(.*?)(\$\{.*?\})(.*?)').findall(translation)
m = re.compile('(.*?)(\$\{.*?\})(.*)').findall(translation)
def transformTopNode(node, data, handle): if node.nodeType == node.ELEMENT_NODE: # Handle i18n translation # # For now, we're using the translate and name attributes found on this # page to handle translation. # http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/ZPTInternationalizationSupport # #...
except webbrowser.Error: util.failedExn("while opening %s in a new window" % url)
except: print "WARNING: Error opening URL: %r" % url traceback.print_exc() recommendURL = 'http://www.videobomb.com/index/democracyemail' if url.startswith(config.get(prefs.VIDEOBOMB_URL)): title = _('Error Bombing Item') elif url.startswith(recommendURL): title = _('Error Recommending Item') else: title = _("Error Op...
def openExternalURL(self, url): # It looks like the maximum URL length is about 2k. I can't # seem to find the exact value if len(url) > 2047: url = url[:2047] try: webbrowser.open(url) except webbrowser.Error: util.failedExn("while opening %s in a new window" % url)
return '%1.1fGB' % (size/1000)
return '%1.1fGB' % (bytes/1000)
def sizeFormattedForDisplay(self, bytes, emptyForZero=True): bytes = bytes / 1000000 if bytes == 0: if emptyForZero: return "" else: return "n/a" elif bytes < 100: return '%1.1fMB' % bytes elif bytes < 1000: return '%1.0fMB' % bytes else: return '%1.1fGB' % (size/1000)
h = open("/tmp/dtv-log", "wt") sys.stdout = sys.stderr = AutoflushingStream(h) try: print "got:: %s" % mainWindowDocument
try: if os.environ.has_key('TMP'): h = open("%s/dtv-log" % os.environ['TMP'], "wt") sys.stdout = sys.stderr = AutoflushingStream(h) except: pass try: print "got:: %s" % mainWindowDocument
def write(self, *args):
paramString = "%s%sdescription=%s" % (paramString, glue, xhtmltools.urlencode(description))
paramString = "%s%sdescription=%s" % (paramString, glue, xhtmltools.urlencode(description.encode('utf-8')))
def videoBombExternally(self, item): obj = db.getObjectByID(int(item)) paramList = {} paramList["title"] = obj.getTitle() paramList["info_url"] = obj.getLink() paramList["hookup_url"] = obj.getPaymentLink() try: rss_url = obj.getFeed().getURL() if (not rss_url.startswith('dtv:')): paramList["rss_url"] = rss_url except:...
schemasimple.validate(True) schemasimple.validate(1)
def testSimpleContainerValidation(self): schemasimple = SchemaSimpleContainer() schemasimple.validate(True) schemasimple.validate(1) schemasimple.validate({1: "Ben", "pie": 3.1415}) schemasimple.validate([1, 1, "two", "three", 5]) schemasimple.validate({'y2k': datetime.datetime(2000, 1, 1), 'now': time.localtime()}) sc...
self.startfrom = datetime.min
def __init__(self, url, ufeed, title = None, visible = True): self.available = 0 self.unwatched = 0 self.url = url self.ufeed = ufeed self.items = [] if title == None: self.title = url else: self.title = title self.created = datetime.now() self.autoDownloadable = False self.getEverything = False self.maxNew = -1 self.f...
But we'll try our best to grab the files. It may take extra time to list the\n\ videos, and descriptions may look funny. Please contact the publishers of\n\ $url and ask if they can supply a feed in a format that will work with\n\
But we'll try our best to grab the files. It may take extra time to list the \ videos, and descriptions may look funny. Please contact the publishers of \ $url and ask if they can supply a feed in a format that will work with \
def askForScrape(self, info, initialHTML, charset): title = _("Channel is not compatible with Democracy!") descriptionTemplate = string.Template(_("""\
self.dbItem.beginChange() try: try: if (self.filename): os.remove (self.filename) except: pass self.url = url self.filename = None self.etag = None self.modified = None finally: self.updating = False if self.needsUpdate: self.needsUpdate = False self.requestUpdate()
wasValid = self.isValid() try: if (self.filename): os.remove (self.filename) except: pass self.url = url self.filename = None self.etag = None self.modified = None self.updated = True self.updating = False if self.needsUpdate: self.needsUpdate = False self.requestUpdate() if wasValid: self.dbItem.beginChange()
def errorCallback(self, url, error = None): # Error during download, or no url. To reflect that, # clear the cache if there was one before. self.dbItem.beginChange() try: try: if (self.filename): os.remove (self.filename) except: pass self.url = url self.filename = None self.etag = None self.modified = None finally: s...
self.dbItem.beginChange() try:
try: if (info['status'] == 304): self.updated = True return self.dbItem.beginChange()
def updateIconCache (self, url, info): if info == None or (info['status'] != 304 and info['status'] != 200): self.errorCallback(url) return self.dbItem.beginChange() try: try: # Our cache is good. Hooray! if (info['status'] == 304): self.updated = True return
if (info['status'] == 304): self.updated = True return
def updateIconCache (self, url, info): if info == None or (info['status'] != 304 and info['status'] != 200): self.errorCallback(url) return self.dbItem.beginChange() try: try: # Our cache is good. Hooray! if (info['status'] == 304): self.updated = True return
self.updating = False if self.needsUpdate: self.needsUpdate = False self.requestUpdate() iconCacheUpdater.updateFinished ()
self.dbItem.endChange()
def updateIconCache (self, url, info): if info == None or (info['status'] != 304 and info['status'] != 200): self.errorCallback(url) return self.dbItem.beginChange() try: try: # Our cache is good. Hooray! if (info['status'] == 304): self.updated = True return
self.dbItem.endChange()
self.updating = False if self.needsUpdate: self.needsUpdate = False self.requestUpdate() iconCacheUpdater.updateFinished ()
def updateIconCache (self, url, info): if info == None or (info['status'] != 304 and info['status'] != 200): self.errorCallback(url) return self.dbItem.beginChange() try: try: # Our cache is good. Hooray! if (info['status'] == 304): self.updated = True return
if currentTime - self.lastTime >= 1.0:
if currentTime - self.lastTime >= 1.0 or self.dragging:
def movieShouldTask_(self, movie): currentTime = self.getCurrentTimeInSeconds() if currentTime - self.lastTime >= 1.0: self.setNeedsDisplay_(YES) self.lastTime = currentTime return NO
origin = NSPoint(60, 8) size = NSSize(self.getGrooveWidth(), 8) rect = NSOffsetRect(NSRect(origin, size), -0.5, -0.5)
def drawProgressGroove(self): origin = NSPoint(60, 8) size = NSSize(self.getGrooveWidth(), 8) rect = NSOffsetRect(NSRect(origin, size), -0.5, -0.5)
NSBezierPath.fillRect_(rect)
NSBezierPath.fillRect_(self.grooveRect)
def drawProgressGroove(self): origin = NSPoint(60, 8) size = NSSize(self.getGrooveWidth(), 8) rect = NSOffsetRect(NSRect(origin, size), -0.5, -0.5)
NSBezierPath.strokeRect_(rect)
NSBezierPath.strokeRect_(self.grooveRect)
def drawProgressGroove(self): origin = NSPoint(60, 8) size = NSSize(self.getGrooveWidth(), 8) rect = NSOffsetRect(NSRect(origin, size), -0.5, -0.5)
offset = (self.getGrooveWidth() - 9) / progress
offset = (self.grooveRect.size.width - 9) / progress
def drawProgressCursor(self): if self.movie == nil: return
def getGrooveWidth(self): return self.bounds().size.width - 60 - 8
def getGrooveRect(self): origin = NSPoint(60, 8) size = NSSize(self.bounds().size.width - 60 - 8, 8) return NSOffsetRect(NSRect(origin, size), -0.5, -0.5)
def getGrooveWidth(self): return self.bounds().size.width - 60 - 8
self.fullscreenController = nil
def selectPlaylistItem(self, index): pathname = self.playlist[index].getPath() (movie, error) = QTMovie.alloc().initWithFile_error_(pathname) self.videoView.setMovie_(movie) self.progressDisplayer.setMovie_(movie) nc.removeObserver_(self) nc.addObserver_selector_name_object_( self, 'handleMovieNotification:', nil, self...
self.fullscreenController = None
self.fullscreenController = nil
def didExitFullscreenMode(self): self.fullscreenController = None
self.currentItemIndex += 1 if self.currentItemIndex < self.playlist.len(): self.selectPlaylistItem(self.currentItemIndex) else: self.currentItemIndex = 0 self.exitVideoMode()
if not self.progressDisplayer.dragging: self.currentItemIndex += 1 if self.currentItemIndex < self.playlist.len(): self.selectPlaylistItem(self.currentItemIndex) self.play_(nil) else: self.currentItemIndex = 0 self.exitVideoMode()
def handleMovieNotification_(self, notification): info = notification.userInfo() if notification.name() == QTMovieRateDidChangeNotification: rate = info.get(QTMovieRateDidChangeNotificationParameter).floatValue() if rate == 0.0: self.playPauseButton.setImage_(NSImage.imageNamed_('play.png')) self.playPauseButton.setAlt...
print "Parsing..."
def _generateFeed(url): info = grabURL(url,"GET") if info is None: return None try: modified = info['last-modified'] except KeyError: modified = None try: etag = info['etag'] except KeyError: etag = None #Definitely an HTML feed if (info['content-type'].startswith('text/html') or info['content-type'].startswith('applic...
print "Done"
def _generateFeed(url): info = grabURL(url,"GET") if info is None: return None try: modified = info['last-modified'] except KeyError: modified = None try: etag = info['etag'] except KeyError: etag = None #Definitely an HTML feed if (info['content-type'].startswith('text/html') or info['content-type'].startswith('applic...
print " Nevermind! it's HTML"
def _generateFeed(url): info = grabURL(url,"GET") if info is None: return None try: modified = info['last-modified'] except KeyError: modified = None try: etag = info['etag'] except KeyError: etag = None #Definitely an HTML feed if (info['content-type'].startswith('text/html') or info['content-type'].startswith('applic...
if info.has_key('etag'): self.etag = info['etag'] if info.has_key('last-modified'): self.modified = info['last-modified']
def update(self): if not self.initialHTML is None: html = self.initialHTML self.initialHTML = None else: info = grabURL(self.url,etag=self.etag,modified=self.modified) if info is None: return None html = info['file-handle'].read() info['file-handle'].close() if info.has_key('charset'): html = fixXMLHeader(html,info['c...
print "I could scrape "+entry['title']
def addScrapedThumbnail(self,entry): if (len(entry['enclosures'])>0 and entry.has_key('description') and not entry['enclosures'][0].has_key('thumbnail')): print "I could scrape "+entry['title'] desc = RSSFeed.firstImageRE.search(unescape(entry['description'])) if not desc is None: print "adding scraped thumb at %s" % d...
print "adding scraped thumb at %s" % desc.expand("\\1")
def addScrapedThumbnail(self,entry): if (len(entry['enclosures'])>0 and entry.has_key('description') and not entry['enclosures'][0].has_key('thumbnail')): print "I could scrape "+entry['title'] desc = RSSFeed.firstImageRE.search(unescape(entry['description'])) if not desc is None: print "adding scraped thumb at %s" % d...
maxThreads = 2
maxThreads = 5
def removeItem(self,item):
def getHTML(self, url):
def getHTML(self, url, useActualHistory = True):
def getHTML(self, url): etag = None modified = None if self.linkHistory.has_key(url): if self.linkHistory[url].has_key('etag'): etag = self.linkHistory[url]['etag'] if self.linkHistory[url].has_key('modified'): modified = self.linkHistory[url]['modified'] info = grabURL(url, etag=etag, modified=modified) if info is Non...
if not self.linkHistory.has_key(info['updated-url']): self.linkHistory[info['updated-url']] = {}
if not self.tempHistory.has_key(info['updated-url']): self.tempHistory[info['updated-url']] = {}
def getHTML(self, url): etag = None modified = None if self.linkHistory.has_key(url): if self.linkHistory[url].has_key('etag'): etag = self.linkHistory[url]['etag'] if self.linkHistory[url].has_key('modified'): modified = self.linkHistory[url]['modified'] info = grabURL(url, etag=etag, modified=modified) if info is Non...
self.linkHistory[info['updated-url']]['etag'] = info['etag']
self.tempHistory[info['updated-url']]['etag'] = info['etag']
def getHTML(self, url): etag = None modified = None if self.linkHistory.has_key(url): if self.linkHistory[url].has_key('etag'): etag = self.linkHistory[url]['etag'] if self.linkHistory[url].has_key('modified'): modified = self.linkHistory[url]['modified'] info = grabURL(url, etag=etag, modified=modified) if info is Non...
self.linkHistory[info['updated-url']]['modified'] = info['last-modified']
self.tempHistory[info['updated-url']]['modified'] = info['last-modified']
def getHTML(self, url): etag = None modified = None if self.linkHistory.has_key(url): if self.linkHistory[url].has_key('etag'): etag = self.linkHistory[url]['etag'] if self.linkHistory[url].has_key('modified'): modified = self.linkHistory[url]['modified'] info = grabURL(url, etag=etag, modified=modified) if info is Non...
self.updating = False
def update(self):
print "**** got open URL event"
def openURL_withReplyEvent_(self, event, replyEvent): print "**** got open URL event" keyDirectObject = struct.unpack(">i", "----")[0] url = event.paramDescriptorForKeyword_(keyDirectObject).stringValue()
match = re.compile(r"^feed:(.*)$").match(url) if match: url = "http:%s" % match.group(1)
urlPattern = re.compile(r"^(.*?)://(.*)$") match = urlPattern.match(url) if match and match.group(1) == 'feed': url = match.group(2) match = urlPattern.match(url) if not match: url = 'http://%s' % url if url.startswith('http'):
def openURL_withReplyEvent_(self, event, replyEvent): print "**** got open URL event" keyDirectObject = struct.unpack(">i", "----")[0] url = event.paramDescriptorForKeyword_(keyDirectObject).stringValue()
self.autoDownloadable = False self.startfrom = datetime.min
self.autoDownloadable = True self.startfrom = datetime.now()
def __init__(self, url, ufeed, title = None, visible = True): self.available = 0 self.unwatched = 0 self.url = url self.ufeed = ufeed self.items = [] if title == None: self.title = url else: self.title = title self.created = datetime.now() self.autoDownloadable = False self.startfrom = datetime.min self.getEverything =...
if expiration < 0.0:
if expiration < 1.0:
def getFormattedDefaultExpiration(self): expiration = self.getDefaultExpiration() formattedExpiration = '' if expiration < 0.0: formattedExpiration = '%d hours' % int(expiration * 24.0) elif expiration == 1: formattedExpiration = '%d day' % int(expiration) elif expiration > 1 and expiration < 30: formattedExpiration = ...
print "%r -- %r " % (url, controller.guideURL)
def onURLLoad(self, url): #print "DTV: got %s" % url try: # Special-case non-'action:'-format URL if url.startswith ("template:"): name, args = self.parseEventURL(url) self.dispatchAction('switchTemplate', name=name, **args) return False
guide = views.guides.getObjectByID(int(id)).setSawIntro()
try: guide = views.guides.getObjectByID(int(id)).setSawIntro() except database.ObjectNotFoundError: return
def doneWithIntro(self, id): guide = views.guides.getObjectByID(int(id)).setSawIntro() self.goToGuide(id)
guide = views.guides.getObjectByID(int(id))
try: guide = views.guides.getObjectByID(int(id)) except database.ObjectNotFoundError: return
def goToGuide(self, id): # Only switch to the guide if the template display is already # selected This prevents doubling clicking on a movie from # openning the channel guide instead of the video if controller.frame.getDisplay(controller.frame.mainDisplay) is self.display: if id is None: guide = getSingletonDDBObject(v...
assert self.controller is not None
assert self.controller is not nil
def __init__(self): app.VideoDisplayDB.__init__(self) app.Display.__init__(self) self.controller = VideoDisplayController.getInstance() assert self.controller is not None
if code == errno.ECONNABORTED or \ code == errno.ECONNRESET:
if code in (errno.ECONNABORTED, errno.ECONNRESET, errno.WSAENOTSOCK):
def requestThread(self): request = None try: try: request = self.file.readline() match = re.match(r"^([^ ]+) +([^ ]+)", request) if request == '': # an empty string indicates we've hit EOS already, don't # bother sending anything back. print "WARNING: empty HTTP request" elif not match: print "WARNING: Malformed HTTP ...
if code == errno.ECONNABORTED or \ code == errno.ECONNRESET:
if code in (errno.ECONNABORTED, errno.ECONNRESET, errno.WSAENOTSOCK):
def runChunkPump(self): self.cond.acquire() try: while True: while len(self.chunkQueue) == 0: self.cond.wait() (mimeType, body) = self.chunkQueue[0] self.chunkQueue = self.chunkQueue[1:]
def pauseAllDownloaders(): dlCount = len(views.remoteDownloads)
def pauseRunningDownloaders(): views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: if dl.getState() == 'downloading': self.pausedDownloaders.append(dl) finally: views.remoteDownloads.endRead() dlCount = len(self.pausedDownloaders)
def pauseAllDownloaders(): dlCount = len(views.remoteDownloads) if dlCount > 0: print "DTV: System is going to sleep, suspending downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.pause(block=True) finally: views.remoteDownloads.endRead()
print "DTV: System is going to sleep, suspending downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.pause(block=True) finally: views.remoteDownloads.endRead() dc = eventloop.addUrgentCall(lambda:pauseAllDownloaders(), "Suspending downloaders")
print "DTV: System is going to sleep, suspending %d download(s)." % dlCount for dl in self.pausedDownloaders: dl.pause(block=True) self.pausedDownloaders = list() dc = eventloop.addUrgentCall(lambda:pauseRunningDownloaders(), "Suspending downloaders for sleep")
def pauseAllDownloaders(): dlCount = len(views.remoteDownloads) if dlCount > 0: print "DTV: System is going to sleep, suspending downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.pause(block=True) finally: views.remoteDownloads.endRead()
time.sleep(2)
time.sleep(3)
def pauseAllDownloaders(): dlCount = len(views.remoteDownloads) if dlCount > 0: print "DTV: System is going to sleep, suspending downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.pause(block=True) finally: views.remoteDownloads.endRead()
def retstartAllDownloaders(): dlCount = len(views.remoteDownloads)
def retstartDownloaders(): dlCount = len(self.pausedDownloaders)
def retstartAllDownloaders(): dlCount = len(views.remoteDownloads) if dlCount > 0: print "DTV: System is awake, resuming downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.start() finally: views.remoteDownloads.endRead()
print "DTV: System is awake, resuming downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.start() finally: views.remoteDownloads.endRead() eventloop.addUrgentCall(lambda:retstartAllDownloaders(), "Restarting downloaders")
print "DTV: System is awake from sleep, resuming %s download(s)." % dlCount for dl in self.pausedDownloaders: dl.start() self.pausedDownloaders = None eventloop.addUrgentCall(lambda:retstartDownloaders(), "Resuming downloaders after sleep")
def retstartAllDownloaders(): dlCount = len(views.remoteDownloads) if dlCount > 0: print "DTV: System is awake, resuming downloads." views.remoteDownloads.beginRead() try: for dl in views.remoteDownloads: dl.start() finally: views.remoteDownloads.endRead()
ret = 2
ret = 10
def get(key): configLock.acquire() try: try: ret = configData[key] except KeyError: if key == 'DataDirectory': #FIXME add Windows support path = expanduser("~/Movies") try: makedirs(join(path,'Incomplete Downloads')) except: pass configData[key] = path ret = path elif key == 'FreeSpaceTarget': configData[key] = '200000...
print "onActivate (%d)" % wparam
def onActivate(hwnd, msg, wparam, lparam): print "onActivate (%d)" % wparam if theControl: print " .. has a control %s" % theControl if wparam == WA_ACTIVE or wparam == WA_CLICKACTIVE: print ".. calling activate() on it" theControl.activate() if wparam == WA_INACTIVE: print ".. calling deactivate() on it" theControl.de...
print " .. has a control %s" % theControl
def onActivate(hwnd, msg, wparam, lparam): print "onActivate (%d)" % wparam if theControl: print " .. has a control %s" % theControl if wparam == WA_ACTIVE or wparam == WA_CLICKACTIVE: print ".. calling activate() on it" theControl.activate() if wparam == WA_INACTIVE: print ".. calling deactivate() on it" theControl.de...
print ".. calling activate() on it"
def onActivate(hwnd, msg, wparam, lparam): print "onActivate (%d)" % wparam if theControl: print " .. has a control %s" % theControl if wparam == WA_ACTIVE or wparam == WA_CLICKACTIVE: print ".. calling activate() on it" theControl.activate() if wparam == WA_INACTIVE: print ".. calling deactivate() on it" theControl.de...
print ".. calling deactivate() on it"
def onActivate(hwnd, msg, wparam, lparam): print "onActivate (%d)" % wparam if theControl: print " .. has a control %s" % theControl if wparam == WA_ACTIVE or wparam == WA_CLICKACTIVE: print ".. calling activate() on it" theControl.activate() if wparam == WA_INACTIVE: print ".. calling deactivate() on it" theControl.de...
onLoadCallback = lambda url: onLoadCallback((lambda: theControl), url), onActionCallback = cb.onActionCallback, onDocumentLoadFinishedCallback = cb.onDocumentLoadFinishedCallback,
def onLoadCallback(getControl, url): control = getControl() print "onLoad for %s (control is %s)" % (url, control) if url == "test:remove": print "before remove" control.remove('victim') print "after remove" return True
elif exp.hours > 0: ret = "%d hours" % exp.hours
elif exp.seconds > 3600: ret = "%d hours" % (exp.seconds/3600)
def getExpirationTime(self): ret = "???" self.beginRead() self.feed.beginRead() try: if self.feed.expire == "never": ret = "never" else: if self.feed.expire == "feed": expireTime = self.feed.expireTime elif self.feed.expire == "system": expireTime = config.get('DefaultTimeUntilExpiration') exp = expireTime - (datetime...
ret = "%d minutes" % exp.minutes
ret = "%d minutes" % (exp.seconds/60)
def getExpirationTime(self): ret = "???" self.beginRead() self.feed.beginRead() try: if self.feed.expire == "never": ret = "never" else: if self.feed.expire == "feed": expireTime = self.feed.expireTime elif self.feed.expire == "system": expireTime = config.get('DefaultTimeUntilExpiration') exp = expireTime - (datetime...
print objectList[i].__class__
def checkSingleChannelGuide(objectList, fixIfPossible): guideCount = 0 for i in reversed(xrange(len(objectList))): print objectList[i].__class__ if isinstance(objectList[i], guide.ChannelGuide): guideCount += 1 if guideCount > 1: msg = "Extra chanel Guide" if fixIfPossible: util.failed("While checking database", detail...
self.fullscreenController = FullScreenVideoController.alloc().initWithVideoView_(self.videoView)
self.fullscreenController = FullScreenVideoController.alloc().initWithPreviousVideoView_(self.videoView)
def goFullscreen_(self, sender): self.fullscreenController = FullScreenVideoController.alloc().initWithVideoView_(self.videoView) self.fullscreenController.setDelegate_(self) self.fullscreenController.enterFullScreen()
def initWithVideoView_(self, videoView):
def initWithPreviousVideoView_(self, previousMovieView):
def initWithVideoView_(self, videoView): self = super(FullScreenVideoController, self).init() self.videoWindow = FullScreenVideoWindow.alloc().init(videoView).retain() self.videoWindow.controller = self self.delegate = nil return self
self.videoWindow = FullScreenVideoWindow.alloc().init(videoView).retain()
self.videoWindow = FullScreenVideoWindow.alloc().init(previousMovieView).retain()
def initWithVideoView_(self, videoView): self = super(FullScreenVideoController, self).init() self.videoWindow = FullScreenVideoWindow.alloc().init(videoView).retain() self.videoWindow.controller = self self.delegate = nil return self
def init(self, videoView):
def init(self, previousMovieView):
def init(self, videoView): frame = NSScreen.mainScreen().frame()
self.controller = None self.videoView = videoView self.previousSuperview = videoView.superview() if self.previousSuperview is not nil: self.videoView.retain() self.videoView.removeFromSuperviewWithoutNeedingDisplay() self.videoView.setFrameSize_(frame.size) self.contentView().addSubview_(self.videoView)
self.previousMovieView = previousMovieView self.movieView = QTMovieView.alloc().initWithFrame_(frame) self.movieView.setControllerVisible_(NO) self.movieView.setPreservesAspectRatio_(YES) self.movieView.setMovie_(previousMovieView.movie()) self.setContentView_(self.movieView)
def init(self, videoView): frame = NSScreen.mainScreen().frame()
self.videoView.retain() self.videoView.removeFromSuperviewWithoutNeedingDisplay() self.previousSuperview.addSubview_(self.videoView) self.videoView.setFrameSize_(self.previousSuperview.frame().size)
self.previousMovieView.setMovie_(self.movieView.movie())
def close(self): self.videoView.retain() self.videoView.removeFromSuperviewWithoutNeedingDisplay() self.previousSuperview.addSubview_(self.videoView) self.videoView.setFrameSize_(self.previousSuperview.frame().size) super(FullScreenVideoWindow, self).close()
if os.path.exists ("democracyplayer.1"): os.system ("gzip < democracyplayer.1 > democracyplayer.1.gz")
os.system ("gzip < " + os.path.join(platform_dir, 'democracyplayer.1') + " > " + os.path.join(platform_dir, 'democracyplayer.1.gz'))
def listfiles(path): return [f for f in glob(os.path.join(path, '*')) if os.path.isfile(f)]
application = self.getExternalViewerApp(moviePath) ok = NSWorkspace.sharedWorkspace().openFile_withApplication_andDeactivate_(moviePath, application, YES)
ok = NSWorkspace.sharedWorkspace().openFile_withApplication_andDeactivate_(moviePath, nil, YES)
def playItemExternally(self, itemID): item = app.PlaybackControllerBase.playItemExternally(self, itemID) moviePath = item.getVideoFilename() application = self.getExternalViewerApp(moviePath) ok = NSWorkspace.sharedWorkspace().openFile_withApplication_andDeactivate_(moviePath, application, YES) if not ok: print "DTV: m...
def getExternalViewerApp(self, filepath): """If the passed movie is an FLV file, we want to open it using the embedded VLC application. To check for FLV files we first check the file extension and then the first 3 bytes of the files (because it's currently possible to get FLV files without the .flv extension). """ isFL...
def playItemExternally(self, itemID): item = app.PlaybackControllerBase.playItemExternally(self, itemID) moviePath = item.getVideoFilename() application = self.getExternalViewerApp(moviePath) ok = NSWorkspace.sharedWorkspace().openFile_withApplication_andDeactivate_(moviePath, application, YES) if not ok: print "DTV: m...
self.selectDisplay(NullDisplay())
if hasattr(self,'selectDisplay'): self.selectDisplay(NullDisplay())
def checkSelectedTab(self, templateNameHint = None):
args[:0] = [info] eventloop.addIdle (callback, args, kwargs)
eventloop.addIdle (callback, (info,) + args, kwargs)
def _grabURLThread(callback, url, start, etag, modified, findHTTPAuth, getBody, args, kwargs): if getBody == False: info = grabURL(url, "HEAD", start, etag, modified, findHTTPAuth) if info == None: info = grabURL (url, "GET", start, etag, modified, findHTTPAuth) else: info = grabURL(url, "GET", start, etag, modified, f...
message = "%s requires a username and password for \"%s\"." % (url, domain) return PasswordController.alloc().init(message, prefillUser, prefillPassword).getAnswer()
ret = None self.httpAuthLock.acquire() try: message = "%s requires a username and password for \"%s\"." % (url, domain) ret = PasswordController.alloc().init(message, prefillUser, prefillPassword).getAnswer() finally: self.httpAuthLock.release() return ret;
def getHTTPAuth(self, url, domain, prefillUser = None, prefillPassword = None): """Ask the user for HTTP login information for a location, identified to the user by its URL and the domain string provided by the server requesting the authorization. Default values can be provided for prefilling the form. If the user subm...
self.updateUsingXML(html)
try: self.updateUsingXML(html) except: print "Error updating feed: %s" % (self.url,) raise
def update(self): #print "Updating %s" % self.url self.ufeed.beginRead() try: if self.updating: return else: self.updating = True finally: self.ufeed.endRead() if hasattr(self, 'initialHTML') and self.initialHTML is not None: html = self.initialHTML self.initialHTML = None self.updateUsingXML(html) if not self.updateUa...
if tag != 'rss':
if tag not in ['rss','feed']:
def startElementNS(self, name, qname, attrs): uri = name[0] tag = name[1] if self.firstTag: self.firstTag = False if tag != 'rss': raise xml.sax.SAXNotRecognizedException, "Not an RSS file" if tag.lower() == 'enclosure' or tag.lower() == 'content': self.enclosureCount += 1 elif tag.lower() == 'link': self.inLink = True...
self.parent.domHandler.addItemBefore(self.currentXML(obj), self.view.getObjectByID(next).tid)
self.toAdd.append(obj) self.addBefore = self.view.getObjectByID(next).tid self.addCallback()
def onAdd(self, obj, id): if len(self.toChange) > 0 or len(self.toRemove) > 0: self.callback() if self.parent.domHandler: next = self.view.getNextID(id) if next == None: self.toAdd.append(obj) self.addCallback() else: self.callback() self.parent.domHandler.addItemBefore(self.currentXML(obj), self.view.getObjectByID(nex...
if self.anchorType == 'parentNode': self.parent.domHandler.addItemAtEnd(xml, self.anchorId) if self.anchorType == 'nextSibling': self.parent.domHandler.addItemBefore(xml, self.anchorId)
if self.addBefore: self.parent.domHandler.addItemBefore(xml, self.addBefore) else: if self.anchorType == 'parentNode': self.parent.domHandler.addItemAtEnd(xml, self.anchorId) if self.anchorType == 'nextSibling': self.parent.domHandler.addItemBefore(xml, self.anchorId)
def doAdd(self, xml): # Adding it at the end of the list. Must add it relative to # the anchor. if self.anchorType == 'parentNode': self.parent.domHandler.addItemAtEnd(xml, self.anchorId) if self.anchorType == 'nextSibling': self.parent.domHandler.addItemBefore(xml, self.anchorId)
NSColor.whiteColor().set()
self.backgroundColor.set()
def drawRect_(self, rect): NSColor.whiteColor().set() NSRectFill(rect)
self.videoAreaView.prepare()
def onSelected(self): self.enableSecondaryControls(YES) self.preventSystemSleep(True) self.videoAreaView.prepare()
renderer = self.getRendererForItem(item) renderer.selectPlaylistItem(item, self.volumeSlider.floatValue()) self.videoAreaView.setup(renderer, item) self.progressDisplayer.setup(renderer) self.renderer = renderer
self.renderer = self.getRendererForItem(item) self.renderer.selectPlaylistItem(item, self.volumeSlider.floatValue()) self.videoAreaView.setup(self.renderer, item) self.progressDisplayer.setup(self.renderer)
def selectPlaylistItem(self, item): renderer = self.getRendererForItem(item) renderer.selectPlaylistItem(item, self.volumeSlider.floatValue()) self.videoAreaView.setup(renderer, item) self.progressDisplayer.setup(renderer) self.renderer = renderer
def awakeFromNib(self): self.hostWindow = nil def prepare(self): self.hostWindow = self.window() assert self.hostWindow is not nil
def setup(self, renderer, item):
def awakeFromNib(self): self.hostWindow = nil
self.hostWindow.addChildWindow_ordered_(self.videoWindow, NSWindowAbove) def setup(self, renderer, item):
def prepare(self): self.hostWindow = self.window() assert self.hostWindow is not nil self.adjustVideoWindowFrame() self.hostWindow.addChildWindow_ordered_(self.videoWindow, NSWindowAbove)
self.hostWindow.removeChildWindow_(self.videoWindow)
self.window().removeChildWindow_(self.videoWindow)
def teardown(self): if self.videoWindow.isFullScreen: self.videoWindow.exitFullScreen() self.hostWindow.removeChildWindow_(self.videoWindow) self.videoWindow.orderOut_(nil) self.videoWindow.teardown()
return quoteattr(self.lastQuery)
return escape(self.lastQuery)
def quoteLastQuery(self): return quoteattr(self.lastQuery)
return self.web.changeItems(pairs)
newPairs = [] for id, xml in pairs: newPairs.append((id, xml.decode('utf-8'))) return self.web.changeItems(newPairs)
def changeItems(self, pairs): return self.web.changeItems(pairs)
newfilename, error)
newfilename, e)
def moveToMoviesDirectory(self): """Move our downloaded file from the Incomplete Downloads directoy to the movies directory. """
if id == mainDisplay.kargs['id']: mainDisplay.reInit([], {'id': id}) return
self.itemListSelection.clearSelection() self.updateMenus() tab = tls.currentView.getObjectByID(id) mainDisplay.reInit([], {'id': tab.obj.getID()}) return
def displayCurrentTabContent(self): frame = app.controller.frame mainDisplay = frame.getDisplay(frame.mainDisplay)
except KeyError:
except:
def getThumbnailURL(self): self.confirmDBThread() # Try to get the thumbnail specific to the video enclosure videoEnclosure = self.getFirstVideoEnclosure() if videoEnclosure is not None: try: return videoEnclosure["thumbnail"]["url"] except: pass # Try to get any enclosure thumbnail for enclosure in self.entry.enclosur...
mimetype = self.getMimeType(link)
if ((link[-4:].lower() in ['.mov','.wmv','.mp4','.mp3','.mpg','.avi']) or (link[-5:].lower() in ['.mpeg'])): mimetype = 'video/unknown' elif link.find('?') > 0 and link.lower().find('.htm') == -1: mimetype = self.getMimeType(link) else: mimetype = 'text/html'
def processLinks(self,links, depth = 0,linkNumber = 0): maxDepth = 2 urls = links[0] links = links[1] if depth<maxDepth: for link in urls: if depth == 0: linkNumber += 1 print "Processing %s (%d)" % (link,linkNumber) #FIXME keep the connection open mimetype = self.getMimeType(link) #print " mimetype is "+mimetype if mi...
if (mimetype.startswith('text/html') or mimetype.startswith('application/xhtml+xml') or mimetype.startswith('text/xml') or mimetype.startswith('application/xml') or mimetype.startswith('application/rss+xml') or mimetype.startswith('application/atom+xml') or mimetype.startswith('application/rdf+xml') ):
if ((mimetype.startswith('text/html') or mimetype.startswith('application/xhtml+xml') or mimetype.startswith('text/xml') or mimetype.startswith('application/xml') or mimetype.startswith('application/rss+xml') or mimetype.startswith('application/atom+xml') or mimetype.startswith('application/rdf+xml') ) and depth < max...
def processLinks(self,links, depth = 0,linkNumber = 0): maxDepth = 2 urls = links[0] links = links[1] if depth<maxDepth: for link in urls: if depth == 0: linkNumber += 1 print "Processing %s (%d)" % (link,linkNumber) #FIXME keep the connection open mimetype = self.getMimeType(link) #print " mimetype is "+mimetype if mi...
self.app = NSApplication.sharedApplication() NSBundle.loadNibNamed_owner_("MainMenu", self.app) controller = self.app.delegate()
self.appl = NSApplication.sharedApplication() NSBundle.loadNibNamed_owner_("MainMenu", self.appl) controller = self.appl.delegate()
def __init__(self): self.app = NSApplication.sharedApplication() NSBundle.loadNibNamed_owner_("MainMenu", self.app) controller = self.app.delegate() controller.actualApp = self
def __init__(self, app):
def __init__(self, appl):
def __init__(self, app): """The initially active display will be an instance of NullDisplay.""" # Do this in two steps so that self.obj is set when self.obj.init # is called. That way, init can turn around and call selectDisplay. self.obj = MainController.alloc() self.obj.init(self, app)
self.obj.init(self, app)
self.obj.init(self, appl)
def __init__(self, app): """The initially active display will be an instance of NullDisplay.""" # Do this in two steps so that self.obj is set when self.obj.init # is called. That way, init can turn around and call selectDisplay. self.obj = MainController.alloc() self.obj.init(self, app)
def init(self, owner, app):
def init(self, owner, appl):
def init(self, owner, app): # owner is the actual frame object (the argument to onSelected, etc) NSObject.init(self) NSBundle.loadNibNamed_owner_("MainWindow", self)
self.app = app
self.appl = appl
def init(self, owner, app): # owner is the actual frame object (the argument to onSelected, etc) NSObject.init(self) NSBundle.loadNibNamed_owner_("MainWindow", self)