Example #1
0
    def addNew(self):

        # Updated date in same format that database updated_date.
        updated_date = datetime.strptime(self.updated_date, "%Y-%m-%d")

        # The root version (0.5.1 -> 0.5)
        version = ".".join(self.sg_ver.split(".")[0:-1])

        # Create the path.
        ftpPath = releasePathFTP + version + "/sources/shogun-" + self.sg_ver
        httpPath = releasePathHTTP + version + "/sources/shogun-" + self.sg_ver
        ftpDataPath = releasePathDataFTP + "shogun-data-" + self.data_ver
        httpDataPath = releasePathDataHTTP + "shogun-data-" + self.data_ver

        try:
            record = New.objects.get(updated_date=updated_date)
            record.stored_date = datetime.now()
            record.sg_ver = self.sg_ver
            record.sg_bver = self.sg_bver
            record.libshogun_ver = self.libshogun_ver
            record.data_ver = self.data_ver
            record.param_ver = self.param_ver
            record.libshogunui = self.libshogunui
            record.author = self.author
            record.mail = self.mail
            record.content = str(self.content)
            record.ftp_data = ftpDataPath + ".tar.bz2"
            record.http_data = httpDataPath + ".tar.bz2"
            record.ftp_source_code = ftpPath + ".tar.bz2"
            record.http_source_code = httpPath + ".tar.bz2"
            record.ftp_md5sum = ftpPath + ".md5sum"
            record.http_md5sum = httpPath + ".md5sum"
            record.ftp_PGP_signature = ftpPath + ".tar.bz2.asc"
            record.http_PGP_signature = httpPath + ".tar.bz2.asc"

            # Add release download links.
            record.save()

            if self.DEBUG:
                print("New modified!")

        except New.DoesNotExist:
            record = New(stored_date=datetime.now(), \
                         sg_ver=self.sg_ver, \
                         sg_bver=self.sg_bver, \
                         libshogun_ver=self.libshogun_ver, \
                         data_ver=self.data_ver, \
                         param_ver=self.param_ver, \
                         libshogunui=self.libshogunui,
                         updated_date=updated_date, \
                         author=self.author, \
                         mail=self.mail, \
                         content=self.content, \
                         ftp_data=ftpDataPath + ".tar.bz2", \
                         http_data=httpDataPath + ".tar.bz2", \
                         ftp_source_code=ftpPath + ".tar.bz2", \
                         http_source_code=httpPath + ".tar.bz2", \
                         ftp_md5sum=ftpPath + ".md5sum", \
                         http_md5sum=httpPath + ".md5sum", \
                         ftp_PGP_signature=ftpPath + ".tar.bz2.asc", \
                         http_PGP_signature=httpPath + ".tar.bz2.asc")
            record.save()

            if self.DEBUG:
                print("New added!")
Example #2
0
    def addNew(self):

        # Updated date in same format that database updated_date.
        updated_date = datetime.strptime(self.updated_date, "%Y-%m-%d")

        # The root version (0.5.1 -> 0.5)
        version = ".".join(self.sg_ver.split(".")[0:-1])

        # Create the path.
        ftpPath = releasePathFTP + version + "/sources/shogun-" + self.sg_ver
        httpPath = releasePathHTTP + version + "/sources/shogun-" + self.sg_ver
        ftpDataPath = releasePathDataFTP + "shogun-data-" + self.data_ver
        httpDataPath = releasePathDataHTTP + "shogun-data-" + self.data_ver

        try:
            record = New.objects.get(updated_date=updated_date)
            record.stored_date = datetime.now()
            record.sg_ver = self.sg_ver
            record.sg_bver = self.sg_bver
            record.libshogun_ver = self.libshogun_ver
            record.data_ver = self.data_ver
            record.param_ver = self.param_ver
            record.libshogunui = self.libshogunui
            record.author = self.author
            record.mail = self.mail
            record.content = str(self.content)
            record.ftp_data=ftpDataPath + ".tar.bz2"
            record.http_data=httpDataPath + ".tar.bz2"
            record.ftp_source_code=ftpPath + ".tar.bz2"
            record.http_source_code=httpPath + ".tar.bz2"
            record.ftp_md5sum=ftpPath + ".md5sum"
            record.http_md5sum=httpPath + ".md5sum"
            record.ftp_PGP_signature=ftpPath + ".tar.bz2.gpg"
            record.http_PGP_signature=httpPath + ".tar.bz2.gpg"

            # Add release download links.
            record.save()

            if self.DEBUG:
                print ("New modified!")


        except New.DoesNotExist:
            record = New(stored_date=datetime.now(), \
                         sg_ver=self.sg_ver, \
                         sg_bver=self.sg_bver, \
                         libshogun_ver=self.libshogun_ver, \
                         data_ver=self.data_ver, \
                         param_ver=self.param_ver, \
                         libshogunui=self.libshogunui,
                         updated_date=updated_date, \
                         author=self.author, \
                         mail=self.mail, \
                         content=self.content, \
                         ftp_data=ftpDataPath + ".tar.bz2", \
                         http_data=httpDataPath + ".tar.bz2", \
                         ftp_source_code=ftpPath + ".tar.bz2", \
                         http_source_code=httpPath + ".tar.bz2", \
                         ftp_md5sum=ftpPath + ".md5sum", \
                         http_md5sum=httpPath + ".md5sum", \
                         ftp_PGP_signature=ftpPath + ".tar.bz2.gpg", \
                         http_PGP_signature=httpPath + ".tar.bz2.gpg")
            record.save()


            if self.DEBUG:
                print ("New added!")
