Ejemplo n.º 1
0
def home_search():
	"""The search menu"""
	def outy(iny):
		x = db.checkins(iny.id)
		print "NAME           CHECK-INS"
		y = 14 - len(iny.name)
		l = " "*y 
		
		print iny.name, l, iny.checkins
		print "YEAR | MONTH | DAY | TIME"
		for i in x:
			y2 = 6 - len(str(i[1]))
			f = " "*y2
			print str(i[0]),"|",str(i[1])+f+"|",str(i[2]),"|",str(i[3])
	print "====================="
	print "---> SEARCH MENU <---"
	print "====================="
	do = raw_input("Search by [N]ame or [I]D    ")
	if do in ("N", "n"):
		x = raw_input("Search by Full Name:   ")
		z = db.search("name",x)
		try:
			outy(z)
		except AttributeError: #@Error 004
			ui.err("#004")
			time.sleep(1)
			home_search()
	elif do in ("I","i"):
		x = raw_input("Search by ID:   ")
		z = db.search("id",x)
		outy(z)
	raw_input("Press [enter] to go home")
	home()
Ejemplo n.º 2
0
Archivo: main.py Proyecto: grokit/dcore
def main():
    
    args = getArgs()
    print(args)
    
    if args.dir_of_db is None:
        args.dir_of_db = findRepositoryByBackTracking()
        print("Using repository in: %s" % args.dir_of_db)
    
    db_fullpath = os.path.join(args.dir_of_db, DB_SUBFOLDER, DB_FILENAME)
    
    (db_folder, throwaway) = os.path.split(db_fullpath)
    
    if args.build_cache == True or not os.path.isdir(db_folder):
        db.reset(db_folder)
        db.createAndIndex(db_fullpath, args.dir_of_db)
        
        if args.build_cache == True:
            exit(0)
    
    strToSearch = " ".join(args.search_string)
    #strToSearch = args.search_string
    
    if args.search_filename:
        db.searchFilename(db_fullpath, strToSearch, args.regex)
        exit(0)
    
    if args.search_filename_path:
        db.searchFilenamePath(db_fullpath, strToSearch, args.regex)
        exit(0)
        
    db.search(db_fullpath, strToSearch, filterExtStrToArray(args.extension_filter), args.regex)
Ejemplo n.º 3
0
def search(request):
    t0 = time.clock()
    pois = db.search(int(request.GET['num']), float(request.GET['xmin']),
                     float(request.GET['ymin']), float(request.GET['xmax']),
                     float(request.GET['ymax']))
    t1 = time.clock()
    return HttpResponse(str(t1-t0) + ';' + str(pois))
Ejemplo n.º 4
0
 def GET(self):
     i = web.input(id=None, p='1', q=None)
     # Detail Page
     if i.id:
         _id = i.id
         page = None
         try:
             body = view.detail(_id)
         except:
             print
             return render.error()
             # Search results page
     elif i.q:
         qs = i.q.split(' ')
         qs = ['content like \'%' + x + '%\'' for x in qs]
         _filter = ' and '.join(qs)
         arg = '/?q=' + i.q + '&p'
         page = view.pagecontrol(i.p, db.search(_filter, i.p)[1], arg)
         body = view.search(_filter, i.p)
     # Summary page for page number, default is home page
     else:
         pagenumber = int(i.p)
         if pagenumber > db.maxx():
             return render.error()
         body = view.summary(pagenumber)
         arg = '/?p'
         page = view.pagecontrol(i.p, db.maxx(), arg)
     s = banner()
     return render.base([body, page, i.q, s])
Ejemplo n.º 5
0
def checkinmode():
	"""The checkin screen"""
	clear()
	ui.chk()
	iny = raw_input("NAME:   ")
	if iny == ":EXIT":
		home()
	else:
		pass
	def markin(uid):
		db.checkin(uid)
	try:
		x = db.search("name",iny)
		if chky(x.id) is False:
			markin(x.id)
			ui.ok()
			time.sleep(1)
			checkinmode()
		elif chky(x.id) is True:
			ui.chkold()
			time.sleep(1)
			checkinmode()
		else:	#@error 003
			ui.err("#003")
			time.sleep(1)
			checkinmode()
	except AttributeError: #@Error 001
		ui.fail()
		time.sleep(1)
		checkinmode()
	except: #@error 002
		#print sys.exc_info()[0]
		ui.err("#002")
		time.sleep(1)
		sys.exit()
