Пример #1
0
	def GET(self):
		i = web.input(uid=None, sha=None, full=0)
		if i.uid == None:
			return render.base(view.listing())
		else:
			results = config.DB.select('items', dict(n=str(i.uid)), where="id=$n")
			rows = results.list()
			print ("Row count: " + str(len(rows)))
			if len(rows) > 0:
				row = rows[0]

				results = config.DB.query("SELECT * FROM scores WHERE id='"  + str(i.uid) + "'")
				if i.full == 0:
					for r in results.list():
						print ("Updating: " + r['commitsha'])
						outdir = os.getcwd() + '/static/' + r['commitsha'] + '/'
						score, pagecount, all_scores = document_compare.compare_pdf_using_images(row['id'], outdir)
						config.DB.update('scores', where='id="' + str(i.uid) + '" AND commitsha="' + str(r['commitsha']) + '"', olscore=score[0],ollscore=score[1], olwscore=score[2], details=str(all_scores).strip('[]'))
				else:
					shutil.copy(os.getcwd() + '/static/originals/' + str(i.uid) + row['extension'], '/tmp/')
					
					if results[0].total_version == len(lo):
						config.DB.delete('scores', where='id = "' + str(i.uid) + '"')
						a = threading.Thread(target=worker, args=('/tmp/' + str(i.uid) + row['extension'], False, ))
						a.start()
					else:
						a = threading.Thread(target=worker, args=('/tmp/' + str(i.uid) + row['extension'], True, ))
						a.start()
			
			return render.base(view.listing())
Пример #2
0
    def GET(self):
        i = web.input(uid=None, sha=None, full=0)
        if i.uid == None:
            return render.base(view.listing())
        else:
            results = config.DB.select('items',
                                       dict(n=str(i.uid)),
                                       where="id=$n")
            rows = results.list()
            print("Row count: " + str(len(rows)))
            if len(rows) > 0:
                row = rows[0]

                results = config.DB.query("SELECT * FROM scores WHERE id='" +
                                          str(i.uid) + "'")
                if i.full == 0:
                    for r in results.list():
                        print("Updating: " + r['commitsha'])
                        outdir = os.getcwd(
                        ) + '/static/' + r['commitsha'] + '/'
                        score, pagecount, all_scores = document_compare.compare_pdf_using_images(
                            row['id'], outdir)
                        config.DB.update('scores',
                                         where='id="' + str(i.uid) +
                                         '" AND commitsha="' +
                                         str(r['commitsha']) + '"',
                                         olscore=score[0],
                                         ollscore=score[1],
                                         olwscore=score[2],
                                         details=str(all_scores).strip('[]'))
                else:
                    shutil.copy(
                        os.getcwd() + '/static/originals/' + str(i.uid) +
                        row['extension'], '/tmp/')

                    if results[0].total_version == len(lo):
                        config.DB.delete('scores',
                                         where='id = "' + str(i.uid) + '"')
                        a = threading.Thread(target=worker,
                                             args=(
                                                 '/tmp/' + str(i.uid) +
                                                 row['extension'],
                                                 False,
                                             ))
                        a.start()
                    else:
                        a = threading.Thread(target=worker,
                                             args=(
                                                 '/tmp/' + str(i.uid) +
                                                 row['extension'],
                                                 True,
                                             ))
                        a.start()

            return render.base(view.listing())
Пример #3
0
	def GET(self):
		i = web.input(uid=None, sha=None)
		if i.uid == None or i.sha == None:
			return render.base(view.listing())
		else:
			results = config.DB.query("SELECT * FROM items JOIN scores WHERE scores.id = items.id AND scores.id = '" + str(i.uid) + "' AND scores.commitsha='" + i.sha + "'")
			rows = results.list()
			print ("Row count: " + str(len(rows)))
			if len(rows) == 0:
				return render.base(view.listing())
			row = rows[0]
			return render.details(row)
Пример #4
0
 def GET(self):
     i = web.input(uid=None, sha=None)
     if i.uid == None or i.sha == None:
         return render.base(view.listing())
     else:
         results = config.DB.query(
             "SELECT * FROM items JOIN scores WHERE scores.id = items.id AND scores.id = '"
             + str(i.uid) + "' AND scores.commitsha='" + i.sha + "'")
         rows = results.list()
         print("Row count: " + str(len(rows)))
         if len(rows) == 0:
             return render.base(view.listing())
         row = rows[0]
         return render.details(row)
Пример #5
0
    def POST(self):
        if not logged():
            raise web.seeother("/login")
        input = web.input()
        if input.Submit == "tethering":
            if input["wifi"] == "ON":
                # Only validating the form if Wlan tethering is turned ON
                input.valid = True

                try:
                    len_passphrase = len(input["passphrase"])
                except:
                    len_passphrase = 0;

                try:
                    len_ssid = len(input["ssid"])
                except:
                    len_ssid = 0;

                if len_ssid == 0:
                    tethering.form.note = "Wlan SSID missing"
                    input.valid = False
                elif len_passphrase < 8 or len_passphrase > 64:
                    tethering.form.note = "Passphrase must be between 8 and 64 characters"
                    input.valid = False

                if not input.valid:
                    return render.base(view.listing(),
                                       title, logout, help)
                else:
                    tethering.form.note = ""
                    tethering.update(input)
            else:
                tethering.form.note = ""
                tethering.update(input)

        elif input.Submit == "technology":
            if not technology.form.validates():
                return render.base(view.listing(),
                                   title, logout, help)
            else:
                technology.update(input)

        elif input.Submit == "rescan":
            rescan.update(input)
            # allow some time for the scan to return some results
            time.sleep(6)

        return view.main_screen()
