rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
downloads = app.globalViewList['remoteDownloads'] dlCount = len(downloads) if dlCount > 0: print "DTV: System is awake, resuming downloads." downloads.beginRead() try: for dl in downloads: dl.start() finally: downloads.endRead()
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() eventloop.addUrgentCall(lambda:retstartAllDownloaders(), "Resta...
def workspaceDidWake_(self, notification): downloads = app.globalViewList['remoteDownloads'] dlCount = len(downloads) if dlCount > 0: print "DTV: System is awake, resuming downloads." downloads.beginRead() try: for dl in downloads: dl.start() finally: downloads.endRead()
print "response: ", id
def handleHTTPAuthResponse(id, authHeader): callback = waitingHTTPAuthCallbacks.pop(id) print "response: ", id callback(authHeader)
if tab.isGuide() and url.startswith(tab.obj.getURL()):
if tab and tab.isGuide() and url.startswith(tab.obj.getURL()):
def onURLLoad(self, url): #print "DTV: got %s" % url try: # Special-case non-'action:'-format URL if url.startswith ("template:"): self.dispatchAction ('switchTemplate', name = url[len("template:"):]) return False
print "NOT IMPLEMENTED"
eventloop.addIdle(app.controller.removeCurrentItems, "Remove Videos")
def removeVideos_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
print "NOT IMPLEMENTED"
eventloop.addIdle(app.controller.copyCurrentItemURL, "Copy Video URL")
def copyVideoURL_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
print "NOT IMPLEMENTED"
eventloop.addIdle(app.controller.renameCurrentChannel, "Rename Channel Tab")
def renameChannelFolder_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
eventloop.addUrgentCall(app.controller.removeCurrentFeed, "Remove channel")
eventloop.addIdle(app.controller.removeCurrentFeed, "Remove channel")
def removeChannel_(self, sender): eventloop.addUrgentCall(app.controller.removeCurrentFeed, "Remove channel")
eventloop.addUrgentCall(app.controller.updateCurrentFeed, "Update current feed")
eventloop.addIdle(app.controller.updateCurrentFeed, "Update current feed")
def updateChannel_(self, sender): eventloop.addUrgentCall(app.controller.updateCurrentFeed, "Update current feed")
eventloop.addUrgentCall(app.controller.updateAllFeeds, "Update all channels")
eventloop.addIdle(app.controller.updateAllFeeds, "Update all channels")
def updateAllChannels_(self, sender): eventloop.addUrgentCall(app.controller.updateAllFeeds, "Update all channels")
eventloop.addUrgentCall(app.controller.copyCurrentFeedURL, "Copy channel URL")
eventloop.addIdle(app.controller.copyCurrentFeedURL, "Copy channel URL")
def copyChannelURL_(self, sender): eventloop.addUrgentCall(app.controller.copyCurrentFeedURL, "Copy channel URL")
print "NOT IMPLEMENTED"
eventloop.addIdle(app.controller.renameCurrentPlaylist, "Rename Playlist")
def renamePlaylist_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
print "NOT IMPLEMENTED"
eventloop.addIdle(app.controller.removeCurrentPlaylist, "Remove Playlist")
def removePlaylist_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
if self.frame.mainDisplay.hostedDisplay is not app.controller.videoDisplay: app.controller.playbackController.enterPlayback() else: self.videoDisplayController.playPause_(sender)
self.videoDisplayController.playPause_(sender)
def playPause_(self, sender): if self.frame.mainDisplay.hostedDisplay is not app.controller.videoDisplay: app.controller.playbackController.enterPlayback() else: self.videoDisplayController.playPause_(sender)
print "NOT IMPLEMENTED"
eventloop.addIdle(lambda:app.controller.playbackController.skip(1), "Skip Video")
def nextVideo_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
print "NOT IMPLEMENTED"
eventloop.addIdle(lambda:app.controller.playbackController.skip(-1), "Skip Video")
def previousVideo_(self, sender): print "NOT IMPLEMENTED" # $$$$$$$$$$$$$$
return self.actionGroups['VideosSelected'] or display is app.controller.videoDisplay
return display is app.controller.videoDisplay
def validateMenuItem_(self, item): result = False action = item.action() display = self.frame.mainDisplay.hostedDisplay if action == 'removeVideos:': self.updateMenuItem(item, 'video_remove') result = self.actionGroups['VideoSelected'] or self.actionGroups['VideosSelected'] elif action == 'saveVideoAs:': result = Fals...
if x == self.higher:
if x is y: return 0 elif x == self.higher:
def sortFunc(self,x,y): if x == self.higher: return 1 else: return -1
self.minimumSpaceField.setIntValue_(config.get(prefs.PRESERVE_X_GB_FREE))
self.minimumSpaceField.setFloatValue_(config.get(prefs.PRESERVE_X_GB_FREE))
def awakeFromNib(self): preserve = config.get(prefs.PRESERVE_DISK_SPACE) self.preserveSpaceCheckBox.setState_(preserve and NSOnState or NSOffState) self.minimumSpaceField.setEnabled_(preserve) self.minimumSpaceField.setIntValue_(config.get(prefs.PRESERVE_X_GB_FREE)) itemTag = int(config.get(prefs.EXPIRE_AFTER_X_DAYS) *...
self.html = "<body><script type=\"text/javascript\">\neventURL('template:first-time-intro');\n</script></body>" self.viewed = False ScheduleEvent(3600,self.update,True)
self.sawIntro = False self.cachedGuideBody = None self.loadedThisSession = False self.cond = threading.Condition()
def __init__(self): self.html = "<body><script type=\"text/javascript\">\neventURL('template:first-time-intro');\n</script></body>"
return (0,temp)
del temp['cond'] del temp['loadedThisSession'] return (1,temp)
def __getstate__(self): temp = copy(self.__dict__) return (0,temp)
assert(version == 0) self.__dict__ = data ScheduleEvent(0,self.update,False) ScheduleEvent(3600,self.update,True)
def __setstate__(self,state): (version, data) = state assert(version == 0) self.__dict__ = data ScheduleEvent(0,self.update,False) ScheduleEvent(3600,self.update,True)
if not self.viewed: html = self.html ScheduleEvent(0,self.update,False) self.viewed = True return html else: return self.html
self.cond.acquire() try: print "guide in getHTML" if not self.sawIntro: print "guide: not viewed. toggling flag." self.sawIntro = True print "guide: setting viewed. now %s" % self.sawIntro return firstTimeIntroBody else: if not self.cachedGuideBody: print "guide scheduling a load and returning apology" Sch...
def getHTML(self): if not self.viewed: html = self.html ScheduleEvent(0,self.update,False) self.viewed = True return html else: return self.html
view = self.templateHandle.getTemplateVariable(viewName)
def handleSelect(self, area, viewName, id, shiftDown, ctrlDown): shift = (shiftDown == '1') ctrl = (ctrlDown == '1') view = self.templateHandle.getTemplateVariable(viewName) controller.selection.selectItem(area, view, int(id), shift, ctrl)
if not data.has_key('id'): self.__class__ = DropItLikeItsHot
def __setstate__(self,state): (version, data) = state
if not dep_util.newer(sourceFile, outFile): continue print "Compiling '%s' template to %s" % (template, outFile) (tcc, handle) = compileTemplate(template)
def compileAllTemplates(root): manifest = file(os.path.join(root,'portable','compiled_templates','__init__.py'),'wb') setResourcePath(os.path.join(root,'resources')) manifest = open(os.path.join(root,'portable','compiled_templates','__init__.py'),'wb') manifest.write('# This is a generated file. Do not edit.\n\n') for...
f = open(outFile,"wb") f.write(tcc.getOutput()) f.close()
if dep_util.newer(sourceFile, outFile): print "Compiling '%s' template to %s" % (template, outFile) (tcc, handle) = compileTemplate(template) f = open(outFile,"wb") f.write(tcc.getOutput()) f.close()
def compileAllTemplates(root): manifest = file(os.path.join(root,'portable','compiled_templates','__init__.py'),'wb') setResourcePath(os.path.join(root,'resources')) manifest = open(os.path.join(root,'portable','compiled_templates','__init__.py'),'wb') manifest.write('# This is a generated file. Do not edit.\n\n') for...
info['filename'].replace ("/","") info['filename'].replace ("\\","")
info['filename'] = cleanFilename(info['filename'])
def grabURL(url, type="GET",start = 0, etag=None,modified=None): maxDepth = 10 maxAuthAttempts = 5 redirURL = url userAgent = "%s/%s (%s)" % \ (config.get(config.SHORT_APP_NAME), config.get(config.APP_VERSION), config.get(config.PROJECT_URL)) myHeaders = {"User-Agent": userAgent} (scheme, host, path, params, query, fr...
return re.compile("^.*?([^/]+)/?$").search(path).expand("\\1")
ret = re.compile("^.*?([^/]+)/?$").search(path).expand("\\1") return cleanFilename(ret)
def filenameFromURL(self,url): (scheme, host, path, params, query, fragment) = parseURL(url) if len(path): try: return re.compile("^.*?([^/]+)/?$").search(path).expand("\\1") except: return 'unknown' else: return "unknown"
for name in ('unwatched-items', 'expiring-items', 'saved-items'):
for name in ('watchable-items', 'unwatched-items', 'expiring-items', 'saved-items'):
def getWatchable(self): view = None for name in ('unwatched-items', 'expiring-items', 'saved-items'): try: namedView = self.templateHandle.findNamedView(name) if namedView.getView().len() > 0: view = namedView break except: pass if view is None: return None return view.getView()
"playlist.
"playlist".
def __init__(self, type): """Construct a TabOrder. type should be either "channel", or "playlist. """
import imp mfile, daemonPath, mdesc = imp.find_module('dl_daemon')
savedSysPath = list(sys.path) found = False while not found: mpath = getModulePath('resource') if 'osx' in mpath: sys.path.remove(os.path.dirname(mpath)) else: found = True import resource resource.setrlimit(resource.RLIMIT_NOFILE, (-1,-1)) del resource del sys.modules['resource'] sys.path = savedSysPath daemonP...
def launchDownloaderDaemon(): import imp mfile, daemonPath, mdesc = imp.find_module('dl_daemon') daemonPrivatePath = os.path.join(daemonPath, 'private') sys.path[0:0] = [daemonPath, daemonPrivatePath] import Democracy_Downloader Democracy_Downloader.launch()
except (IOError, OSError, shutil.ERROR), e:
except (IOError, OSError, shutil.Error), e:
def moveToDirectory (self, directory): newfilename = os.path.join(directory, self.shortFilename) newfilename = shortenFilename(newfilename) if newfilename == self.filename: return newfilename = nextFreeFilename(newfilename) try: shutil.move(self.filename, newfilename) except (IOError, OSError, shutil.ERROR), e: print "...
match = re.match(r"GET /dtv/dtvapi/([^?]+)\?(.*)", request)
match = re.match(r"GET /dtv/dtvapi/([^?]+)\?([^ ]*)", request)
def handleRequest(self, request, reqNum): ## Mutator stream ## match = re.match("GET /dtv/mutators/([^ ]*)", request) if match: cookie = match.group(1) print "My event cookie is %s (%d)" % (cookie, reqNum) self.push("""HTTP/1.0 200 OK
if header not in self.headers:
if header not in self.headers or self.headers[header] is None: if header in self.headers: print "DTV: Warning: header %s is None for %s:%s%s in parseHeader for httpclient" % (header, self.host, self.port, self.path)
def parseHeader(self, line): header, value = line.split(":", 1) value = value.strip() header = header.lstrip().lower() if value == '': self.handleError(BadHeaderLine(line)) return if header not in self.headers: self.headers[header] = value else: self.headers[header] += (',%s' % value)
obj.update()
thread = threading.Thread(target=obj.update) thread.setDaemon(False) thread.start()
def updateFeed(self, url):
self.shutDown = True
self.shutdown = True
def downloaderLoop(self): try: self.listenLoop() print "Downloader listen loop completed" finally: self.shutDown = True from dl_daemon import download download.shutDown()
app.controller.getBackendDelegate().saveFailed(err)
app.delegate.saveFailed(err)
def saveDatabaseIdle (db=None, pathname=None): err = saveDatabase(db, pathname) if err: print "Save failed: %s" % (err,) try: err = err.strerror except: pass app.controller.getBackendDelegate().saveFailed(err) eventloop.addTimeout(300, saveDatabaseIdle, "Database Save", args=(db, pathname))
[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)]
dest = '/usr/share/man/man1/democracyplayer.1' if self.root: dest = change_root(self.root, dest) os.system ("gzip -f %s" % dest)
def install_app_config(self): source = os.path.join(resource_dir, 'app.config.template') dest = '/usr/share/democracy/resources/app.config' revision = util.queryRevision(root_dir) if revision is None: revision = "unknown" if self.root: dest = change_root(self.root, dest) self.mkpath(os.path.dirname(dest)) self.copy_fil...
if obj.downloadState() != "finished":
if obj.getState() != "finished":
def mappableToPlaylistItem(obj): if not isinstance(obj, item.Item): return False # NEEDS: check to see if the download has finished in a cleaner way if obj.downloadState() != "finished": return False return True
class playlistItemFromItem(frontend.PlaylistItem):
class PlaylistItemFromItem (frontend.PlaylistItem):
def mappableToPlaylistItem(obj): if not isinstance(obj, item.Item): return False # NEEDS: check to see if the download has finished in a cleaner way if obj.downloadState() != "finished": return False return True
return "/Users/gschmidt/Movies/mahnamahna.mpeg"
return self.item.getFilename()
def getPath(self): # NEEDS return "/Users/gschmidt/Movies/mahnamahna.mpeg"
return playlistItemFromItem(obj)
return PlaylistItemFromItem(obj)
def mapToPlaylistItem(obj): return playlistItemFromItem(obj)
if xlibhelper.XInitThreads() == 0: print "WARNING: XInitThreads() failed!"
def Run(self): locale.setlocale(locale.LC_ALL, '') gettext.bindtextdomain("democracyplayer", resource.path("../../locale")) gettext.textdomain("democracyplayer") gettext.bind_textdomain_codeset("democracyplayer","UTF-8") gtk.glade.bindtextdomain("democracyplayer", resource.path("../../locale")) gtk.glade.textdomain("de...
if status == 304: else:
if not status == 304:
def update(self): if not self.initialHTML is None: html = self.initialHTML self.initialHTML = None redirURL=self.url status = 200 else: (html,url, redirURL, status) = self.getHTML(self.url) if status == 304: #pass else: if not html is None: links = self.scrapeLinks(html, redirURL, setTitle=True) self.processLinks(links...
willRestart = False
installList = list() upgradeList = list() installedComponents = list() installableComponents = _gatherInstallableComponents() for installable in installableComponents: installed = _checkInstalledComponent(installable) if installed is None: installList.append(installable) else: installedComponents.append(installed) ins...
def run(): willRestart = False if _shouldRun(): print 'DTV: running QuickTime Components Installer.' _didRun() installList = list() upgradeList = list() installableComponents = _gatherInstallableComponents() for installable in installableComponents: installed = _checkInstalledComponent(installable) if installed is No...
print 'DTV: running QuickTime Components Installer.'
print 'DTV: Running QuickTime Components Installer.'
def run(): willRestart = False if _shouldRun(): print 'DTV: running QuickTime Components Installer.' _didRun() installList = list() upgradeList = list() installableComponents = _gatherInstallableComponents() for installable in installableComponents: installed = _checkInstalledComponent(installable) if installed is No...
installList = list() upgradeList = list() installableComponents = _gatherInstallableComponents() for installable in installableComponents: installed = _checkInstalledComponent(installable) if installed is None: installList.append(installable) else: installedVersion = _getComponentVersion(installed) installableVersion ...
return _performInstallation(installList, upgradeList) return False
def run(): willRestart = False if _shouldRun(): print 'DTV: running QuickTime Components Installer.' _didRun() installList = list() upgradeList = list() installableComponents = _gatherInstallableComponents() for installable in installableComponents: installed = _checkInstalledComponent(installable) if installed is No...
commands = 'echo Upgrading %s \n' % upgradeInfo[0] commands += 'mv -v "%s" "%s" \n' % (upgradeInfo[0], PATH_TO_TRASH)
commands = _getMoveToTrashCommands(upgradeInfo[0])
def _getUpgradeCommands(upgradeInfo): commands = 'echo Upgrading %s \n' % upgradeInfo[0] commands += 'mv -v "%s" "%s" \n' % (upgradeInfo[0], PATH_TO_TRASH) commands += _getInstallCommands(upgradeInfo[1], os.path.dirname(upgradeInfo[0])) return commands
def _runScript(script):
def _runScript(script, wait=False):
def _runScript(script): path = _makeTempScript(script) wrapper = 'osascript -e "do shell script \\\"/bin/sh %s\\\" with administrator privileges"\n' % path wrapper += 'rm %s\n' % path path = _makeTempScript(wrapper) task = NSTask.alloc().init() task.setLaunchPath_('/bin/sh') task.setArguments_([path]) task.setStandardO...
parser = xml.sax.make_parser() parser.setFeature(xml.sax.handler.feature_namespaces, 1) handler = RSSLinkGrabber(info['redirected-url'],charset) parser.setContentHandler(handler)
def _generateFeedCallback(self, info, removeOnError): """This is called by grabURL to generate a feed based on the type of data found at the given URL """ # FIXME: This probably should be split up a bit. The logic is # a bit daunting
@platformutils.onMainThread
@platformutils.onMainThreadWaitingUntilDone
def hasXiphComponent(self): return len(glob.glob('/Library/QuickTime/Ogg*')) > 0
value = self.pop('media:thumbnail') if self.inentry: if self.inenclosure: self.entries[-1]['enclosures'][-1]['thumbnail']['url'] = value else: self.entries[-1]['thumbnail']['url'] = value
self.pop('media:thumbnail')
def _end_media_thumbnail(self):
platformUtils.callOnMainThreadAfterDelay(0.5, self.palette.reveal, self)
platformutils.callOnMainThreadAfterDelay(0.5, self.palette.reveal, self)
def setup(self, renderer, item): if self.contentView() != renderer.view: self.setContentView_(renderer.view) self.palette.setup(item, renderer) if self.isFullScreen: platformUtils.callOnMainThreadAfterDelay(0.5, self.palette.reveal, self)
info = grabURL(self.url,"GET")
info = grabURL(self.url,"GET", findHTTPAuth = findHTTPAuth)
def runDownloader(self, retry = False): if retry: pos = self.currentSize try: filehandle = file(self.filename,"r+b") filehandle.seek(pos) except: filehandle = file(self.filename,"w+b") self.currentSize = 0 totalSize = self.totalSize pos = 0 if totalSize > 0: filehandle.seek(totalSize-1) filehandle.write(' ') filehandle...
if self.isFinished and not wasFinished:
if self.isFinished() and not wasFinished:
def updateStatus(cls, data): self = _getDownloader (dlid=data['dlid']) # print data if self is not None: if self.status == data: return wasFinished = self.isFinished() self.status = data # Store the time the download finished if self.isFinished and not wasFinished: for item in self.itemList: item.onDownloadFinished() s...
self.handleError(shortReason, errorMessage)
self.dler.handleError(shortReason, errorMessage)
def handleBitTorrentError(self, errorMessage): if "problem connecting to the tracker" in errorMessage.lower(): shortReason = _("Can't connect") else: shortReason = _("Error") self.handleError(shortReason, errorMessage)
def init(secondslf, message):
def init(self, message):
def init(secondslf, message): # as loaded, button titles are "Yes" and "No" and window title is # "Question", but these could be made arguments to init() pool = NSAutoreleasePool.alloc().init() # sets defaultButton, alternateButton, textArea, window NSBundle.loadNibNamed_owner_("QuestionWindow", self) self.textArea.set...
elif descriptor == config.ICON_CACHE_DIR: value = os.path.join(get(config.SUPPORT_DIRECTORY), 'icon-cache')
elif descriptor == config.ICON_CACHE_DIRECTORY: path = get(config.SUPPORT_DIRECTORY) path = os.path.join(path, 'icon-cache') value = path
def get(descriptor): value = None if descriptor == config.MOVIES_DIRECTORY: path = os.path.join(MOVIES_DIRECTORY_PARENT, config.get(config.SHORT_APP_NAME)) try: os.makedirs(os.path.join(path,'Incomplete Downloads')) except: pass value = path elif descriptor == config.SUPPORT_DIRECTORY: path = os.path.join(SUPPORT_DIR...
if not (key.startswith('t:') or key.startswith('i18n:')):
if (not (key.startswith('t:') or key.startswith('i18n:')) or key == 't:contextMenu'):
def startElement(self,name, attrs): self.depth = self.depth + 1
def handleCommandLine(self, commandLine): singleclick.setCommandLineArgs(getArgumentList(commandLine)) def handleSecondCommandLine(self, commandLine): singleclick.parseCommandLineArgs(getArgumentList(commandLine))
def handleCommandLine(self, commandLine): singleclick.setCommandLineArgs(getArgumentList(commandLine))
self.setFrame_display_animate_(NSScreen.mainScreen().frame(), YES, YES)
self.setFrame_display_animate_(self.parent.screen().frame(), YES, YES)
def enterFullScreen(self): SetSystemUIMode(kUIModeAllHidden, 0) self.isFullScreen = YES self.parent = self.parentWindow() self.frameInParent = self.frame() self.setFrame_display_animate_(NSScreen.mainScreen().frame(), YES, YES) self.parent.removeChildWindow_(self) self.parent.orderOut_(nil) self.makeKeyAndOrderFront_(n...
screenSize = NSScreen.mainScreen().frame().size
screenSize = parent.screen().frame().size
def reveal(self, parent): self.update_(nil) self.volumeSlider.setFloatValue_(app.Controller.instance.videoDisplay.getVolume()) screenSize = NSScreen.mainScreen().frame().size height = self.frame().size.height frame = ((0, -height), (screenSize.width, height)) self.setFrame_display_(frame, NO) parent.addChildWindow_orde...
message = ngettext ("You have %d download still in progress.", "You have %d download still in progress.", downloadsCount) % (downloadsCount,)
message = _("You have %d download still in progress.", "You have %d download still in progress.", downloadsCount) % (downloadsCount,)
def interruptDownloadsAtShutdown(self, downloadsCount): summary = _("Are you sure you want to quit?") message = ngettext ("You have %d download still in progress.", "You have %d download still in progress.", downloadsCount) % (downloadsCount,) buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_QUIT, gtk.RESPON...
self.stopReadTimeout() if self.readSomeData: timeout = SOCKET_READ_TIMEOUT else: timeout = SOCKET_INITIAL_READ_TIMEOUT self.readTimeout = eventloop.addTimeout(timeout, self.onReadTimeout,
return self.readTimeout = eventloop.addTimeout(SOCKET_INITIAL_READ_TIMEOUT, self.onReadTimeout,
def startReadTimeout(self): if self.disableReadTimeout: return if self.readTimeout is not None: self.stopReadTimeout() if self.readSomeData: timeout = SOCKET_READ_TIMEOUT else: timeout = SOCKET_INITIAL_READ_TIMEOUT self.readTimeout = eventloop.addTimeout(timeout, self.onReadTimeout, "AsyncSocket.onReadTimeout")
self.stopReadTimeout() self.timedOut = True self.handleEarlyClose('read')
if self.readSomeData: timeout = SOCKET_READ_TIMEOUT else: timeout = SOCKET_INITIAL_READ_TIMEOUT if clock() < self.lastClock + timeout: self.readTimeout = eventloop.addTimeout(self.lastClock + timeout - clock(), self.onReadTimeout, "AsyncSocket.onReadTimeout") else: self.readTimeout = None self.timedOut = True self.han...
def onReadTimeout(self): self.stopReadTimeout() self.timedOut = True self.handleEarlyClose('read')
return quote(data,'')
return quote(data.encode('utf-8'), '')
def urlencode(data): return quote(data,'')
elif item.getPubDateParsed() < next.getPubDateParsed():
elif item.getPubDateParsed() > next.getPubDateParsed():
def downloadNextAuto(self, dontUse = []): self.ufeed.beginRead() try: next = None
if self.method != 'GET':
if self.method != 'GET' or self.willHandleResponse:
def callbackIntercept(self, response): # we send the callback for GET requests during the headers if self.method != 'GET': HTTPClient.callbackIntercept(self, response)
if self.method == 'GET':
HTTPClient.onHeaders(self, headers) if (self.method == 'GET' and not self.willHandleResponse):
def onHeaders(self, headers): if self.method == 'GET': headers['body'] = '' # make it match the behaviour of a HEAD request self.callback(self.prepareResponse(headers)) self.cancel() else: HTTPClient.onHeaders(self, headers)
else: HTTPClient.onHeaders(self, headers)
def onHeaders(self, headers): if self.method == 'GET': headers['body'] = '' # make it match the behaviour of a HEAD request self.callback(self.prepareResponse(headers)) self.cancel() else: HTTPClient.onHeaders(self, headers)
attrPattern = re.compile("^(.*)@@@(.*?)@@@(.*)$"); rawAttrPattern = re.compile("^(.*)\*\*\*(.*?)\*\*\*(.*)$");
attrPattern = re.compile("^(.*)@@@(.*?)@@@(.*)$") rawAttrPattern = re.compile("^(.*)\*\*\*(.*?)\*\*\*(.*)$") HTMLPattern = re.compile("^.*<body.*?>(.*)</body\s*>", re.S)
def __str__(self): return self.message
self.repeatList.append(lambda x,y:'<') self.repeatList.append(lambda x,y:name) for key in attrs.keys(): if not (key in ['t:replace','t:replaceMarkup','t:hideIfKey',
if name == 't:includeTemplate': if hide: self.repeatList.append(lambda x,y: self.returnIf(hideFunc(x,y),self.fillTemplate(attrs['filename'],x))) else: self.repeatList.append(lambda x,y: self.fillTemplate(attrs['filename'],x)) else: self.repeatList.append(lambda x,y:'<') self.repeatList.append(lambda x,y:name) for key i...
def startElement(self,name, attrs): self.depth += 1 if self.inReplace: pass elif 't:hideIfViewEmpty' in attrs.keys() or 't:hideIfViewNotEmpty' in attrs.keys(): nodeId = generateId() if 't:hideIfViewEmpty' in attrs.keys(): viewName = attrs['t:hideIfViewEmpty'] ifInvert = False else: viewName = attrs['t:hideIfViewNotEmpt...
if self.inReplace and self.depth == self.replaceDepth:
if name == 't:include': pass elif name == 't:filter': pass elif name == 't:sort': pass elif name == 't:includeTemplate': pass elif self.inReplace and self.depth == self.replaceDepth:
def endElement(self,name): if self.inReplace and self.depth == self.replaceDepth: if self.inRepeatView: self.repeatList.append(lambda x,y: '</%s>'%name) else: self.outString.write('</%s>'%name) self.inReplace = False elif self.inRepeatView and self.depth == self.repeatDepth: self.inRepeatView = False self.repeatList.ap...
elif name == 't:include': pass elif name == 't:filter': pass elif name == 't:sort': pass
def endElement(self,name): if self.inReplace and self.depth == self.replaceDepth: if self.inRepeatView: self.repeatList.append(lambda x,y: '</%s>'%name) else: self.outString.write('</%s>'%name) self.inReplace = False elif self.inRepeatView and self.depth == self.repeatDepth: self.inRepeatView = False self.repeatList.ap...
if item.downloader is None:
if item.downloader is None and item.__class__ == Item:
def reconnectDownloaders(): reconnected = set() for item in views.items: item.setupLinks() reconnected.add(item.downloader) for downloader in views.remoteDownloads: if downloader not in reconnected: print "removing orphaned downloader: ", downloader.url downloader.remove() manualFeed = util.getSingletonDDBObject(views....
self.changer = templateoptimize.XMLChangeOptimizer()
self.changer = templateoptimize.HTMLChangeOptimizer()
def setUp(self): self.changer = templateoptimize.XMLChangeOptimizer()
self.changer.setInitialXML('abc123', first)
self.changer.setInitialHTML('abc123', first)
def testBigChange(self): first = '<div class="item" id="abc123">foo</div>' second = '<div class="item" id="abc123">bar</div>' self.changer.setInitialXML('abc123', first) self.checkChange('abc123', second, {}, True)
self.changer.setInitialXML('abc123', first)
self.changer.setInitialHTML('abc123', first)
def testNoChange(self): first = '<div class="item" id="abc123">foo</div>' self.changer.setInitialXML('abc123', first) changes = self.changer.calcChanges('abc123', first) self.assertEquals(len(changes), 0)
self.changer.setInitialXML('abc123', first)
self.changer.setInitialHTML('abc123', first)
def testAttributeChange(self): first = '<div class="item" id="abc123">foo</div>' second = '<div class="item highlighed" id="abc123">foo</div>' self.changer.setInitialXML('abc123', first) self.checkChange('abc123', second, {'class': 'item highlighed'}, False)
self.changer.setInitialXML('abc123', first)
self.changer.setInitialHTML('abc123', first)
def testMultipleChanges(self): first = '<div class="item" id="abc123">foo</div>' second = '<div class="item highlighed" id="abc123">foo</div>' third = '<div class="item highlighed" id="abc123">bar</div>' fourth = '<div class="item" id="abc123">bar</div>' self.changer.setInitialXML('abc123', first) self.checkChange('abc...
self.changer.setInitialXML('outer', first)
self.changer.setInitialHTML('outer', first)
def testHotspotChange(self): first = self.makeHotspotArea('booya', 'booyaka') second = self.makeHotspotArea('booya', 'booyaka booyaka') self.changer.setInitialXML('outer', first) self.checkChange(second, 'inner')
self.changer.setInitialXML('outer', first)
self.changer.setInitialHTML('outer', first)
def testOutsideHotspotChange(self): first = self.makeHotspotArea('foo', 'booyaka') second = self.makeHotspotArea('bar', 'booyaka booyaka') self.changer.setInitialXML('outer', first) self.checkChange(second, 'outer')
AttachInteger (widgetTree['entry-padding'], prefs.PRESERVE_X_GB_FREE)
AttachFloat(widgetTree['entry-padding'], prefs.PRESERVE_X_GB_FREE)
def on_preference(self, event = None): # get our add channel dialog movie_dir = config.get(prefs.MOVIES_DIRECTORY) widgetTree = MainFrame.WidgetTree(resource.path('democracy.glade'), 'dialog-preferences', 'democracyplayer') dialog = widgetTree['dialog-preferences'] mainWindow = self.mainFrame.widgetTree['main-window'] ...
def __init__(self, url, ufeed, title = None, visible = True, calcItems=True):
def __init__(self, url, ufeed, title = None, visible = True):
def __init__(self, url, ufeed, title = None, visible = True, calcItems=True): self.available = 0 self.unwatched = 0 self.url = url self.ufeed = ufeed if calcItems: self.calc_item_list() if title == None: self.title = url else: self.title = title self.created = datetime.now() self.autoDownloadable = ufeed.initiallyAutoD...
if calcItems: self.calc_item_list()
self.calc_item_list()
def __init__(self, url, ufeed, title = None, visible = True, calcItems=True): self.available = 0 self.unwatched = 0 self.url = url self.ufeed = ufeed if calcItems: self.calc_item_list() if title == None: self.title = url else: self.title = title self.created = datetime.now() self.autoDownloadable = ufeed.initiallyAutoD...
self.actualFeed = FeedImpl(url,self, calcItems=False)
self.actualFeed = FeedImpl(url,self)
def __init__(self,url, initiallyAutoDownloadable=True): self.origURL = url self.errorState = False self.initiallyAutoDownloadable = initiallyAutoDownloadable self.loading = True self.actualFeed = FeedImpl(url,self, calcItems=False) self.download = None self.iconCache = IconCache(self, is_vital = True) self.informOnErro...
DDBObject.__init__(self) startActualFeed = self.actualFeed
def __init__(self,url, initiallyAutoDownloadable=True): self.origURL = url self.errorState = False self.initiallyAutoDownloadable = initiallyAutoDownloadable self.loading = True self.actualFeed = FeedImpl(url,self, calcItems=False) self.download = None self.iconCache = IconCache(self, is_vital = True) self.informOnErro...
if self.actualFeed == startActualFeed: self.actualFeed.calc_item_list()
self.dd.addAfterCursor(self)
def __init__(self,url, initiallyAutoDownloadable=True): self.origURL = url self.errorState = False self.initiallyAutoDownloadable = initiallyAutoDownloadable self.loading = True self.actualFeed = FeedImpl(url,self, calcItems=False) self.download = None self.iconCache = IconCache(self, is_vital = True) self.informOnErro...
sortedItems = list(self.items) sortedItems.sort(lambda x, y: cmp(x.getPubDateParsed(), y.getPubDateParsed())) self.startfrom = sortedItems[-1].getPubDateParsed()
if len(self.items) > 0: sortedItems = list(self.items) sortedItems.sort(lambda x, y: cmp(x.getPubDateParsed(), y.getPubDateParsed())) self.startfrom = sortedItems[-1].getPubDateParsed()
def updateUsingXML(self, xml): """Update the feed using XML passed in""" d = feedparser.parse(xml) self.parsed = d
print "This is work in process"
def irclogin(nickname, username='pbot', password = SVRPASSWORD, realname='Nigels PBot', hostname='Nigel', servername='Freenode'): #We need to see if we need to send a password, so here we go if password != "": #Pass Required so lets send it! irccommand("PASS " + password) #IRC "USER" RFC says: "USER Username Hostname ...
if '\n' not in buffer: continue msg, buffer = buffer.split('\n', 1)
while '\n' in buffer: msg, buffer = buffer.split('\n', 1)
#def isusingprefix(INDATA,COMMAND):
print msg, if msg[0] == "PING": irccommand("PONG %s" % msg[1]) if msg[1] == 'PRIVMSG' and msg[2] == ircbpconfig.NICKNAME: print "We got a PM!!!" nick_name = msg[0][:string.find(msg[0],"!")] print "Sent by " + nick_name message = ' '.join(msg[3:]) print "The message was: " + message if msg[1] == 'PRIVMSG' and msg[2][0...
print msg msg = msg.split() if msg[0] == "PING": irccommand("PONG %s" % msg[1]) if msg[1] == 'PRIVMSG' and msg[2] == ircbpconfig.NICKNAME: print "We got a PM!!!" nick_name = msg[0][:string.find(msg[0],"!")] print "Sent by " + nick_name message = ' '.join(msg[3:]) print "The message was: " + message if msg[1] == 'PRIVM...
#def isusingprefix(INDATA,COMMAND):
irccommand("KICK " + msg[4] + " " + msg[5] + " :You've being a BAD boy!") irccommand("PRIVMSG " + CHANNEL + " :" + nick_name + ", your dirty work is done!")
irccommand("PRIVMSG " + CHANNEL + " :SYNTAX IS: !kick \x02<
#def isusingprefix(INDATA,COMMAND):
irccommand("PRIVMSG " + CHANNEL + " :SYNTAX IS: !kick \x02<nick>\x02 [Optional Message]")
irccommand("PRIVMSG " + CHANNEL + " :" + nick_name + ", I'm not in that channel!")
#def isusingprefix(INDATA,COMMAND):
irccommand("PRIVMSG " + CHANNEL + " :" + nick_name + ", I'm not in that channel!") else: irccommand("PRIVMSG " + CHANNEL + " :SYNTAX IS: !kick \x02<nick>\x02 [Optional Message]") else: irccommand("PRIVMSG " + CHANNEL + " :No privledges for this command!") if string.upper(string.lstrip(msg[3], ':')) == string.upper('!...
irccommand("PRIVMSG " + CHANNEL + " :SYNTAX IS: !kick \x02< else: irccommand("PRIVMSG " + CHANNEL + " :No privledges for this command!") if string.upper(string.lstrip(msg[3], ':')) == string.upper('!list'):
#def isusingprefix(INDATA,COMMAND):
if string.upper(string.lstrip(msg[3], ':')) == string.upper('!join'): print "Joining a channel!" if privcheck(HOSTMASK): if len(msg) > 4: if msg[4][0] == " ircbpconfig.addchan(msg[4]) irccommand("JOIN " + msg[4])
if string.upper(string.lstrip(msg[3], ':')) == string.upper('!join'): print "Joining a channel!" if privcheck(HOSTMASK): if len(msg) > 4: if msg[4][0] == " ircbpconfig.addchan(msg[4]) irccommand("JOIN " + msg[4]) else: irccommand("PRIVMSG " + CHANNEL + " :" + msg[4] + " is not a channel")
#def isusingprefix(INDATA,COMMAND):
irccommand("PRIVMSG " + CHANNEL + " :" + msg[4] + " is not a channel") else: irccommand("PRIVMSG " + CHANNEL + " :Syntax error, correct syntax is: !join \x02<channel>\x02") else: irccommand("PRIVMSG " + CHANNEL + " :No privledges for this command!") if string.upper(string.lstrip(msg[3], ':')) == string.upper('!cycl...
irccommand("PRIVMSG " + CHANNEL + " :Syntax error, correct syntax is: !join \x02<channel>\x02") else: irccommand("PRIVMSG " + CHANNEL + " :No privledges for this command!") if string.upper(string.lstrip(msg[3], ':')) == string.upper('!cycle'): if privcheck(HOSTMASK): print "Cycling!" irccommand("PRIVMSG " + CHANNEL ...
#def isusingprefix(INDATA,COMMAND):
irccommand("PRIVMSG " + CHANNEL + " :" + msg[4] + " is not a channel") else: irccommand("PRIVMSG " + CHANNEL + " :buh-bye now! =)") irccommand("PART " + CHANNEL + " :Part from %s" % nick_name) remchan(CHANNEL) else: irccommand("PRIVMSG " + CHANNEL + " :No privledges for this command!") if string.upper(string.lstrip...
irccommand("PRIVMSG " + CHANNEL + " :buh-bye now! =)") irccommand("PART " + CHANNEL + " :Part from %s" % nick_name) remchan(CHANNEL) else: irccommand("PRIVMSG " + CHANNEL + " :No privledges for this command!") if string.upper(string.lstrip(msg[3], ':')) == string.upper('!quit'): if privcheck(HOSTMASK): print "It's ...
#def isusingprefix(INDATA,COMMAND):
if msg[1] == 'PRIVMSG' and msg[2] == NICKNAME:
if msg[1] == 'PRIVMSG' and msg[2] == ircbpconfig.NICKNAME:
#def isusingprefix(INDATA,COMMAND):