Ejemplo n.º 6
0
async def userSearch(m, _):
    userid = ul.parse_mention(m)
    if userid == None:
        await m.channel.send("I wasn't able to find a user anywhere based on that message. `$search USER`")
        return

    # Get database values for given user
    search_results = db.search(userid)
    username = ul.fetch_username(m.guild, userid)

    if search_results == []:
        if username != None:
            await m.channel.send("User {} was not found in the database\n".format(username))
        else:
            await m.channel.send("That user was not found in the database or the server\n")
        return

    # Format output message
    out = "User {} was found with the following infractions\n".format(username)
    for index, item in enumerate(search_results):
        # Enumerate each item
        n = "{}. ".format(index + 1)
        n += str(item)

        # If message becomes too long, send what we have and start a new post
        if len(out) + len(n) < config.CHAR_LIMIT:
            out += n
        else:
            await m.channel.send(out)
            out = n

    await m.channel.send(out)
Ejemplo n.º 7
0
def filesend(filename, mediatype):
    path = "/data/data/com.termux/files/home/scripts/file2send/"
    data = db.search(mediatype)
    with open(path + filename, "w", encoding="utf-8") as f:
        for t in data:
            f.write(",".join(t) + "\n")
    send2FTP(path, filename)
Ejemplo n.º 8
0
def success():
    #post method is used to receive user data to the backend for BMI Calculation
    if request.method == 'POST':
        email = request.form["user_email"]
        height = stringToFloat(request.form["user_height"])
        weight = stringToFloat(request.form["user_weight"])
        if (height != 0) and (weight > 0):#if entered height is 0 and weight is greater than 0
            bmi = weight/(height*height)
            bmi = ("%.2f" % bmi)
            #stores data into the database
            db.insert(email, height, weight, bmi)
            #prints data from the database
            print(db.search(email))
            return render_template('success.html', email=db.search(email)[-1][1], height=db.search(email)[-1][2], weight=db.search(email)[-1][3]
                                   , bmi=db.search(email)[-1][4])
        else:
            return '<h1>Height or Weight can not be zero</h1>'
Ejemplo n.º 9
0
def search(tag):
    if request.method == 'GET':
        resultDict = db.search(tag)
        return render_template('search.html', resultDict = resultDict, tag=tag)
    else:
        button = request.form['button']
        if button == 'Search':        
            return redirect('/search/'+request.form['query'])
Ejemplo n.º 10
0
def search_command():
    refresh_list()
    for row in db.search(title_text.get(), author_text.get(), year_text.get(),
                         isbn_text.get()):
        listbox.insert(
            END,
            '{:2d}|{:6s}|{:6s}|{:4d}|{:10d}'.format(row[0], row[1], row[2],
                                                    row[3], row[4]))
Ejemplo n.º 11
0
def students_list():
    if request.method == 'POST':
        id = int(request.form.get('id'))
        name = request.form.get('name')
        email = request.form.get('email')
        db.insert(id=id, name=name, email=email)
        return render_template('students.html',
                               students=db.search(),
                               id=id,
                               name=name,
                               email=email)
    elif request.method == 'GET':
        return render_template('students.html',
                               students=db.search(),
                               id="",
                               name="",
                               email="")
Ejemplo n.º 12
0
def search(tag):
    if request.method == 'GET':
        resultDict = db.search(tag)
        return render_template('search.html', resultDict=resultDict, tag=tag)
    else:
        button = request.form['button']
        if button == 'Search':
            return redirect('/search/' + request.form['query'])
Ejemplo n.º 13
0
 def querybook(self):
     na = self.bookname.get()
     a = db.search(na)
     if a == ():
         showinfo(title = '查询结果', message = '无结果!')
     else:
         results = a[0]
         msg = '书号:'+results[1]+'  作者: '+results[2]+'  出版社: '+results[3]
         showinfo(title = '查询结果', message = msg)
Ejemplo n.º 14
0
def search():
	try:
		connection = db.get_connection()
		searchInput = request.form['search']
		locationInput = request.form['location']
		businesses = db.search(connection, searchInput, locationInput)
		return jsonify(businesses)
	except Exception as e:
		return {'error': str(e)}