Пример #6
0
    def POST(self):
        form = web.input(doc={})

        basename = form['doc'].filename.replace(' ', '_')
        tempfile = '/tmp/' + basename
        with open(tempfile, 'wb') as saved:
            shutil.copyfileobj(form['doc'].file, saved)

        uid = document_compare.compute_uid(tempfile)

        # Remove old entries
        config.DB.delete('scores', where='id = "' + uid + '"')
        config.DB.delete('items', where='id = "' + uid + '"')

        b, ext = os.path.splitext(form['doc'].filename)
        # Insert
        config.DB.insert('items', id=uid, name=b, pagecount=-1, extension=ext)

        # Start bg thread
        a = threading.Thread(target=worker, args=(
            tempfile,
            False,
        ))
        a.start()

        return render.base(view.listing())
Пример #7
0
    def POST(self):
        input = web.input()
        if input.Submit == "tethering":
            if input["wifi"] == "ON":
                # Only validating the form if Wlan tethering is turned ON
                input.valid = True

                try:
                    len_passphrase = len(input["passphrase"])
                except:
                    len_passphrase = 0

                try:
                    len_ssid = len(input["ssid"])
                except:
                    len_ssid = 0

                if len_ssid == 0:
                    tethering.form.note = "Wlan SSID missing"
                    input.valid = False
                elif len_passphrase < 8 or len_passphrase > 64:
                    tethering.form.note = "Passphrase must be between 8 and 64 characters"
                    input.valid = False

                if not input.valid:
                    return render.base(view.listing(), title, help)
                else:
                    tethering.form.note = ""
                    tethering.update(input)
            else:
                tethering.form.note = ""
                tethering.update(input)

        elif input.Submit == "technology":
            if not technology.form.validates():
                return render.base(view.listing(), title, help)
            else:
                technology.update(input)

        elif input.Submit == "rescan":
            rescan.update(input)
            # allow some time for the scan to return some results
            time.sleep(6)

        return view.main_screen()
Пример #8
0
 def GET(self):
     form = web.input()
     url = form.url
     o = urlparse(url)
     if o.netloc == 'www.leboncoin.fr':
         web.header('Content-Type', 'text/xml')
         # return render.response(code)
         return view.listing(url)
     else:
         return ''
Пример #9
0
 def GET(self,page=1):
     page = int(page)
     limit=config.perpage
     offset = (page -1)*limit
     counting = db.counting()
     pages = counting / limit
     if counting % limit > 0:
         pages += 1
     if page > pages:
         raise web.seeother('/')
     else:
         return render.base(view.listing(offset=offset,limit=limit), 
                 pages=pages, curpage=page)
Пример #10
0
 def GET(self):
     fill_seedwords()
     category = None
     category_list = {}
     user_data = web.input()
     if user_data.has_key('category'):
       category = user_data.get('category')
       k = {}
       k['what'] = 'rank, name'
       k['where'] = 'category = "%s"' % category
       entities = db.listing(**k)
       category_list['category'] = category
       category_list['words'] = seedwords[category]
     return render.base(view.listing(), category_list = category_list)
Пример #11
0
 def GET(self):
     entity = None
     entity_list = {}
     user_data = web.input()
     if user_data.has_key('entity'):
       entity = user_data.get('entity')
       k = {}
       k['what'] = 'entity2'
       k['where'] = 'entity1 = "%s"' % entity
       k['order'] = 'rank desc'
       k['limit'] = 10
       entities = db.entity_listing(**k)
       entity_list['entity'] = entity
       entity_list['entities'] = entities
     return render.base(view.listing(), entity_list = entity_list)
Пример #12
0
	def POST(self):
		form = web.input(doc={})

		basename = form['doc'].filename.replace(' ', '_')
		tempfile = '/tmp/' + basename
		with open(tempfile, 'wb') as saved:
			shutil.copyfileobj(form['doc'].file, saved)

		uid = document_compare.compute_uid (tempfile)

		# Remove old entries
		config.DB.delete('scores', where='id = "' + uid + '"')
		config.DB.delete('items', where='id = "' + uid + '"')

		b, ext = os.path.splitext(form['doc'].filename)
		# Insert 
		config.DB.insert('items', id=uid, name=b, pagecount=-1, extension=ext)

		# Start bg thread		
		a = threading.Thread(target=worker, args=(tempfile, False, ))
		a.start()

		return render.base(view.listing())
Пример #13
0
 def GET(self):
     return render.base(view.listing(), title='域名列表')
Пример #14
0
 def GET(self):
     print render.base(view.listing())
Пример #15
0
 def index(self):
     tmpl = env.get_template('index.html')
     return tmpl.render(listing=view.listing(), results=view.getresultbyname('web'), status=host+":"+str(port))
Пример #16
0
 def _get_listing(self, _ = None):
     return view.listing()
Пример #17
0
 def _get_listing(self, _=None):
     return view.listing()
Пример #18
0
 def GET(self):
     return render.base(view.listing())
Пример #19
0
	def GET(self):
		return render.base(view.listing())
Пример #20
0
 def index(self):
     tmpl = env.get_template('index.html')
     return tmpl.render(listing=view.listing(),
                        results=view.getresultbyname('web'),
                        status=host + ":" + str(port))