Example #3
0
    def parseFile(self, path):

        if self.DEBUG:
            # Print information.
            print("Parsing file : " + path)

        # News structure.
        sg_ver = '0.0.0'  # Shogun version.
        sg_bver = '0.0.0'  #
        libshogun_ver = '0.0'  # Libshogun version.
        data_ver = '0.0'  # Data version.
        param_ver = '0.0'  # Parameter version
        updated_date = '00.00.0000'  # Date
        content = ''  # Content

        # Tags.
        stop_tag_ul = ''
        stop_tag_li = ''
        news_start = False

        for l in file(path).readlines():
            if news_start:
                if l == '\n':
                    break
                s = l.lstrip().rstrip()
                if s.startswith('* This'):
                    content += '' + s.lstrip('* ') + '\n<ul>\n'
                elif s.startswith('* '):
                    content += stop_tag_li + stop_tag_ul
                    content += '<li><h5>' + s.lstrip('* ') + '</h5>\n<ul>'
                    stop_tag_li = ''
                    stop_tag_ul = '</ul></li>\n'
                elif s.startswith('-'):
                    content += stop_tag_li
                    content += '<li>' + s.lstrip('- ')
                    stop_tag_li = '</li>\n'
                else:
                    content += ' ' + s.lstrip()
            else:
                if l.startswith("20"):
                    updated_date = '%s.%s.%s' % (l[8:10], l[5:7], l[0:4])
                elif l.find("* SHOGUN") != -1:
                    i = l.find("* SHOGUN")
                    v = l[i + 2:].split()
                    sg_ver = v[3]
                    sg_bver = '.'.join(sg_ver.split('.')[0:2])
                    libshogun_ver = v[5][:-1]
                    data_ver = v[7][:-1]
                    param_ver = v[9][:-1]
                    news_start = True

        content += stop_tag_li + stop_tag_ul + '</ul>\n' + '\n'

        # Save the new in DB.
        current_date = datetime.strftime(datetime.now(), '%d.%m.%Y')

        try:
            record = New.objects.get(updated_date=updated_date)
            record.stored_date = current_date
            record.sg_ver = sg_ver
            record.sg_bver = sg_bver
            record.libshogun_ver = libshogun_ver
            record.data_ver = data_ver
            record.param_ver = param_ver
            record.updated_date = updated_date
            record.content = content
            record.save()

        except New.DoesNotExist:
            record = New(stored_date=current_date,
                         sg_ver=sg_ver,
                         sg_bver=sg_bver,
                         libshogun_ver=libshogun_ver,
                         data_ver=data_ver,
                         param_ver=param_ver,
                         updated_date=updated_date,
                         content=content)
            record.save()

            if self.DEBUG:
                print("adding ...")
                print("date:" + updated_date)
                print("libshogun_ver:" + libshogun_ver)
                print("data_ver:" + data_ver)
                print("param_ver:" + param_ver)
                print("sg_ver:" + sg_ver)
                print("sg_bver:" + sg_bver)
                print("")