Ejemplo n.º 15
0
def student_update(student_id):
    student = db.search(id=student_id)[0]
    if request.method == 'POST':
        name = request.form.get('name')
        email = request.form.get('email')
        db.update({'name': name, 'email': email}, {'id': student_id})
        return redirect('/students')
    elif request.method == 'GET':
        return render_template('student_update.html', student=student)
Ejemplo n.º 16
0
def lookup_username(uid: int) -> Optional[str]:
    username = ul.fetch_username(client, uid)

    if not username:
        check_db =  db.search(uid)
        if check_db != []:
            username = check_db[-1].name
        else:
            return None

    return username
Ejemplo n.º 17
0
def search(*args, **kargs):
    """
    Search entries by performin an exact match. You must pass key-value pairs 
    according to the following accepted keys: 'series', 'abstract', 'number', 'month', 
    'edition', 'year', 'techreport_type', 'title', 'booktitle', 'institution', 'note', 
    'editor', 'howpublished', 'journal', 'volume', 'key', 'address', 'pages', 'chapter',
    'publisher', 'school', 'author', 'organization'

    It returns a SQLAlchemy query which contains objects of bibtexmodel.Document.
    """
    return db.search(*args, **kargs)
Ejemplo n.º 18
0
def query_keywords(value):
    result = search(value)

    myjson = [{
        "title": row.get("title"),
        "summary": row.get("summary"),
        "url": row.get("url", ""),
        "company": row.get("company", ""),
        "location": row.get("location")
    } for row in result]
    return json.dumps(myjson, ensure_ascii=False).encode('utf8')
Ejemplo n.º 19
0
def search_tip():
    data = request.get_json()
    keyword = data.get('keyword')
    search_data = db.search(keyword)
    bar = []
    post = []
    for b in search_data.get('bar'):
        bar.append([b.b_name, b.b_statement])
    for p in search_data.get('post'):
        post.append([p.p_title, p.p_content])
    return jsonify({'bar': bar, 'post': post})
Ejemplo n.º 20
0
def get_user(username):
    """
    If there is the user in the database, we will return that user, else error
    :param username: Twitter handle
    :return: User object
    """
    result = search({'username': username}, 'tweets')
    if not result:
        user = User("@{}".format(username))
        user.get_tweets()
        return json.loads(user.to_json())
    else:
        return result
Ejemplo n.º 21
0
def submit_search():
    user = db.User()
    if auth.is_login:
        user = db.db_session.query(db.User).filter(
            db.User.u_name == session.get('current_user')).first()
    keyword = request.form.get('search_input')
    search_data = db.search(keyword)
    bars = search_data.get('bar')
    posts = search_data.get('post')
    return render_template('search.html',
                           user=user,
                           bars=bars,
                           posts=posts,
                           old_keyword=keyword)
Ejemplo n.º 22
0
def search():
    obj = json.loads(request.data.decode("utf-8"))
    print(obj)
    keyword = obj["keyword"]
    data = db.search(keyword)
    if data["code"] == 200:
        print(data)
        resp = {"code": 200, "data": data["data"]}
        jsonData = json.dumps(resp, default=str, sort_keys=True, indent=2)
        return jsonData
    else:
        resp = {"code": 202}
        jsonData = json.dumps(resp, default=str, sort_keys=True, indent=2)
        return jsonData
Ejemplo n.º 23
0
 def GET(self, search_query, page_num):
     """ 
     input: user's query (search_query)
     output: matching results 
     """
     
     path = search_query.split('/') # split query
     
     # FUTURE POSSIBLE BUG: SUPPLYING LESS PARAMETERS WILL CAUSE TO UNEXECPETED RESULTS
     search_for = path[0] # searching query word is always first
     # options are everything else (-options are places you want to search in: title, description etc.)
     options = path[1:]
     options_path = "/".join(options) # build path of options
     search_result = db.search(search_for, options, int(page_num))
     return render.search(search_result, search_for, int(page_num), options_path)
