text
stringlengths 0
828
|
|---|
self.tautulli_users = users
|
logger(self.tautulli_users)
|
except (asyncio.TimeoutError, aiohttp.ClientError, socket.gaierror,
|
AttributeError) as error:
|
msg = ""Can not load data from Tautulli: {} - {}"".format(url, error)
|
logger(msg, 40)"
|
475,"async def get_user_data(self):
|
""""""Get Tautulli userdata.""""""
|
userdata = {}
|
sessions = self.session_data.get('sessions', {})
|
try:
|
async with async_timeout.timeout(8, loop=self._loop):
|
for username in self.tautulli_users:
|
userdata[username] = {}
|
userdata[username]['Activity'] = None
|
for session in sessions:
|
if session['username'].lower() == username.lower():
|
userdata[username]['Activity'] = session['state']
|
for key in session:
|
if key != 'Username':
|
userdata[username][key] = session[key]
|
break
|
self.tautulli_user_data = userdata
|
except (asyncio.TimeoutError, aiohttp.ClientError, KeyError):
|
msg = ""Can not load data from Tautulli.""
|
logger(msg, 40)"
|
476,"def import_string(impstr, attr=None):
|
""""""Imports a string. Can import an attribute of the imported
|
class/module using a double colon as a separator
|
""""""
|
if ""::"" in impstr:
|
impstr, attr = impstr.split(""::"")
|
imported = wz_import_string(impstr)
|
if attr is not None:
|
return getobjpath(imported, attr)
|
return imported"
|
477,"def getobjpath(obj, path):
|
""""""Returns an item or attribute of the object recursively.
|
Item names are specified between brackets, eg: [item].
|
Attribute names are prefixed with a dot (the first one is optional), eg: .attr
|
Example: getobjpath(obj, ""attr1.attr2[item].attr3"")
|
""""""
|
if not path:
|
return obj
|
if path.startswith(""[""):
|
item = path[1:path.index(""]"")]
|
return getobjpath(obj[item], path[len(item) + 2:])
|
if path.startswith("".""):
|
path = path[1:]
|
if ""."" in path or ""["" in path:
|
dot_idx = path.find(""."")
|
bracket_idx = path.find(""["")
|
if dot_idx == -1 or bracket_idx < dot_idx:
|
idx = bracket_idx
|
next_idx = idx
|
else:
|
idx = dot_idx
|
next_idx = idx + 1
|
attr = path[:idx]
|
return getobjpath(getattr(obj, attr), path[next_idx:])
|
return getattr(obj, path)"
|
478,"def find_classes_in_module(module, clstypes):
|
""""""Find classes of clstypes in module
|
""""""
|
classes = []
|
for item in dir(module):
|
item = getattr(module, item)
|
try:
|
for cls in clstypes:
|
if issubclass(item, cls) and item != cls:
|
classes.append(item)
|
except Exception as e:
|
pass
|
return classes"
|
479,"def remove_yaml_frontmatter(source, return_frontmatter=False):
|
""""""If there's one, remove the YAML front-matter from the source
|
""""""
|
if source.startswith(""---\n""):
|
frontmatter_end = source.find(""\n---\n"", 4)
|
if frontmatter_end == -1:
|
frontmatter = source
|
source = """"
|
else:
|
frontmatter = source[0:frontmatter_end]
|
source = source[frontmatter_end + 5:]
|
if return_frontmatter:
|
return (source, frontmatter)
|
return source
|
if return_frontmatter:
|
return (source, None)
|
return source"
|
480,"def populate_obj(obj, attrs):
|
""""""Populates an object's attributes using the provided dict
|
""""""
|
for k, v in attrs.iteritems():
|
setattr(obj, k, v)"
|
481,"def insert_element_to_dict_of_list(dict_of_list, key, parser):
|
""""""
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.