Exemple #1
0
 def _fake_import(fn,name):
     from importlib import machinery
     m = machinery.SourceFileLoader(name,fn)
     try:
         sys.modules[name] = m.load_module(name)
     except FileNotFoundError:
         raise ImportError('file %s not found' % ascii(fn))
 def _fake_import(fn,name):
     from importlib import machinery
     m = machinery.SourceFileLoader(name,fn)
     try:
         sys.modules[name] = m.load_module(name)
     except FileNotFoundError:
         raise ImportError('file %s not found' % ascii(fn))
Exemple #3
0
 def sendmail(self, request_id, logname, alias, authcode):
     """ int SendMail(request_id, logname, alias, authcode)
     """
     if __debug__:
         self._log.debug("Started")
     dbconn = self._dbpool.connect()
     try:
         stri = "UPDATE registrations SET status='progress' where id=%d" % request_id
         dbconn.exec_simple_sql(stri)
         # COMMIT отложен до отправки почты.
     except SQLexecError as e:
         if __debug__:
             self._log.debug(
                 "errRegStatusToProgress: eSQLexec(%s) for '%s'" % (str(e)),
                 stri)
         self._dbpool.disconnect(dbconn)
         return self.get_errno("errRegStatusToProgress")
     # Сюда добавить реальный код отправки запроса авторизации по почте
     # authURI = web_domain + registration_path + "?a=" + authcode
     # try:
     # except ___ as e:
     # Если почту отправить не удастся, то статус не изменится, чтобы потом разобраться с причинами
     #     self.dbconn.rollback()
     #     return -2 # Cannot send email
     self._log.info("Authcode %s is sent to %s for %s." %
                    (authcode, logname, ascii(alias)))
     dbconn.commit()
     self._dbpool.disconnect(dbconn)
     return 0
Exemple #4
0
    def _formatRoot(self, obj):
        """
        Convert an object from C{self._roots} to a string suitable for
        inclusion in a render-traceback (like a normal Python traceback, but
        can include "frame" source locations which are not in Python source
        files).

        @param obj: Any object which can be a render step I{root}.
            Typically, L{Tag}s, strings, and other simple Python types.

        @return: A string representation of C{obj}.
        @rtype: L{str}
        """
        # There's a circular dependency between this class and 'Tag', although
        # only for an isinstance() check.
        from twisted.web.template import Tag

        if isinstance(obj, (bytes, str)):
            # It's somewhat unlikely that there will ever be a str in the roots
            # list.  However, something like a MemoryError during a str.replace
            # call (eg, replacing " with ") could possibly cause this.
            # Likewise, UTF-8 encoding a unicode string to a byte string might
            # fail like this.
            if len(obj) > 40:
                if isinstance(obj, str):
                    ellipsis = "<...>"
                else:
                    ellipsis = b"<...>"
                return ascii(obj[:20] + ellipsis + obj[-20:])
            else:
                return ascii(obj)
        elif isinstance(obj, Tag):
            if obj.filename is None:
                return "Tag <" + obj.tagName + ">"
            else:
                return 'File "%s", line %d, column %d, in "%s"' % (
                    obj.filename,
                    obj.lineNumber,
                    obj.columnNumber,
                    obj.tagName,
                )
        else:
            return ascii(obj)
Exemple #5
0
    def job(self, link, newsContentClassName, imageClassName, section):
        db = connection.MySQLConnection(user='******',
                                        password='******',
                                        host='127.0.0.1',
                                        database='NewsData',
                                        charset='utf8')

        # prepare a cursor object using cursor() method
        cursor = db.cursor()

        print("Scheduler is running.......")
        feed = feedparser.parse(link)
        for entry in feed['items']:

            length = len(entry['link'].split('/'))

            sql1 = "SELECT * FROM NewsOrder WHERE newsId >= '%s' and newsSite= '%s'" % (
                entry['link'].split('/')[length - 1], section)
            cursor.execute(sql1)
            result = cursor.fetchall()
            if len(result) == 0:
                length = len(entry['link'].split('/'))
                # converting title into a url
                title = entry['title'].replace(" ", "")
                asci = ascii(title)
                asci = asci[1:].replace("'", "")
                urlTitle = asci.replace("\\", "%")
                url = entry['link'] + '/' + urlTitle
                content = urllib2.Request(url)
                res = urllib2.urlopen(content).read()
                try:
                    soup = BeautifulSoup(res, "html.parser")
                except:
                    print "Error"

                imgsrc = soup.find_all(True, attrs={"class": imageClassName})
                if (imgsrc.__len__() != 1):
                    imgsrc = soup.find_all(True,
                                           attrs={
                                               "class": imageClassName,
                                               "alt": entry['title']
                                           })

                patImgSrc = re.compile('src="(.*)".*/>')
                findPatImgSrc = re.findall(patImgSrc, str(imgsrc))
                newsContentRows = soup.find_all(
                    True, attrs={"class": newsContentClassName})
                dao = DAO()
                dao.insertNews(entry['title'], entry['link'],
                               entry['description'], findPatImgSrc[0], 'null',
                               entry['link'].split('/')[length - 1], section)

            else:
                print 'No new news in', section
