本文整理汇总了Python中API.API类的典型用法代码示例。如果您正苦于以下问题:Python API类的具体用法?Python API怎么用?Python API使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了API类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setListItemProps
def setListItemProps(self, server, id, listItem, result):
# set up item and item info
thumbID = id
eppNum = -1
seasonNum = -1
tvshowTitle = ""
if(result.get("Type") == "Episode"):
thumbID = result.get("SeriesId")
seasonNum = result.get("ParentIndexNumber")
eppNum = result.get("IndexNumber")
tvshowTitle = result.get("SeriesName")
self.setArt(listItem,'poster', API().getArtwork(result, "Primary"))
self.setArt(listItem,'tvshow.poster', API().getArtwork(result, "SeriesPrimary"))
self.setArt(listItem,'clearart', API().getArtwork(result, "Art"))
self.setArt(listItem,'tvshow.clearart', API().getArtwork(result, "Art"))
self.setArt(listItem,'clearlogo', API().getArtwork(result, "Logo"))
self.setArt(listItem,'tvshow.clearlogo', API().getArtwork(result, "Logo"))
self.setArt(listItem,'discart', API().getArtwork(result, "Disc"))
self.setArt(listItem,'fanart_image', API().getArtwork(result, "Backdrop"))
self.setArt(listItem,'landscape', API().getArtwork(result, "Thumb"))
listItem.setProperty('IsPlayable', 'true')
listItem.setProperty('IsFolder', 'false')
# Process Studios
studios = API().getStudios(result)
if studios == []:
studio = ""
else:
studio = studios[0]
listItem.setInfo('video', {'studio' : studio})
details = {
'title' : result.get("Name", "Missing Name"),
'plot' : result.get("Overview")
}
if(eppNum > -1):
details["episode"] = str(eppNum)
if(seasonNum > -1):
details["season"] = str(seasonNum)
if tvshowTitle != None:
details["TVShowTitle"] = tvshowTitle
listItem.setInfo( "Video", infoLabels=details )
people = API().getPeople(result)
# Process Genres
genre = API().getGenre(result)
listItem.setInfo('video', {'director' : people.get('Director')})
listItem.setInfo('video', {'writer' : people.get('Writer')})
listItem.setInfo('video', {'mpaa': result.get("OfficialRating")})
listItem.setInfo('video', {'genre': API().getGenre(result)})
示例2: display_task
def display_task(self, id=None):
tmpl = lookup.get_template("display_task.html.mako")
task = API.get_task_object(id)
if task.parent_job == None:
job = None
else:
job = API.get_job_object(id=str(task.parent_job))
return tmpl.render(task=task, job=job)
示例3: add_task
def add_task(self, id=None, name=None, state=None, tag=None, dependency=None, parent_job=None, removed_parent_defaults=None,
image=None, command=None, entrypoint=None, cron=None, restartable=None, exitcodes=None, max_failures=None, delay=None,
faildelay=None, environment=None, datavolumes=None, port=None, description=None):
""" """
if id:
return API.update_task(id=id, name=name, state=state, tag=tag, dependency=dependency, parent_job=parent_job, removed_parent_defaults=removed_parent_defaults,
image=image, command=command, entrypoint=entrypoint, cron=cron, restartable=restartable, exitcodes=exitcodes, max_failures=max_failures, delay=delay, faildelay=faildelay,
environment=environment, datavolumes=datavolumes, port=port, description=description)
else:
return API.add_task(name=name, state=state, tag=tag, dependency=dependency, parent_job=parent_job, removed_parent_defaults=removed_parent_defaults,
image=image, command=command, entrypoint=entrypoint, cron=cron, restartable=restartable, exitcodes=exitcodes, max_failures=max_failures, delay=delay, faildelay=faildelay,
environment=environment, datavolumes=datavolumes, port=port, description=description)
示例4: advance
def advance(self):
'''Ход планеты, он же игровой день'''
self.repaint_method_by_obj.clear()
for team in self.teams_by_base.itervalues():
team.base.advance()
for ant in team.ants_set:
dst_coord, move = ant.move()
my_API = API(world=self)
if dist(dst_coord, my_API.get_coord_by_obj(ant)) <= 1:
getattr(self, move)(dst_coord, ant)
# срабатывает, если при запуске был задан флаг --logs
self.dump()
示例5: Init
def Init(self, teams):
for team in teams:
self.add_team(team)
# рандомим места для баз, размещаем их там и инициализируем
coord_for_bases = sample(self.obj_by_coord, len(teams))
for base, coord in zip(self.teams_by_base, coord_for_bases):
API_for_setup = API(world=self)
if API_for_setup.get_type_by_coord(coord) != type(None):
self.del_obj(self.obj_by_coord[coord])
API_for_setup.Init(base)
base.Init(API=API_for_setup)
self.set_obj(obj=base, coord=coord)
示例6: add_instance_configuration
def add_instance_configuration(self, name=None, ami=None, key=None, iam=None, ebssize=None,
ebstype=None, userdata=None, instance_type=None, spot=None, bid=None,
subnet=None, sg=None, tag=None, id=None, default=False):
if cherrypy.session.get("usertype", "user") == "admin":
return API.add_instance_configuration(name, ami, key, iam, ebssize,
ebstype, userdata, instance_type, spot, bid,
subnet, sg, tag, id, default)
else:
return json.dumps({"error": "User not authorized for this request"})
示例7: get_users
def get_users(self, username=None, userid=None, usertype=None):
# Check if the user is an admin
if cherrypy.session.get("usertype", "user") == "admin":
users = API.get_users(username, userid, usertype)
if users:
return [user.json for user in users]
else:
return json.dumps({"error": "No user matches the request"})
else:
return json.dumps({"error": "User not authorized for this request"})
示例8: action_request
def action_request(self):
title = API.get_title_by_id(self.str_input)
# in this case, pass it in as a list
self.build_response([title])
if len(self.response.avail_titles) > 0:
self.response.message = 'Great! %s is available to stream!' % title.name
else:
self.response.message = 'Unfortunately %s is not available to stream. You might want to set up ' \
'an alert.' % title.name
示例9: build_response
def build_response(self, titles):
"""
Does the generic parts of building a request. Just provide a list of titles discovered by the subclass's
implementation of action_request
"""
titles_with_availability = API.find_titles(titles)
avail, unavail = self.separate_availability(titles_with_availability)
self.response = Response()
self.response.avail_titles = avail
self.response.unavail_titles = unavail
self.response.request_type = self.str_type
示例10: update_job
def update_job(
self,
id=None, name=None, description="", tags=None, state=None, dependencies=None,
parent_job=None, command="", entrypoint="", exitcodes="",
restartable=True, datavolumes=None, environment=None, image=None, cron="",
max_failures=3, delay=0, faildelay=5, port=None
):
return API.update_job(
id, name, description, tags, state, dependencies, parent_job, command,
entrypoint, exitcodes, restartable, datavolumes, environment, image, cron,
max_failures, delay, faildelay, port
)
示例11: get_log
def get_log(self, log_name, lines=200, full_log=False):
if not log_name:
if full_log:
return None
else:
return '{"error": "log_name must be present"}'
if full_log:
try:
return serve_file("/logs/" + log_name, "application/x-download", "attachment")
except Exception:
return None
return API.get_log(log_name=log_name, lines=lines)
示例12: __init__
def __init__(self, parent):
Frame.__init__(self, parent)
# Initialize the api
self.api = API()
# Set the ip and port to communicate with the master server
self.SERVER_IP = config.masterip
self.SERVER_PORT = config.port
# Set the initial server status to 0, will change to 1 if server is active
# self.serverStatus = 0
# Declare a list which will hold the files that have been flagged for deletion
self.toDelete = []
self.parent = parent
# Initialize the GUI
self.initUI()
示例13: admin
def admin(self):
# Check if the user is an admin
if cherrypy.session.get("usertype", "user") == "admin":
tmpl = lookup.get_template("admin.html.mako")
if settings['web_use_auth'] == "true":
return tmpl.render(
username = cherrypy.session['username'],
userimageurl = cherrypy.session['userimageurl'],
usertype = cherrypy.session['usertype'],
settings = settings,
users = API.get_users(),
hooks = API.get_hooks()
)
else:
return tmpl.render(
username = cherrypy.session.get("username", "dev"),
userimageurl = cherrypy.session.get("userimageurl", "dev"),
usertype = cherrypy.session.get("usertype", "admin"),
settings = settings,
users = API.get_users(),
hooks = API.get_hooks()
)
else:
return json.dumps({"error": "User not authorized for this request"})
示例14: __init__
def __init__(self, nom=None, url=None, frequence=7):
self.API = API.getInstance()
self.pluginDatas = {"chaines":[],
"emissions":{},
"fichiers":{}}
self.pluginOptions = []
if nom == None:
logger.warn("DEPRECATED: il faut préciser le nom du plugin au constructeur")
else:
self.nom = nom
if url == None:
logger.warn("DEPRECATED: il faut préciser l'url du site du plugin au constructeur")
else:
self.url = url
self.frequence = frequence
self.fichierConfiguration = os.path.join( Constantes.REPERTOIRE_CONFIGURATION, self.nom.replace( " ", "_" )+ ".conf" )
self.fichierCache = os.path.join( Constantes.REPERTOIRE_CACHE, self.nom.replace( " ", "_" ) + ".cache" )
示例15: __init__
def __init__(self, nom=None, url=None, frequence=7):
self.API = API.getInstance()
self.pluginDatas = {"chaines":[],
"emissions":{},
"fichiers":{}}
self.pluginOptions = []
if nom == None:
logger.warn("DEPRECATED: il faut préciser le nom du plugin au constructeur")
else:
self.nom = nom
if url == None:
logger.warn("DEPRECATED: il faut préciser l'url du site du plugin au constructeur")
else:
self.url = url
self.frequence = frequence
path = os.path.expanduser( "~" )
self.fichierConfiguration = path+"/.tvdownloader/conf/"+self.nom.replace( " ", "_" )+".conf"
self.fichierCache = path+"/.tvdownloader/cache/"+self.nom.replace( " ", "_" )+".cache"