def grab_random_fanart(controlNum, special): global fanart get_fanart_list(True) if len(fanart) == 0: return # sometimes the list control isn't available yet onload # so add some checking to make sure control = common.get_list(controlNum, special) count = 10 while control == "" and count > 0: time.sleep(0.25) control = common.get_list(controlNum, special) count = count - 1 window = common.get_window_id(special) if control == "": pass else: item = control.GetItem(0) while 1: if xbmcgui.getCurrentWindowDialogId() == 9999: art = fanart[fanart.keys()[randint(0, len(fanart) - 1)]].encode("utf-8") item.SetProperty("fanart", str(art)) count = 5 while count > 0: if window != common.get_window_id(special): return time.sleep(2) count = count - 1
def grab_fanart_list(listNum, special): global fanart_changed get_fanart_list() # sometimes the list control isn't available yet onload # so add some checking to make sure lst = common.get_list(listNum, special) count = 10 while lst == "" and count > 0: time.sleep(0.25) lst = common.get_list(listNum, special) count = count - 1 window = common.get_window_id(special) if lst == "": pass else: # as long as the list exists (while the window exists) # the list gets updated at regular intervals. otherwise # the fanart disappears when you change sort-orders or # select a genre # should have very little overhead because all the values # get cached in memory focusedItem = "" while 1: # don't spend any time doing stuff if a dialog is open # 9999 is the dialog number when no dialogs are open # if special == True then the scanning is happening in # a dialog so we DO continue processing if xbmcgui.getCurrentWindowDialogId() == 9999 or special: newFocusedItem = mc.GetInfoString("Container(%s).ListItem.Label" % listNum) newFocusedItem = str(newFocusedItem) if newFocusedItem != focusedItem and newFocusedItem != "": lst = common.get_list(listNum, special) if lst != "": items = lst.GetItems() if len(items) > 0: for item in items: grab_fanart_for_item(item) focusedItem = newFocusedItem del items if window != common.get_window_id(special): return time.sleep(2) # store the fanart list for next time if the list # was modified if fanart_changed == 1: store_fanart_list()
def list(self): ''' Makes REST API call and retrieves volume groups Parameters: None Returns: List of volume group UUIDs in JSON response payload ''' (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", VolumeGroup.URI_VOLUME_GROUP_LIST, None) o = common.json_decode(s) if("volume_group" in o): return common.get_list(o, 'volume_group') return []
def feed(): feed = AtomFeed('MacaroniCode', feed_url=request.url, url=request.url_root) posts = get_list(Post) for post in posts: feed.add( unicode(post.title), unicode(post.html), content_type='html', author='uppfinnarn', url=make_external(url_for('blog.post', slug=post.slug)), updated=post.created, published=post.created ) return feed.get_response()
def list_imageservers(self): ''' Makes REST API call and retrieves compute Image servers Returns: List of image server in JSON response payload ''' uri = ComputeImageServers.URI_COMPUTE_IMAGE_SERVERS (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", uri, None) o = common.json_decode(s) if("compute_imageserver" in o): return common.get_list(o, 'compute_imageserver') return []
def list_imageservers(self): ''' Makes REST API call and retrieves compute Image servers Returns: List of image server in JSON response payload ''' uri = ComputeImageServers.URI_COMPUTE_IMAGE_SERVERS (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", uri, None) o = common.json_decode(s) if ("compute_imageserver" in o): return common.get_list(o, 'compute_imageserver') return []
def list_vnasserver_names(self): ''' Makes REST API call and retrieves vnasserver Parameters: Returns: List of vnasservers UUIDs in JSON response payload ''' uri = VnasServer.URI_VNSSERVER (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", uri, None) o = common.json_decode(s) if("vnas_server" in o): return common.get_list(o, 'vnas_server' ) return []
def list_file_polices(self): ''' Makes REST API call and retrieves filepolicy Parameters: Returns: List of FilePolicies UUIDs in JSON response payload ''' uri = FilePolicy.URI_FILE_POLICIES (s, h) = common.service_json_request(self.__ipAddr, self.__port, 'GET', uri, None) o = common.json_decode(s) returnlst = [] if 'file_policy' in o: return common.get_list(o, 'file_policy') return returnlst
def project_list(self, tenant_name): ''' Makes REST API call and retrieves projects based on tenant UUID Parameters: None Returns: List of project UUIDs in JSON response payload ''' from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) try: tenant_uri = tenant_obj.tenant_query(tenant_name) except SOSError as e: raise e (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", Project.URI_PROJECT_LIST.format(tenant_uri), None) o = common.json_decode(s) if("project" in o): return common.get_list(o, 'project') return []
def grab_fanart_list(listNum, special): global fanart_changed get_fanart_list(False) # sometimes the list control isn't available yet onload # so add some checking to make sure lst = common.get_list(listNum, special) count = 10 while lst == "" and count > 0: time.sleep(0.25) lst = common.get_list(listNum, special) count = count - 1 window = common.get_window_id(special) if lst == "": pass else: # as long as the list exists (while the window exists) # the list gets updated at regular intervals. otherwise # the fanart disappears when you change sort-orders or # select a genre # should have very little overhead because all the values # get cached in memory focusedItem = "" while 1: # don't spend any time doing stuff if a dialog is open # 9999 is the dialog number when no dialogs are open # if special == True then the scanning is happening in # a dialog so we DO continue processing if xbmcgui.getCurrentWindowDialogId() == 9999 or special: theItem = mc.GetInfoString("Container(%s).ListItem.Label" % listNum) theItem = str(theItem) if theItem != "": newFocusedItem = theItem else: newFocusedItem = focusedItem if (newFocusedItem != focusedItem and newFocusedItem != "") or (newFocusedItem == "" and special): lst = common.get_list(listNum, special) if lst != "": items = lst.GetItems() if len(items) > 0: if newFocusedItem == "": newFocusedItem = items[0].GetLabel() for item in items: grab_fanart_for_item(item) focusedItem = newFocusedItem del items if window != common.get_window_id(special): return time.sleep(2) # store the fanart list for next time if the list # was modified if fanart_changed == 1: store_fanart_list()
def index(): return render_template('blog/index.html', posts=get_list(Post))