Ejemplo n.º 24
0
    def on_button(self):
        self.index1 = 0
        self.index2 = 0
        for widget in self.main.winfo_children():
            widget.destroy()
        query = self.entry.get()
        self.results = search(query)
        if len(self.results) > 0:
            import json

            with open('bookkeeping.json') as f:
                self.bookkeeping = json.load(f)
        if len(self.results) >= self.index1 + 10:
            self.index2 = 10
        else:
            self.index2 = len(self.results)
        for index in range(self.index1, self.index2):
            result = self.results[index]
            document_id = result[2]
            document_id = document_id[54:]
            link = self.bookkeeping[document_id]
            data_string = StringVar()
            data_string.set(link)
            messeage = Entry(self.main,
                             textvariable=data_string,
                             fg="black",
                             bg="white",
                             bd=0,
                             state="readonly",
                             width=800)
            # messeage = Entry(self.main, text=link, width=800)
            messeage.pack(fill='both', pady=(10, 10))
        if len(self.results) > 10:
            for widget in self.frame2.winfo_children():
                widget.destroy()
            next_btn = Button(self.frame2,
                              text="Next",
                              width=8,
                              command=self.next_button,
                              fg='blue')
            prev_btn = Button(self.frame2,
                              text="Prev",
                              width=8,
                              command=self.prev_button,
                              fg='blue')
            prev_btn.pack(side=LEFT)
            next_btn.pack(side=RIGHT)
        self.index1 = self.index2
Ejemplo n.º 25
0
    def GET(self, search_query, page_num):
        """ 
        input: user's query (search_query)
        output: matching results 
        """

        path = search_query.split('/')  # split query

        # FUTURE POSSIBLE BUG: SUPPLYING LESS PARAMETERS WILL CAUSE TO UNEXECPETED RESULTS
        search_for = path[0]  # searching query word is always first
        # options are everything else (-options are places you want to search in: title, description etc.)
        options = path[1:]
        options_path = "/".join(options)  # build path of options
        search_result = db.search(search_for, options, int(page_num))
        return render.search(search_result, search_for, int(page_num),
                             options_path)
Ejemplo n.º 26
0
def action_search(keywords, max_results):
    print("Searching for:", keywords)
    data_path = appdata.data_path()
    if os.path.exists(data_path):
        with db.connect(data_path) as fafi:
            cursor = db.search(fafi, keywords, max_results)
            if cursor is None:
                print("No results.")
                return

            i = 1
            for row in cursor:
                url = row[0]
                snippet = row[1].replace("\n", " ").strip()
                print(str(i) + ")", url, "\n", snippet, "\n")
                i += 1
Ejemplo n.º 27
0
def get_user(username):
    """
    If there is the user in the database, we will return that user, else error
    :param username: Twitter handle
    :return: User object
    """
    result = search({'username': username}, 'tweets')
    if not result:
        print("new user")
        user = User(username)
        user.get_tweets()
        return user
    else:
        print("old user")
        user = get_user_data(result)
        user.get_tweets()
        return user
Ejemplo n.º 28
0
    def fetch_username(self, server, userid):
        username = None

        member = self.fetch_user(server, userid)
        if member != None:
            # If we found a member in the server, simply format the username
            username = "******".format(member.name, member.discriminator)

        if username == None:
            # If user has recently left, use that username
            if userid in self.recent_bans:
                username = self.recent_bans[userid]

        if username == None:
            # Check the database to see if we can get their name from their most recent infraction (if any)
            checkDatabase = db.search(userid)
            if checkDatabase != []:
                username = checkDatabase[-1].name

        return username
Ejemplo n.º 29
0
def find():
    s2 = search.write()
    id = s2[1]
    status = s2[0]
    ack = s2[2]
    if (ack == 0x09):
        data = {
            'status': status,
            'ack': ack,
            'msg': ' You are Not Valid User ! '
        }
        return render_template('vote.html', **data)
    elif ack == 0:
        ser = db.search(id)
        status = ser['status']
        if status == 1:
            msg = {'msg': 'You Are Allready Attempt for Vote !'}
            return render_template('duplicate.html', **msg)
        else:
            return render_template('govote.html', **ser)
