def no_results(): feedback = Feedback() feedback.add_item("No results found", "I'm really sorry that you had to experience this.", arg="", valid="no") return feedback
def display_actors(the_id): feedback = Feedback() movie = omdb.get_movie(the_id) feedback.add_item("Back...", "", "", "no", the_id, "images/back.png") if "Actors" in movie: actors = movie["Actors"].split(", ") for actor in actors: feedback.add_item(actor, "Show on IMDb...", json_args({ "command": "lucky_imdb", "query": actor }), "yes", "", "images/imdb.png") return feedback
def show_tabs(query = ""): feedback = Feedback() wins_tabs = all_tabs() windows = wins_tabs["windows"] for window in windows: tabs = window["tabs"] for tab in tabs: if query is None or query is "" or query.lower() in tab["name"].lower() or query.lower() in tab["url"].lower(): feedback.add_item(tab["name"], "", json_args({ "window_index": window["index"], "window_title": window["title"], "tab_index": tab["index"], "tab_name": tab["name"], "tab_url": tab["url"] })) return feedback
def xml_results(items): feedback = Feedback() for item in items: video_id = item["id"] if video_id is not None: title = item["title"] subtitle = "by %s (%s)" % (item["uploader"], seconds_to_string(item["duration"])) if SUBTITLE_SHOWS_VIEW_COUNT is True and "viewCount" in item: view_count = item["viewCount"] view_word = "view" if view_count is not 1: view_word = "views" subtitle = "%s [%s %s]" % (subtitle, locale.format("%d", view_count, grouping = True), view_word) feedback.add_item(title, subtitle, ("http://www.youtube.com/watch?v=%s" % video_id)) return feedback
def search_channels(query, max_results = 0): feedback = Feedback() url = "https://gdata.youtube.com/feeds/api/channels?q=%s&v=2" % (query) url = max_results_url(url, max_results) content = content_of_url(url) dom = minidom.parseString(content) entries = dom.getElementsByTagName("entry") for entry in entries: title = entry.getElementsByTagName("title")[0].firstChild.nodeValue summary = entry.getElementsByTagName("summary")[0].firstChild name = entry.getElementsByTagName("author")[0].firstChild.firstChild.nodeValue if summary is not None: summary = summary.data feedback.add_item(title, summary, ("http://www.youtube.com/user/%s" % name)) return feedback
def __init__(self, editor): Signal.__init__(self) self.__init_attributes(editor) from Feedback import Feedback Feedback(self, editor) from CursorReseter import Reseter Reseter(self, editor) from ViewUpdater import Updater Updater(self, editor) from TextInserter import Inserter Inserter(self, editor) from CommandExecutor import Executor Executor(self, editor) from BoundsExtractor import Extractor Extractor(self, editor) from NewWindowHandler import Handler Handler(self, editor) from GUI.Manager import Manager Manager(self, editor) from DatabaseMonitor import Monitor Monitor(self, editor) from DatabaseWriter import Writer Writer(self, editor) from DatabaseReader import Reader Reader(self, editor)
def __init__(self, editor): Signal.__init__(self) self.__init_attributes(editor) from Feedback import Feedback Feedback(self, editor) from GUI.Manager import Manager Manager(self, editor) from ThemeFileInstaller import Installer Installer(self, editor) from ThemeFileValidator import Validator Validator(self, editor) from DatabaseWriter import Writer Writer(self, editor) from DatabaseReader import Reader Reader(self, editor) from DatabaseMonitor import Monitor Monitor(self, editor) from ThemeRemover import Remover Remover(self, editor) from ThemeUpdater import Updater Updater(self, editor) from ThemeDispatcher import Dispatcher Dispatcher(self, editor) from ThemeFolderMonitor import Monitor Monitor(self, editor)
def __init__(self, editor): Signal.__init__(self) self.__init_attributes(editor) from ViewUpdater import Updater Updater(self, editor) from UndoRedoManager import Manager Manager(self, editor) from Feedback import Feedback Feedback(self, editor) from PlaceholderColorer import Colorer Colorer(self, editor) from PlaceholderCursorMonitor import Monitor Monitor(self, editor) from TextInsertionMonitor import Monitor Monitor(self, editor) from BoundaryCursorMonitor import Monitor Monitor(self, editor) from PlaceholderNavigator import Navigator Navigator(self, editor) from KeyboardHandler import Handler Handler(self, editor) from PlaceholderRemover import Remover Remover(self, editor) from PlaceholderSearcher import Searcher Searcher(self, editor) from MarkManager import Manager Manager(self, editor) from TemplateInserter import Inserter Inserter(self, editor) from AbbreviationExpander import Expander Expander(self, editor) from GUI.Manager import Manager Manager(self, editor)
def __init__(self, editor): Signal.__init__(self) self.__init_attributes(editor) from GUI.Manager import Manager Manager(self, editor) from LineJumper import Jumper Jumper(self, editor) from Feedback import Feedback Feedback(self, editor) from Utils import create_bookmark_image create_bookmark_image(editor) from MarkAdder import Adder Adder(self, editor) from MarkRemover import Remover Remover(self, editor) from MarginDisplayer import Displayer Displayer(self, editor) from DatabaseWriter import Writer Writer(self, editor) from MarkReseter import Reseter Reseter(self, editor) from MarkUpdater import Updater Updater(self, editor) from Marker import Marker Marker(self, editor) from DatabaseReader import Reader Reader(self, editor)
def display_search_results(query): feedback = Feedback() results = imdb.search(query) feedback = add_to_feedback(feedback, results, "popular") feedback = add_to_feedback(feedback, results, "exact") feedback = add_to_feedback(feedback, results, "substring") # feedback = add_to_feedback(feedback, results, "approx") return feedback
def search_channels(query, max_results=0): feedback = Feedback() url = "https://gdata.youtube.com/feeds/api/channels?q=%s&v=2" % (query) url = max_results_url(url, max_results) content = content_of_url(url) dom = minidom.parseString(content) entries = dom.getElementsByTagName("entry") for entry in entries: title = entry.getElementsByTagName("title")[0].firstChild.nodeValue summary = entry.getElementsByTagName("summary")[0].firstChild name = entry.getElementsByTagName( "author")[0].firstChild.firstChild.nodeValue if summary is not None: summary = summary.data feedback.add_item(title, summary, ("http://www.youtube.com/user/%s" % name)) return feedback
def get_status(terms=""): """Retrieve the current status of the jobs matching the given terms Keyword arguments: terms -- The terms entered by the user (default is "") """ feedback = Feedback() data = get_data_from_url() if data != None: if "jobs" in data and len(data["jobs"]) > 0: search_regex = re.compile(terms, re.IGNORECASE) for job in data["jobs"]: if re.search(search_regex, job["name"]) != None: title = job["name"] if "healthReport" in job and len(job["healthReport"]) > 0: subtext = job["healthReport"][0]["description"] icon = health_to_icon(job["healthReport"][0]["score"], job["color"]) else: subtext = "" icon = "images/"+job["color"]+".png" feedback.add_item(title, subtext, job["url"], "yes", "", icon) else: feedback.add_item("No results found", "I'm sorry, I failed to find what you were looking for", "", "no") else: feedback.add_item("An error occured", "It seems I made a mistake somewhere, please forgive me", "", "no") return feedback
def query(query="love the way you lie"): q_url = 'http://www.xiami.com/app/nineteen/search/key/%s/page/1' % query req = urllib2.Request(q_url, headers=HEADERS) html = urllib2.urlopen(req).read() response = json.loads(html) results = response['results'] fb = Feedback() for rcd in results: name = urllib.unquote_plus(rcd['song_name']).encode("latin-1").decode("utf-8") album = urllib.unquote_plus(rcd['album_name']).encode("latin-1").decode("utf-8") artist = urllib.unquote_plus(rcd['artist_name']).encode("latin-1").decode("utf-8") song_id = urllib.unquote_plus(rcd['song_id']).encode("latin-1").decode("utf-8") fb.add_item("%s - %s" % (artist, name), subtitle=u"歌手:%s 专辑:《%s》" % (artist, album), uid=song_id, arg='http://www.xiami.com/song/' + song_id) print fb
def execute(query): """Execute the desired command Keyword arguments: query -- The query entered by the user """ words = query.split() action = words[0] words.pop(0) terms = " ".join(words) if action == "status": return get_status(terms) else: feedback = Feedback() feedback.add_item("status {query}", "Get the status for builds corresponding with {query}", "", "no", "status") return feedback
def feedback(username): userID = webEngine.username2id(username) feedbackform = feedbackForm(request.form) fullName = "" userName = "" email = "" message = "" user = [] s = shelve.open('db/users.db') user = s[userID] s.close() if request.method == 'POST' and feedbackform.validate(): fullName = feedbackform.fullName.data userName = feedbackform.userName.data email = feedbackform.email.data message = feedbackform.message.data feedbackObject = Feedback(fullName, user.get_username(), user.get_password(), email, message) feedbackShelve = {} s = shelve.open('db/feedback.db') try: feedbackShelve = s[userID] feedbackShelve[feedbackObject.get_feedbackID()] = feedbackObject s[userID] = feedbackShelve except KeyError: feedbackShelve[feedbackObject.get_feedbackID()] = feedbackObject s[userID] = feedbackShelve s.close() return render_template('home.html') else: feedbackform.userName.data = user.get_username() feedbackform.fullName.data = user.get_name() feedbackform.email.data = user.get_email() return render_template('feedback.html', form=feedbackform)
def run(): # Get all the mounts in Volumes volumes = os.listdir(MOUNT_FOLDER) # Get Additional Volume Information volume_tuples = [] for volume_name in volumes: volume_arg = MOUNT_FOLDER + '/' + re.sub(' ', '\\ ', volume_name) extra_info = os.popen('diskutil info ' + volume_arg).read() # Get Partition Protocol volume_prot = re.search('Protocol:\s+(.+)', extra_info) if volume_prot: volume_prot = volume_prot.group(1) volume_icon = get_volume_icon(volume_prot) if volume_prot == 'SATA': continue else: continue # Get Partition Type volume_type = re.search('File System Personality:\s+(.+)', extra_info) if volume_type: volume_type = volume_type.group(1) else: continue # Get Partition Total Size volume_size = re.search('Total Size:\s+(\S+\s\w+)', extra_info) if volume_size: volume_size = volume_size.group(1) else: continue # Append Values to tuple if all fields present subtitle = 'Protocol: ' + volume_prot + ' | ' + 'Type: ' + \ volume_type + ' | ' + 'Size: ' + volume_size volume_tuples.append((volume_name, subtitle, volume_arg, volume_icon)) # Create the object to display mounts feedback = Feedback() # Add the mount items for volume_name, subtitle, volume_arg, volume_icon in volume_tuples: # feedback.add_item(volume_name) feedback.add_item(volume_name, subtitle, volume_arg, icon=volume_icon) if volume_tuples: feedback.add_item('All', 'Eject All Disks.', 'all') # If no volumes are mounted...say so else: feedback.add_item('No Volumes Found...', 'Searched for mounted drives in /Volumes') return feedback
def xml_results(items): feedback = Feedback() for item in items: video_id = item["id"] if video_id is not None: title = item["title"] subtitle = "by %s (%s)" % (item["uploader"], seconds_to_string(item["duration"])) if SUBTITLE_SHOWS_VIEW_COUNT is True: view_count = item["viewCount"] view_word = "view" if view_count is not 1: view_word = "views" subtitle = "%s [%s %s]" % ( subtitle, locale.format("%d", view_count, grouping=True), view_word) feedback.add_item(title, subtitle, ("http://www.youtube.com/watch?v=%s" % video_id)) return feedback
def shoplist(query): query = query.decode('utf-8') query = unicodedata.normalize('NFC', query) encoded = urllib.urlencode({'query':query.encode('utf-8')}) url = 'http://openapi.naver.com/search?{}&display={}&start=1&target=shop&sort=sim&key={}'.format(encoded, length, KEY) response = urllib2.urlopen(url) r = response.read() t = fromstring(r) items = t.findall('channel/item') fb = Feedback() for i in items: title = strip_tags(i.find('title').text) url = i.find('link').text price = i.find('lprice').text fb.add_item(title, subtitle=u"₩ {:,}".format(int(price)), arg=url) print fb
def find(): feedback = Feedback() song = current_song() if "error" in song: feedback.add_item(song["error"]) else: result = LyricsWiki.search(song["artist"], song["song"]) if result: title = "Show lyrics" subtitle = "%s - %s" % (result["artist"], result["song"]) feedback.add_item("Show lyrics", subtitle, result["url"]) else: feedback.add_item("No lyrics found", "", "", "no") return feedback
def get_trans_result(keyword): # 有道API youdao_api = 'http://fanyi.youdao.com/openapi.do?' \ 'keyfrom=simman' \ '&key=902290141' \ '&type=data' \ '&doctype=json' \ '&version=1.1&' + \ urllib.urlencode({'q':keyword}) result_json = urllib2.urlopen(youdao_api) base_json = json.load(result_json) fb = Feedback() # 处理错误信息 try: fb.add_item(base_json['reason']) except: for dic in base_json['web'] : fb.add_item(dic['key'], ','.join(dic['value'])) print fb
def run(): # scan for available networks networks = WifiScan.find_access_points() """ networks = WifiScanYosemite.find_access_points() """ # Create the object to display networks feedback = Feedback() # Add the network items to feedback for mac in networks: feedback.add_item(networks[mac], mac, networks[mac], icon="OPEN.png") """ for TK in networks # how to specify the particular item below - e.g. the items and the record #??? # e.g the SSID_STR from the 4th network? # encryption flag # CAPABILITIES key? an integer that contains info on encryption? # look at scan data from airport utiliity for encrypted networks # how to pass it to here and what to do with it?? feedback.add_item(networks[SSID_STR], networks[BSSID], icon=network_icon(networks[TK])) def get_network_icon(TK): if TK == 'NONE': return 'OPEN.png' else: return 'CLOSED.png' """ return feedback
def query(query="love the way you lie"): q_url = 'http://www.xiami.com/app/nineteen/search/key/%s/page/1' % query req = urllib2.Request(q_url, headers=HEADERS) html = urllib2.urlopen(req).read() response = json.loads(html) results = response['results'] fb = Feedback() for rcd in results: name = urllib.unquote_plus( rcd['song_name']).encode("latin-1").decode("utf-8") album = urllib.unquote_plus( rcd['album_name']).encode("latin-1").decode("utf-8") artist = urllib.unquote_plus( rcd['artist_name']).encode("latin-1").decode("utf-8") song_id = urllib.unquote_plus( rcd['song_id']).encode("latin-1").decode("utf-8") fb.add_item("%s - %s" % (artist, name), subtitle=u"歌手:%s 专辑:《%s》" % (artist, album), uid=song_id, arg='http://www.xiami.com/song/' + song_id) print fb
def filtering(tag_lst): tag_lst[:] = map(sanitize_sql, tag_lst) tags = "'" + "', '".join(tag_lst) + "'" sql = """SELECT bm.* FROM bookmark bm, tags t WHERE (t.tag IN (%s)) AND t.bid=bm.id GROUP BY bm.id HAVING COUNT(bm.id)=%d """ % (tags, len(tag_lst)) conn = sqlite3.connect(DB_FN) c = conn.cursor() fb = Feedback() parser = HTMLParser.HTMLParser() is_empty = True for bid, url, desc, tm in c.execute(sql): is_empty = False fb.add_item("""%s""" % parser.unescape(desc), subtitle="""%s""" % url, uid=bid, arg=url) if not is_empty: print fb
def get_status(terms=""): """Retrieve the current status of the jobs matching the given terms Keyword arguments: terms -- The terms entered by the user (default is "") """ feedback = Feedback() data = get_data_from_url() if data != None: if "jobs" in data and len(data["jobs"]) > 0: search_regex = re.compile(terms, re.IGNORECASE) for job in data["jobs"]: if re.search(search_regex, job["name"]) != None: title = job["name"] subtext = job["lastBuild"]["displayName"]; if (job["lastBuild"]["building"]): progress = job["lastBuild"]["executor"]["progress"]; duration = job["lastBuild"]["estimatedDuration"]; subtext += " (building: " \ + str(progress) + "%, " \ + str(duration*progress/1000/100) + "/" + str(duration/1000) \ + "sec)"; if (job["queueItem"]): subtext += " - queued(" + job["queueItem"]["why"] + ")"; if "healthReport" in job and len(job["healthReport"]) > 0: #subtext = job["healthReport"][0]["description"] icon = health_to_icon(job["healthReport"][0]["score"], job["color"]) else: #subtext = "" icon = "images/"+job["color"]+".png" feedback.add_item(title, subtext, job["url"], "yes", "", icon) else: feedback.add_item("No results found", "I'm sorry, I failed to find what you were looking for", "", "no") else: feedback.add_item("An error occured", "It seems I made a mistake somewhere, please forgive me", "", "no") return feedback
def __init__(self, editor): Signal.__init__(self) from Feedback import Feedback Feedback(self, editor) from BufferFreezer import Freezer Freezer(self, editor) from RegionSelector import Selector Selector(self, editor) from CursorPlacer import Placer Placer(self, editor) from TextInserter import Inserter Inserter(self, editor) from Commenter import Commenter Commenter(self, editor) from CommentDecider import Decider Decider(self, editor) from RegionMarker import Marker Marker(self, editor)
def __init__(self, editor): Signal.__init__(self) from Feedback import Feedback Feedback(self, editor) from UndoManager import Manager Manager(self, editor) from Selector import Selector Selector(self, editor) from QuoteCharacterMatcher import Matcher Matcher(self, editor) from RangeChecker import Checker Checker(self, editor) from PairCharacterMatcher import Matcher Matcher(self, editor) from OpenCharacterSearcher import Searcher Searcher(self, editor) from SelectionChecker import Checker Checker(self, editor)
def __init__(self, editor): Signal.__init__(self) from Feedback import Feedback Feedback(self, editor) from LineJumper import Jumper Jumper(self, editor) from Checker import Checker Checker(self, editor) from ProcessCommunicator import Communicator Communicator(self, editor) from ExternalProcessStarter import Starter Starter(self, editor) from DatabaseReader import Reader Reader(self, editor) from DatabaseWriter import Writer Writer(self, editor) from DatabaseMonitor import Monitor Monitor(self, editor)
def display_actors(the_id): feedback = Feedback() movie = omdb.get_movie(the_id) feedback.add_item("Back...", "", "", "no", the_id, "images/back.png") if "Actors" in movie: actors = movie["Actors"].split(", ") for actor in actors: feedback.add_item( actor, "Show on IMDb...", json_args({ "command": "lucky_imdb", "query": actor }), "yes", "", "images/imdb.png") return feedback
def __init__(self, editor): Signal.__init__(self) from os.path import join self.__gui = editor.get_gui_object(globals(), join("GUI", "GUI.ui")) from GUI.Manager import Manager Manager(self, editor) from FolderEnumerator import Enumerator Enumerator(self, editor) from FileinfosGenerator import Generator Generator(self, editor) from PathNavigator import Navigator Navigator(self, editor) from HistoryManager import Manager Manager(self, editor) from Feedback import Feedback Feedback(self, editor) from FolderMonitor import Monitor Monitor(self, editor) from gobject import idle_add idle_add(self.emit, "generate-uris", editor.pwd_uri)
def __init__(self, editor): GObject.__init__(self) self.__init_attributes(editor) from Feedback import Feedback Feedback(self, editor) from URIOpener import Opener Opener(self, editor) from MatchFilterer import Filterer Filterer(self, editor) from FileFormatter import Formatter Formatter(self, editor) from FileinfoFilterer import Filterer Filterer(self, editor) from Enumerator import Enumerator Enumerator(self, editor) from FilesAggregator import Aggregator Aggregator(self, editor) from FolderPathUpdater import Updater Updater(self, editor) from GUI.Manager import Manager Manager(self, editor)
def get_status(terms=""): """Retrieve the current status of the jobs matching the given terms Keyword arguments: terms -- The terms entered by the user (default is "") """ feedback = Feedback() data = get_data_from_url() if data != None: if "jobs" in data and len(data["jobs"]) > 0: search_regex = re.compile(terms, re.IGNORECASE) for job in data["jobs"]: if re.search(search_regex, job["name"]) != None: title = job["name"] if "healthReport" in job and len(job["healthReport"]) > 0: subtext = job["healthReport"][0]["description"] icon = health_to_icon(job["healthReport"][0]["score"], job["color"]) else: subtext = "" icon = "images/" + job["color"] + ".png" feedback.add_item(title, subtext, job["url"], "yes", "", icon) else: feedback.add_item( "No results found", "I'm sorry, I failed to find what you were looking for", "", "no") else: feedback.add_item( "An error occured", "It seems I made a mistake somewhere, please forgive me", "", "no") return feedback
def __init__(self): Signal.__init__(self) self.__init_attributes() from ProcessMonitor import Monitor Monitor(self) from DBusService import DBusService DBusService(self) from GUI.Manager import Manager Manager(self) from LastFileOpener import Opener Opener(self) from Feedback import Feedback Feedback(self) from MatchFilterer import Filterer Filterer(self) from DataGenerator import Generator Generator(self) from FileOpener import Opener Opener(self) from RecentInfoListener import Listener Listener(self) from gobject import timeout_add timeout_add(1000, self.__response)
def set_off(self, current_object=None): """ Sets 'on' to false (i.e our laser is turned not detected). :param current_object: the object (i.e the ROI) the dot was last seen in. :rtype : void """ self.on = False self.last_found_time = time.time() if self.found_time is not None: elapsed = (time.time() - self.found_time) if elapsed >= self.wait_time: print "[INFO] Gesture detected. (ON for {0} seconds)".format( str(self.wait_time)) if self.current_object is not None and self.current_object == current_object: command = "Gesture detected on object: {0}".format( str(current_object.name)) feedback = Feedback(command) feedback.setName('FeedbackThread') feedback.daemon = True # make deamon thread to terminate when main program ends feedback.start() print "[INFO] Gesture detected on object: {0}".format( str(current_object.name))
def set_off(self, current_object=None): """ Sets 'on' to false (i.e our laser is turned not detected). :param current_object: the object (i.e the ROI) the dot was last seen in. :rtype : void """ self.on = False self.last_found_time = time.time() if self.found_time is not None: elapsed = (time.time() - self.found_time) if elapsed >= self.wait_time: print "[INFO] Gesture detected. (ON for {0} seconds)".format(str(self.wait_time)) if self.current_object is not None and self.current_object == current_object: command = "Gesture detected on object: {0}".format(str(current_object.name)) feedback = Feedback(command) feedback.setName('FeedbackThread') feedback.daemon = True # make deamon thread to terminate when main program ends feedback.start() print "[INFO] Gesture detected on object: {0}".format(str(current_object.name))
def get_trans_result(keyword): # 有道API youdao_api = 'http://fanyi.youdao.com/openapi.do?' \ 'keyfrom=simman' \ '&key=902290141' \ '&type=data' \ '&doctype=json' \ '&version=1.1&' + \ urllib.urlencode({'q':keyword}) result_json = urllib2.urlopen(youdao_api) base_json = json.load(result_json) fb = Feedback() # 处理错误信息 try: fb.add_item(base_json['reason']) except: for dic in base_json['web']: fb.add_item(dic['key'], ','.join(dic['value'])) print fb
def xml_items_deletion(amount = 10): feedback = Feedback() myitems = items(amount) for item in myitems: feedback.add_item(item["name"], str_date(item["created_at"]), item["href"], "", "", icon_for_type(item["item_type"])) return feedback
def youtube_helper(query): args = string.split(query, " ") if (args[0] == "s" or args[0] == "search") and len(args) > 1 and args[1] is not "": return youtube.search_videos(" ".join(args[1:])) elif (args[0] == "c" or args[0] == "channels") and len(args) > 1 and args[1] is not "": return youtube.search_channels(" ".join(args[1:])) elif (args[0] == "cv" or args[0] == "channelvideos") and len(args) > 1 and args[1] is not "": return youtube.channel_videos(" ".join(args[1:])) elif args[0] == "toprated": return youtube.top_rated_videos() elif args[0] == "topfavorited": return youtube.top_favorited_videos() elif args[0] == "mostviewed": return youtube.most_viewed_videos() elif args[0] == "mostpopular": return youtube.most_popular_videos() elif args[0] == "mostrecent": return youtube.most_recent_videos() elif args[0] == "mostdiscussed": return youtube.most_discussed_videos() elif args[0] == "mostresponded": return youtube.most_responded_videos() elif args[0] == "recentlyfeatured": return youtube.recently_featured_videos() elif len(args) == 0 or args[0] == "": feedback = Feedback() feedback.add_item("Search videos", "", "", "no", "s") feedback.add_item("Search channels", "", "", "no", "c") feedback.add_item("View videos on channel", "", "", "no", "cv") feedback.add_item("Top rated videos", "", "", "no", "toprated") feedback.add_item("Top favorited videos", "", "", "no", "topfavorited") feedback.add_item("Most viewed videos", "", "", "no", "mostviewed") feedback.add_item("Most popular videos", "", " videos", "no", "mostpopular") feedback.add_item("Most recent videos", "", "", "no", "mostrecent") feedback.add_item("Most discussed videos", "", "", "no", "mostdiscussed") feedback.add_item("Most responded videos", "", "", "no", "mostresponded") feedback.add_item("Recently featured videos", "", "", "no", "recentlyfeatured") return feedback else: return youtube.search_videos(" ".join(args)) return None
def tweetbot_helper(query = ""): feedback = Feedback() args = string.split(query, " ") if args[0] == "n" or args[0] == "new" or args[0] == "tweet": item = build_post_tweet_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "t" or args[0] == "timeline": item = build_show_timeline_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "m" or args[0] == "mentions": item = build_show_mentions_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "rt" or args[0] == "retweets": item = build_show_retweets_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "dm" or args[0] == "directmessages" or args[0] == "messages": item = build_show_direct_messages_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "l" or args[0] == "lists": item = build_show_lists_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "favs" or args[0] == "favorites": item = build_show_favorites_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "s" or args[0] == "search": item = build_show_search_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "user": item = build_show_user_profile_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "f" or args[0] == "follow": item = build_follow_item(args) feedback.add_item(item["title"], "", item["args"]) elif args[0] == "u" or args[0] == "unfollow": item = build_unfollow_item(args) feedback.add_item(item["title"], "", item["args"]) else: feedback.add_item("Post tweet", "", "", "no", "n") feedback.add_item("Show timeline", "", "", "no", "t") feedback.add_item("Show mentions", "", "", "no", "m") feedback.add_item("Show retweets", "", "", "no", "rt") feedback.add_item("Show direct messages", "", "", "no", "dm") feedback.add_item("Show lists", "", "", "no", "l") feedback.add_item("Show favorites", "", "", "no", "favs") feedback.add_item("Show search", "", "", "no", "s") feedback.add_item("Show user profile", "", "", "no", "user ") feedback.add_item("Follow", "", "", "no", "f ") feedback.add_item("Unfollow", "", "", "no", "u ") return feedback
sys.setdefaultencoding('utf-8') query = sys.argv[1] #query = '{query}' url = 'http://suggest.taobao.com/sug?code=utf-8&callback=KISSY.Suggest.callback&q=%s' % query; f = urllib.urlopen(url); content = f.read(); ## KISSY.Suggest.callback({"result": [["arduino套件", "534"], ["arduino 入门套件", "845"], ["arduino uno r3", "120853"], ["arduino 小车", "464"], ["arduino mega2560", "217"], ["arduino wifi", "1272843"], ["arduino leonardo", "53"], ["arduino nano", "177"], ["arduino 蓝牙", "169"], ["arduino 摄像头", "23"]]}) content = content.replace("\s*","") p = re.compile( r'KISSY.Suggest.callback\((.*)\)') content = p.sub(r'\1', content); response = json.loads(content) #print response; fb = Feedback() try: # 将搜索关键字补充进来 fb.add_item(query, subtitle="Search taobao items on %s" % query, arg=query) for title,id in response['result']: #url = 's.taobao.com/search?q=%s&searcy_type=item&s_from=newHeader&source=&ssid=s5-e&search=y' % title #url.replace(' ', '_') fb.add_item(title, subtitle="Search taobao items on %s" % title, # arg=title.replace(" ", "_")) arg=title) except SyntaxError as e: if ('EOF', 'EOL' in e.msg): fb.add_item('...')
from Feedback import Feedback fb = Feedback() fb.add_item("Hello", "World") fb.add_item("Title", subtitle="Item description", arg="Value return to workflow", valid="yes", autocomplete="Description", icon="public.jpeg", filetype="file", icontype="filetype") print fb
def results_feedback(results): feedback = Feedback() for song in results: feedback.add_item(song.title(), 'by %s' % song.artist().name(), str(song.id())) return feedback
def display_movie_info(the_id): feedback = Feedback() movie = omdb.get_movie(the_id) title_args = json_args({ "command": "imdb_movie", "id": the_id }) if "Title" in movie and "Year" in movie and "Runtime" in movie and "imdbRating" in movie: feedback.add_item(("%s (%s)" % (movie["Title"], movie["Year"])), ("%s, Rating: %s" % (movie["Runtime"], movie["imdbRating"])), title_args, "yes", "", "images/imdb.png") elif "Title" in movie and "Year" in movie and "Runtime" in movie: feedback.add_item(("%s (%s)" % (movie["Title"], movie["Year"])), ("%s" % (movie["Runtime"])), title_args, "yes", "", "images/imdb.png") elif "Title" in movie and "Year" in movie and "imdbRating" in movie: feedback.add_item(("%s (%s)" % (movie["Title"], movie["Year"])), ("Rating: %s" % (movie["imdbRating"])), title_args, "yes", "", "images/imdb.png") elif "Title" in movie and "Year" in movie: feedback.add_item(("%s (%s)" % (movie["Title"], movie["Year"])), "Title", title_args, "yes", "", "images/imdb.png") elif "Title" in movie: feedback.add_item(movie["Title"], "Title", title_args, "yes", "", "images/imdb.png") if "Genre" in movie: feedback.add_item(movie["Genre"], "Genre", "", "no", the_id, "images/genre.png") if "Released" in movie: feedback.add_item(movie["Released"], "Release date", "", "no", the_id, "images/release_date.png") if "Director" in movie and movie["Director"] != "" and movie["Director"] != "N/A": feedback.add_item(movie["Director"], "Director", json_args({ "command": "lucky_imdb", "query": movie["Director"] }), "yes", "", "images/director.png") if "Writer" in movie and movie["Writer"] != "" and movie["Writer"] != "N/A": feedback.add_item(movie["Writer"], "Writer", json_args({ "command": "lucky_imdb", "query": movie["Writer"] }), "yes", "", "images/writer.png") if "Actors" in movie: feedback.add_item("Show actors...", movie["Actors"], "", "no", ("%s actors" % (the_id)), "images/actors.png") if "Plot" in movie and movie["Plot"] != "" and movie["Plot"] != "N/A": escaped_plot = movie["Plot"].replace("'", "").replace("\"", "") feedback.add_item("Show plot...", movie["Plot"], json_args({ "command": "quicklook_text", "text": escaped_plot }), "yes", "", "images/plot.png") if "Poster" in movie: feedback.add_item("Show poster...", "", json_args({ "command": "quicklook_poster", "url": movie["Poster"] }), "yes", "", "images/poster.png") if "Title" in movie: trailer_query = "%s official trailer" % (movie["Title"]) feedback.add_item("View trailer...", "", json_args({ "command": "trailer", "query": trailer_query }), "yes", "", "images/youtube.png") feedback.add_item("Show on IMDb...", "", title_args, "yes", "", "images/imdb.png") return feedback
query = sys.argv[1] #query = '{query}' url = 'http://suggest.taobao.com/sug?code=utf-8&callback=KISSY.Suggest.callback&q=%s' % query f = urllib.urlopen(url) content = f.read() ## KISSY.Suggest.callback({"result": [["arduino套件", "534"], ["arduino 入门套件", "845"], ["arduino uno r3", "120853"], ["arduino 小车", "464"], ["arduino mega2560", "217"], ["arduino wifi", "1272843"], ["arduino leonardo", "53"], ["arduino nano", "177"], ["arduino 蓝牙", "169"], ["arduino 摄像头", "23"]]}) content = content.replace("\s*", "") p = re.compile(r'KISSY.Suggest.callback\((.*)\)') content = p.sub(r'\1', content) response = json.loads(content) #print response; fb = Feedback() try: for title, id in response['result']: #url = 's.taobao.com/search?q=%s&searcy_type=item&s_from=newHeader&source=&ssid=s5-e&search=y' % title #url.replace(' ', '_') fb.add_item( title, subtitle="Search taobao items on %s" % title, # arg=title.replace(" ", "_")) arg=title) except SyntaxError as e: if ('EOF', 'EOL' in e.msg): fb.add_item('...') else: fb.add_item('SyntaxError', e.msg)
import soundcloud from Feedback import Feedback client = soundcloud.Client(client_id='0c61ce131a2c1db8e56059446e33456a') feedback = Feedback() tracks = client.get('/tracks', q="{query}", limit=9) for track in tracks: artist = client.get('/users/' + str(track.user_id)) url = "http://www.soundcloud.com/" + artist.permalink + '/' + track.permalink feedback.add_item(track.title, artist.permalink, url) print feedback
def no_results(): feedback = Feedback() feedback.add_item("No results found", "I'm really sorry that you had to experience this.", arg = "", valid = "no") return feedback
def xml_items(amount = 10): feedback = Feedback() myitems = items(amount) for item in myitems: feedback.add_item(item["name"], subtitle_for_item(item), item["url"], "", "", icon_for_type(item["item_type"])) return feedback
def no_results_feedback(): feedback = Feedback() feedback.add_item('No results found', '', '', 'no', '') return feedback
def error_feedback(msg): feedback = Feedback() feedback.add_item(msg) return feedback
def read_rtcp_packet(rtcp_socket): packet = rtcp_socket.recv(4096) rate_packet_loss = int.from_bytes(packet[9:11], 'big') / 10000 rate_packet_late = int.from_bytes(packet[11:13], 'big') / 10000 return Feedback(rate_packet_loss, rate_packet_late)
print("Total Number of Images:", no_of_images) print("Unique Images:", unique_images) result = {} for val in ret_val: result[val[0]] = val[1] misc.plot_similar_images(result) lsh.save_result(result) elif task == '6': r = int(input('Number Of Images you would like to label as Relevant:')) ir = int(input('Number of Images you would like to label as Irrelevant:')) final_path = '../Phase2/pickle_files/HOG_SVD_11k.pkl' print('loading from pickle file path', final_path) infile = open(final_path, 'rb') dataset_features = pickle.load(infile) feedback = Feedback() task5_result = feedback.task5_result base_id = None num_image = {} count = 1 rorir_map = {} for image_id, val in task5_result.items(): image_id = os.path.basename(image_id) num_image[count] = image_id print(count, image_id) rorir_map[num_image[count]] = -1 count += 1 count = 0 while r > 0: ind = int(input('Enter the Image Number to Label as Relevant:')) r -= 1