Exemple #6
0
    def _formatRoot(self, obj):
        """
        Convert an object from C{self._roots} to a string suitable for
        inclusion in a render-traceback (like a normal Python traceback, but
        can include "frame" source locations which are not in Python source
        files).

        @param obj: Any object which can be a render step I{root}.
            Typically, L{Tag}s, strings, and other simple Python types.

        @return: A string representation of C{obj}.
        @rtype: L{str}
        """
        # There's a circular dependency between this class and 'Tag', although
        # only for an isinstance() check.
        from twisted.web.template import Tag

        if isinstance(obj, (bytes, str, unicode)):
            # It's somewhat unlikely that there will ever be a str in the roots
            # list.  However, something like a MemoryError during a str.replace
            # call (eg, replacing " with &quot;) could possibly cause this.
            # Likewise, UTF-8 encoding a unicode string to a byte string might
            # fail like this.
            if len(obj) > 40:
                if isinstance(obj, unicode):
                    ellipsis = u'<...>'
                else:
                    ellipsis = b'<...>'
                return ascii(obj[:20] + ellipsis + obj[-20:])
            else:
                return ascii(obj)
        elif isinstance(obj, Tag):
            if obj.filename is None:
                return 'Tag <' + obj.tagName + '>'
            else:
                return "File \"%s\", line %d, column %d, in \"%s\"" % (
                    obj.filename, obj.lineNumber,
                    obj.columnNumber, obj.tagName)
        else:
            return ascii(obj)
    def job(self, link, newsContentClassName, imageClassName, section):
        db = connection.MySQLConnection(user='******', password='******',
                                        host='127.0.0.1',
                                        database='NewsData',
                                        charset='utf8')

        # prepare a cursor object using cursor() method
        cursor = db.cursor()

        print("Scheduler is running.......")
        feed = feedparser.parse(link)
        for entry in feed['items']:

            length=len(entry['link'].split('/'))

            sql1="SELECT * FROM NewsOrder WHERE newsId >= '%s' and newsSite= '%s'"%(entry['link'].split('/')[length-1],section)
            cursor.execute(sql1)
            result=cursor.fetchall()
            if len(result)==0:
                length = len(entry['link'].split('/'))
                # converting title into a url
                title = entry['title'].replace(" ", "")
                asci = ascii(title)
                asci = asci[1:].replace("'", "")
                urlTitle = asci.replace("\\", "%")
                url = entry['link'] + '/' + urlTitle
                content = urllib2.Request(url)
                res = urllib2.urlopen(content).read()
                try:
                    soup = BeautifulSoup(res, "html.parser")
                except:
                    print "Error"

                imgsrc = soup.find_all(True, attrs={"class": imageClassName })
                if(imgsrc.__len__()!= 1):
                    imgsrc = soup.find_all(True, attrs={"class": imageClassName,"alt":entry['title']})

                patImgSrc = re.compile('src="(.*)".*/>')
                findPatImgSrc = re.findall(patImgSrc, str(imgsrc))
                newsContentRows = soup.find_all(True, attrs={"class": newsContentClassName})
                dao = DAO()
                dao.insertNews(entry['title'], entry['link'], entry['description'], findPatImgSrc[0], 'null',entry['link'].split('/')[length - 1],section)

            else:
                print 'No new news in',section
Exemple #8
0
#time.accept2dyear(x['boop'])
#print time.localtime(tm_year,tm_min,tm_mday,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)
'''
	#print random.NV_MAGICCONST
	time.clock();
	time.time();
	date = time.strftime("%d-%m-%Y %H:%M:%S -0000")
	print date
	date.__contains__(date)
	date.count(super(object)#[-1,1[0,-1]]) #-> date_acceptable?
	#date.join("\p1 && \p2")
	#time.accept2dyear(x['boop'])
	#print time.localtime(tm_year,tm_min,tm_mday,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)	
'''
area = ['A', 'B', 'C']
for i in future_builtins.ascii(1324871239804723984702347923):
    if (area < setattr):
        unicode.capitalize
        delattr.__doc__
        Query.__oracle__
        reduce
        set = setattr(game, 'two', you)
    elif (area > setattr):
        #callable iter(person_with_index = self.class.setattr)
        hex(23478569234789562934856934875)
        i = 234
        #print unichr(i)
        the_instance_of_introduction = traceback
        py = 23
        game = "habe"
        reversed(game)
Exemple #9
0
 def _request_hash(request_id, logname, alias, passwd):
     stri = str(request_id) + ascii(logname) + ascii(alias) + passwd + str(
         datetime.datetime.utcnow())
     return hashlib.md5(stri).hexdigest()