Ejemplo n.º 30
0
def pois_v1():
    global _db

    filter_s = unicode(request.query.get('filter', None), encoding='utf-8')
    if filter_s is None:
        abort(501, "Unfiltered searches not allowed.")

    result = search(database=_db, verbose=False, query=filter_s)

    municipality = request.query.get('municipality', None)
    if municipality:
        if municipality.lower() in municipalities_set:
            municipality_key = None
            for k, v in municipalities.iteritems():
                if v.lower() == municipality.lower():
                    municipality_key = k
                    break
            if not municipality_key:
                abort(501, "Unknown municipality: %s." % municipality)
            else:
                result = [r for r in result if r['municipality_id'] == municipality_key]


    try:
        result_count = int(request.query.get('resultcount', -1))

        if int(result_count) != -1:
            for r in result:
                distance = levenshtein(filter_s, r['name'])
                r['edit_distance'] = distance

            result.sort(key=lambda x: x['edit_distance'])
            result = list(islice(result, result_count))
    except:
        abort(501, "Cannot parse resultcount:%s." % request.query.get('resultcount'))

    response.content_type = 'application/json'
    return json.dumps(result, ensure_ascii=False)
Ejemplo n.º 31
0
async def userSearch(m: discord.Message, _):
    userid = ul.parse_id(m)
    if not userid:
        await m.channel.send(f"I wasn't able to find a user anywhere based on that message. `{CMD_PREFIX}search USER`")
        return

    # Get database values for given user
    search_results = db.search(userid)
    username = lookup_username(userid)

    if search_results == []:
        if username:
            await m.channel.send(f"User {username} was not found in the database\n")
        else:
            await m.channel.send("That user was not found in the database or the server\n")
            return
    else:
        # Format output message
        out = f"User {username} (ID: {userid}) was found with the following infractions\n"
        for index, item in enumerate(search_results):
            # Enumerate each item
            n = f"{index + 1}. "
            n += str(item)

            # If message becomes too long, send what we have and start a new post
            if len(out) + len(n) < config.CHAR_LIMIT:
                out += n
            else:
                await m.channel.send(out)
                out = n
        await m.channel.send(out)

    censored = db.get_censor_count(userid)
    if not censored:
        await m.channel.send("They have never tripped the censor")
    else:
        await m.channel.send(f"They have tripped the censor {censored[0]} times, most recently on {commonbot.utils.format_time(censored[1])}")
Ejemplo n.º 32
0
def search(search_term):
    """ Search for products, returns a list of products """
    print("Searching for " + search_term)
    return jsonify(db.search(search_term))
Ejemplo n.º 33
0
def identify_clip(filename):
    song_name, tags, sig = read_audiofile(filename)
    addresses, times = fp.get_addresses(fp.get_filtered_spectrogram(sig))
    return db.show_results(db.search(addresses, times), 3)