Example #4
0
    def endElement (self, name):
        if name == 'new':
            self.in_New = False

            # New structure.
            # <new>
            #   <sg_ver> 0.0.0 </sg_ver>
            #   <sg_bver> 0.0.0 </sg_bver>
            #   <libshogun_ver> 0.0 </libshogun_ver>
            #   <data_ver> 0.0 </data_ver>
            #   <param_ver> 0.0 </param_ver>
            #   <updated_date> 00.00.0000 </updated_date>
            #   <content>
            #       * This release contains several enhancements, cleanups and bugfixes:
            #       * Features:
            #           - Implement set_linear_classifier for static interfaces.
            #           - Implement Polynomial DotFeatures.
            #       * Bugfixes:
            #           - Fix one class MKL for static interfaces.
            #   </content>
            # <new>

            #Give format to the content.
            self.content = self.content.encode('utf8','replace')

            #Add html code.
            self.addHTMLContent()

            #If now value in new should be 0.0.
            if self.sg_ver == '':
                self.sg_ver = '0.0.0'
            if self.sg_bver == '':
                self.sg_bver = '0.0.0'
            if self.libshogun_ver == '':
                self.libshogun_ver = '0.0'
            if self.data_ver == '':
                self.data_ver = '0.0'
            if self.param_ver == '':
                self.param_ver = '0.0'
            if self.libshogunui == '':
                self.libshogunui = '0.0'
      
            #Save in DB.
            updated_date = datetime.strptime(self.updated_date, "%Y-%m-%d")

            try:
                record = New.objects.get(updated_date=updated_date)
                record.stored_date = datetime.now()
                record.sg_ver = self.sg_ver
                record.sg_bver = self.sg_bver
                record.libshogun_ver = self.libshogun_ver
                record.data_ver = self.data_ver
                record.param_ver = self.param_ver
                record.libshogunui = self.libshogunui
                record.updated_date = updated_date
                record.author = self.author
                record.mail = self.mail
                record.content = str(self.content)
                record.save()

                if self.DEBUG:
                    print ("New modified!")


            except New.DoesNotExist:
                record = New(stored_date=datetime.now(), \
                            sg_ver=self.sg_ver, \
                            sg_bver=self.sg_bver, \
                            libshogun_ver=self.libshogun_ver, \
                            data_ver=self.data_ver, \
                            param_ver=self.param_ver, \
                            libshogunui=self.libshogunui,
                            updated_date=updated_date, \
                            author=self.author, \
                            mail=self.mail, \
                            content=self.content)
                record.save()


                if self.DEBUG:
                    print ("New added!")

            #Reset the values.
            self.sg_ver = ""                # Shogun version.
            self.sg_bver = ""               # Shogun bversion.
            self.libshogun_ver = ""         # Libshogun version.
            self.data_ver = ""              # Data version.
            self.param_ver = ""             # Param version.
            self.libshogunui = ""           # Libshogunui version.
            self.updated_date = ""          # Updated date. 
            self.content = ""               # Content.
            self.mail = ""
            self.author = ""

        elif self.in_New:
            if name == 'sg_ver':
                self.in_sg_ver = False  
            elif name == 'sg_bver': 
                self.in_sg_bver = False
            elif name == "libshogun_ver":
                self.in_libshogun_ver = False
            elif name == "data_ver":
                self.in_data_ver = False
            elif name == "param_ver":
                self.in_param_ver = False
            elif name == "updated_date":
                self.in_updated_date = False
            elif name == "author":
                self.in_author = False
            elif name == "mail":
                self.in_mail = False
            elif name == "libshogunui":
                self.in_libshogunui = False
            elif name == "content":
                self.in_content = False         
Example #5
0
	def parseFile(self, path):

		if self.DEBUG:
			# Print information.
			print("Parsing file : " + path)

		# News structure.
		sg_ver='0.0.0'            # Shogun version.
		sg_bver='0.0.0'           #
		libshogun_ver='0.0'       # Libshogun version.
		data_ver='0.0'            # Data version.
		param_ver='0.0'           # Parameter version
		updated_date='00.00.0000' # Date
		content=''                # Content

		# Tags.
		stop_tag_ul=''
		stop_tag_li=''
		news_start=False

		for l in file(path).readlines():
			if news_start:
				if l=='\n':
					break
				s=l.lstrip().rstrip()
				if s.startswith('* This'):
					content+=''+s.lstrip('* ')+'\n<ul>\n'
				elif s.startswith('* '):
					content+=stop_tag_li + stop_tag_ul
					content+='<li><h5>'+s.lstrip('* ')+'</h5>\n<ul>'
					stop_tag_li=''
					stop_tag_ul='</ul></li>\n'
				elif s.startswith('-'):
					content+=stop_tag_li
					content+='<li>'+s.lstrip('- ')
					stop_tag_li='</li>\n'
				else:
					content+=' ' +s.lstrip()
			else:
				if l.startswith("20"):
					updated_date='%s.%s.%s' % (l[8:10],l[5:7],l[0:4])
				elif l.find("* SHOGUN")!=-1:
					i=l.find("* SHOGUN")
					v=l[i+2:].split()
					sg_ver=v[3]
					sg_bver='.'.join(sg_ver.split('.')[0:2])
					libshogun_ver=v[5][:-1]
					data_ver=v[7][:-1]
					param_ver=v[9][:-1]
					news_start=True

		content+=stop_tag_li + stop_tag_ul + '</ul>\n' + '\n'

		# Save the new in DB.
		current_date = datetime.strftime(datetime.now(),'%d.%m.%Y');

		try:
			record = New.objects.get(updated_date=updated_date)
			record.stored_date = current_date
			record.sg_ver = sg_ver
			record.sg_bver = sg_bver
			record.libshogun_ver = libshogun_ver
			record.data_ver = data_ver
			record.param_ver = param_ver
			record.updated_date = updated_date
			record.content = content
			record.save()

		except New.DoesNotExist:
			record = New(stored_date=current_date, sg_ver=sg_ver, sg_bver=sg_bver, libshogun_ver=libshogun_ver, data_ver=data_ver, param_ver=param_ver, updated_date=updated_date, content=content)
			record.save()

			if self.DEBUG:
				print ("adding ...")
				print ("date:" + updated_date)
				print ("libshogun_ver:" + libshogun_ver) 
				print ("data_ver:" + data_ver)
				print ("param_ver:" + param_ver)
				print ("sg_ver:" + sg_ver)
				print ("sg_bver:" + sg_bver)
				print ("")