Esempio n. 1
0
    def getRSSFeed(self, url, post_data=None):
        parsed = list(urlparse.urlparse(url))
        parsed[2] = re.sub("/{2,}", "/",
                           parsed[2])  # replace two or more / with one

        if post_data:
            url = url + 'api?' + urllib.urlencode(post_data)

        f = feedparser.parse(url)

        if not f:
            logger.log(u"Error loading " + self.name + " URL: " + url,
                       logger.ERROR)
            return None
        elif 'error' in f.feed:
            logger.log(
                u"Newznab ERROR:[%s] CODE:[%s]" %
                (f.feed['error']['description'], f.feed['error']['code']),
                logger.DEBUG)
            return None
        elif not f.entries:
            logger.log(
                u"No items found on " + self.name + " using URL: " + url,
                logger.WARNING)
            return None

        return f
Esempio n. 2
0
    def getRSSFeed(self, url, post_data=None):
        parsed = list(urlparse.urlparse(url))
        parsed[2] = re.sub("/{2,}", "/", parsed[2])  # replace two or more / with one

        if post_data:
            url = url + 'api?' + urllib.urlencode(post_data)

        f = feedparser.parse(url)

        if not f:
            logger.log(u"Error loading " + self.name + " URL: " + url, logger.ERROR)
            return None

        return f
Esempio n. 3
0
    def getRSSFeed(self, url, post_data=None):
        parsed = list(urlparse.urlparse(url))
        parsed[2] = re.sub("/{2,}", "/",
                           parsed[2])  # replace two or more / with one

        if post_data:
            url = url + 'api?' + urllib.urlencode(post_data)

        f = feedparser.parse(url)

        if not f:
            logger.log(u"Error loading " + self.name + " URL: " + url,
                       logger.ERROR)
            return None

        return f
Esempio n. 4
0
	def importShifts(self):
		from lib.feedparser import feedparser
		
		url = unicode(self.ui.lineEdit_URL.text())

		feed = feedparser.parse(url)

		self.beginTransaction()
		maxDateTime = ignoreBefore = self.ui.dateTimeEdit_ignoreBefore.dateTime()
		for item in feed['items']:
			name = item['title']
			dateTime = item['published'][:-6] #strip the last 6 chars for easier parsing below
			locale = QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates)
			dateTime = locale.toDateTime(dateTime, 'ddd, dd MMM yyyy hh:mm:ss') # Sat, 29 Dec 2018 22:00:00

			if dateTime <= ignoreBefore:
				continue
			
			beginDate = dateTime.date()
			beginTime = dateTime.time()
			
			if dateTime > maxDateTime:
				maxDateTime = dateTime
		
			if not self.createShift(name, beginDate, beginTime):
				self.rollback()
				QtGui.QMessageBox.critical(self, u'Schichterstellung fehlgeschlagen', 
											u'Die Schichten konnten nicht erstellt werden!\nBitte kontaktieren Sie Ihren Datenbank Administrator')
				
		self.commit()
		QtGui.QMessageBox.information(self, u'Schichterstellung erfolgreich', 
										u'Die Schichten wurden erfolgreich import')
		
		try:
			tmp = config.config['connection']
		except KeyError:
			config.config['connection'] = {DBConnection.connName: {}}
		config.config['connection'][DBConnection.connName]['last_shift_import_url'] = url
		config.config.write()
		
		globalConf.setValueI('last_imported_shift_datetime', maxDateTime.toTime_t())
		
		return True
Esempio n. 5
0
    def importShifts(self):
        from lib.feedparser import feedparser

        url = unicode(self.ui.lineEdit_URL.text())

        feed = feedparser.parse(url)

        self.beginTransaction()
        maxDateTime = ignoreBefore = self.ui.dateTimeEdit_ignoreBefore.dateTime()
        for item in feed["items"]:
            name = item["title"]
            dateTime = item["published"][:-6]  # strip the last 6 chars for easier parsing below
            dateTime = QtCore.QDateTime.fromString(dateTime, "ddd, dd MMM yyyy hh:mm:ss")

            if dateTime <= ignoreBefore:
                continue

            beginDate = dateTime.date()
            beginTime = dateTime.time()

            if dateTime > maxDateTime:
                maxDateTime = dateTime

            if not self.createShift(name, beginDate, beginTime):
                self.rollback()
                QtGui.QMessageBox.critical(
                    self,
                    u"Schichterstellung fehlgeschlagen",
                    u"Die Schichten konnten nicht erstellt werden!\nBitte kontaktieren Sie Ihren Datenbank Administrator",
                )

        self.commit()
        QtGui.QMessageBox.information(
            self, u"Schichterstellung erfolgreich", u"Die Schichten wurden erfolgreich import"
        )

        config.config["connection"][DBConnection.connName]["last_shift_import_url"] = url
        config.config.write()

        globalConf.setValueI("last_imported_shift_datetime", maxDateTime.toTime_t())

        return True
Esempio n. 6
0
    def getRSSFeed(self, url, post_data=None):
        parsed = list(urlparse.urlparse(url))
        parsed[2] = re.sub("/{2,}", "/", parsed[2])  # replace two or more / with one

        if post_data:
            url = url + 'api?' + urllib.urlencode(post_data)

        f = feedparser.parse(url)

        if not f:
            logger.log(u"Error loading " + self.name + " URL: " + url, logger.ERROR)
            return None
        elif 'error' in f.feed:
            logger.log(u"Newznab ERROR:[%s] CODE:[%s]" % (f.feed['error']['description'], f.feed['error']['code']), logger.DEBUG)
            return None
        elif not f.entries:
            logger.log(u"No items found on " + self.name + " using URL: " + url, logger.WARNING)
            return None

        return f