Ejemplo n.º 34
0
    def GET(self, action):
        web.header("Content-Type", "application/json")
        set_no_cache()

        # check if we have the action
        if action not in self.GET_ACTIONS:
            return error.wrong_action()

        # get the input data if we have the spec
        if action in self.VALIDATE_SPECS:
            d = get_input(self.VALIDATE_SPECS[action])

        uuid = session.get("uuid", None)
        if not uuid:
            return error.not_logged_in()

        if action == "stream":
            param = spec.extract(self.EXTRACT_SPECS["stream_request"], d)
            if param["type"] == "user":
                if not param["uid"]:
                    raise web.badrequest()
            elif param["type"] == "list":
                if not param["list_id"]:
                    raise web.badrequest()
            ret = db.stream(uuid, **param)
            if "error" in ret:
                return jsond(ret)
            else:
                return jsond(spec.extract(self.EXTRACT_SPECS["stream_response"], ret))

        elif action == "current_user":
            u = db.get_user(uuid)
            return jsond(spec.extract(self.EXTRACT_SPECS["current_user"], u))

        elif action == "userinfo":
            u = db.find_user(d.uid)
            if not u:
                return error.user_not_found()
            u["isfollowing"] = bson.objectid.ObjectId(uuid) in u["follower"]
            return jsond(spec.extract(self.EXTRACT_SPECS["userinfo"], u))

        elif action == "get_following":
            param = spec.extract(self.EXTRACT_SPECS["userlist_request"], d)
            ret = db.get_following(uuid, **param)
            new_items = [spec.extract(self.EXTRACT_SPECS["userinfo"], u) for u in ret["items"]]
            ret["items"] = new_items
            return jsond(ret)

        elif action == "get_follower":
            param = spec.extract(self.EXTRACT_SPECS["userlist_request"], d)
            ret = db.get_follower(uuid, **param)
            new_items = [spec.extract(self.EXTRACT_SPECS["userinfo"], u) for u in ret["items"]]
            ret["items"] = new_items
            return jsond(ret)

        elif action == "get_message":
            ret = db.get_message(uuid, d.msg_id)
            if "error" in ret:
                return jsond(ret)
            else:
                return jsond(spec.extract(self.EXTRACT_SPECS["stream_response"], ret))

        elif action == "validate":
            act = d.action
            if act in self.VALIDATE_SPECS:
                errors = spec.validate(self.VALIDATE_SPECS[act], web.input())
                if errors:
                    return jsond(errors)
                else:
                    return jsond({"success": 1})
            else:
                return error.wrong_action()

        elif action == "recommend_user":
            return jsond({"users": [spec.extract(self.EXTRACT_SPECS["userinfo"], u) for u in db.recommend_user(uuid)]})

        elif action == "get_lists":
            ret = db.get_lists(uuid, d.get("uid"))
            if "error" in ret:
                return jsond(ret)
            else:
                return jsond({"items": [spec.extract(self.EXTRACT_SPECS["listinfo"], l) for l in ret]})

        elif action == "get_list_info":
            ret = db.get_list_info(uuid, d["id"])
            if "error" in ret:
                return jsond(ret)
            else:
                return jsond(spec.extract(self.EXTRACT_SPECS["listinfo"], ret))

        elif action == "get_list_users":
            param = spec.extract(self.EXTRACT_SPECS["list_userlist_request"], d)
            ret = db.get_list_users(uuid, param["id"], param["skip"])
            new_items = [spec.extract(self.EXTRACT_SPECS["userinfo"], u) for u in ret["items"]]
            ret["items"] = new_items
            return jsond(ret)

        elif action == "search":
            req = spec.extract(self.EXTRACT_SPECS["search_request"], d)
            ret = db.search(uuid, **req)
            if "error" in ret:
                return jsond(ret)
            else:
                return jsond(spec.extract(self.EXTRACT_SPECS["stream_response"], ret))

        return error.not_implemented()
Ejemplo n.º 35
0
def search():
	if request.method == "POST":
		button = str(request.form["button"])
		if button == "Register":
			return redirect(url_for("register"))
		if button == "Login":
			username = request.form['username']
			password = request.form['password']
			du = (db.authuser(username, password))
			if du != False:
					session["username"] = str(username)
					u = du[1]
					session["idnum"] = int(u["idnum"])
					session["email"] = str(u["email"])
					session["first"] = str(u["first"])
					session["last"] = str(u["last"])
					print session["username"]
					print session["idnum"]
					print "u:" + u["first"]
					print "last: " + session["last"]
					print "name: " + session["first"]
					session["itemsubmitted"] = False
					return redirect(url_for("search"))
			else:
				c = []
				if "searchcat" in session:
					c = session["searchcat"]
					session["searchcat"] = []
				print c
				return render_template("search.html",loginfailed = True, results = db.search(c), notloggedin = True)
		elif button == "Search":
			stype = str(request.form["dropdown"])
			print stype
			itemname = str(request.form["itemname"]	)	
			startprice = str(request.form["startprice"])
			cats = [str(x) for x in request.form.getlist("cats")]
			print cats
			if startprice == "":
				startprice = -1
			else:
				sp = floatpat.findall(startprice)
				print startprice
				print sp
				print sp[0][0]
				if (sp[0][0]) == "" or (len(sp[0][1]) != 3 and len(sp[0][1]) != 0)or sp[0][0] != startprice or float(startprice) < 0:
					return render_template("search.html", spbad = True)
				startprice = float(startprice)	
			res = db.search(cats,itemname, "",startprice, stype)
			print "search res:"
			print res
			if "username" not in session:
				return render_template("search.html",results = res, notloggedin = True)
			else:
				return render_template("search.html",results = res)
		elif button in allcategories:
			session["searchcat"] = [str(button)]
			c = []
			if "searchcat" in session:
				c = session["searchcat"]
				session["searchcat"] = []
			print c
			if "username" in session:
				return render_template("search.html", results = db.search(c))
			else:
				return render_template("search.html", results = db.search(c), notloggedin = True)
		else:
			print "search button " + button#floatpat.findall(startprice)
			num = inumpat.findall(button)
			us = iuserpat.findall(button)
			name = inamepat.findall(button)
			bs = ibspat.findall(button)
			print "Init:\nnumber: "
			print num
			print "search button " + button#floatpat.findall(startprice)
			print "user: "******"search button " + button#floatpat.findall(startprice)
			print "product: "
			print name
			print "b/s: "
			print bs
			session["itemnumber"] = (num)[0][0:len((num)[0]) - 1]
			session["itemuser"] = (us)[0][1:len((us)[0]) - 10]
			session["itemname"] = (name)[0][10:len((name)[0]) - 8]
			session["itembs"] = (bs)[0][8:]
			print "number: " + session["itemnumber"]
			print "seller: " + session["itemuser"]
			print "product: " + session["itemname"]
			print "b/s: " + session["itembs"]
			return redirect(url_for("product"))
	else:	
		c = []
		if "searchcat" in session:
			c = session["searchcat"]
			session["searchcat"] = []
		print c
		if "username" in session:
			return render_template("search.html", results = db.search(c))
		else:
			return render_template("search.html", results = db.search(c), notloggedin = True)
Ejemplo n.º 36
0
def search_cmd():
    listbox.delete(0, END)
    for row in db.search(str(permit_val.get()), name_val.get().lower()):
        listbox.insert(END, row)
Ejemplo n.º 37
0
def search( db, args ):
	return db.search( args.words );
Ejemplo n.º 38
0
def search(request):
    pois = db.search(float(request.GET['lat']), float(request.GET['lng']),
                     request.GET['q'], int(request.GET['num']))
    return HttpResponse(str(pois))
Ejemplo n.º 39
0
def search(request):
  #print request.GET['q']
  pois = db.search(float(request.GET['lat']), float(request.GET['lng']),
      request.GET['q'], int(request.GET['num']))
  return HttpResponse(str(pois))
Ejemplo n.º 40
0
 def search(self, names):
     result = []
     for db in self.dbs:
         result.extend(db.search(names))
     return result
Ejemplo n.º 41
0
        for file in files:
            tagging.tagAdd().filename(file)
    
    if args.timetest is not None:
        directory = args.timetest
        files = crawl().get_filepaths(directory)
        tagging.tagAdd().timetest(files)

if args.command == "search":
    parser._actions[-1].container._remove_action(parser._actions[-1])
    parser.add_argument("--gallery", nargs='*', help="Instead of returning a list, return every filename in sequence, separated by a space, so that the files can all be piped")
    parser.add_argument("tags", nargs='*', help="Tags to search for")
    args = parser.parse_args()
    if args.gallery:
        exclude = ["'", ',', '[', ']'] 
        results = search().results(args.gallery)
        results = str(results)
        results = ''.join(ch for ch in results if ch not in exclude)
    else:
        results = search().results(args.tags)
    print(results)

if args.command == "rm":
    parser._actions[-1].container._remove_action(parser._actions[-1])
    parser.add_argument("-t", "--tag", nargs='*', help="Remove specific tag(s) from file(s)")
    parser.add_argument("filepath", nargs='*', help="File(s) or directories to remove")
    args = parser.parse_args()
    if args.tag:
        tags_remove = args.tag[0]
        filepaths = args.tag[1:]
    else:
Ejemplo n.º 42
0
def student_detail_view(student_id):
    if request.method == 'GET':
        db_search = db.search(id=student_id)
        student = db_search and db_search[0] or None
        return render_template('student_detail.html', student=student)
Ejemplo n.º 43
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import time
from time import strftime
import cgitb,cgi
import db
import json
import twitter,watson
cgitb.enable()

print("Content-Type: application/json;charset=utf-8")
print()

query_string = cgi.FieldStorage().getvalue('q').upper()
#case insensitive
if query_string is None:
	print("{'error':'Empty query'}")
else:
	tweets=twitter.search(query_string)
	db.store(query_string,time.time(),tweets,watson.analyze(tweets))
	ret=db.search(query_string)
	result=[]
	for doc in ret:
		result.append({"id":doc["_id"], "time":doc["time"]})
	print(json.dumps(result))