desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Log level for this pattern.
:return:
:rtype:'
| @property
def log_level(self):
| return (self._log_level if (self._log_level is not None) else debug.LOG_LEVEL)
|
'Does this match has children
:param match:
:type match:
:return:
:rtype:'
| def _yield_children(self, match):
| return (match.children and (self.children or self.every))
|
'Does this mat
:param match:
:type match:
:return:
:rtype:'
| def _yield_parent(self):
| return ((not self.children) or self.every)
|
'Handle a parent match
:param match:
:type match:
:param yield_parent:
:type yield_parent:
:return:
:rtype:'
| def _match_parent(self, match, yield_parent):
| if ((len(match) < 0) or (match.value == '')):
return False
pattern_value = get_first_defined(self.values, [match.name, '__parent__', None], self._default_value)
if pattern_value:
match.value = pattern_value
if (yield_parent or self.format_all):
match.formatter = get_first_defined... |
'Handle a children match
:param child:
:type child:
:param yield_children:
:type yield_children:
:return:
:rtype:'
| def _match_child(self, child, yield_children):
| if ((len(child) < 0) or (child.value == '')):
return False
pattern_value = get_first_defined(self.values, [child.name, '__children__', None], self._default_value)
if pattern_value:
child.value = pattern_value
if (yield_children or self.format_all):
child.formatter = get_first_def... |
'Computes all matches for a given input
:param input_string: the string to parse
:type input_string: str
:param context: the context
:type context: dict
:param with_raw_matches: should return details
:type with_raw_matches: dict
:return: matches based on input_string for this pattern
:rtype: iterator[Match]'
| def matches(self, input_string, context=None, with_raw_matches=False):
| matches = []
raw_matches = []
for pattern in self.patterns:
yield_parent = self._yield_parent()
match_index = (-1)
for match in self._match(pattern, input_string, context):
match_index += 1
match.match_index = match_index
raw_matches.append(match)
... |
'Mark matches included in private_names with private flag.
:param matches:
:type matches:
:return:
:rtype:'
| def _matches_privatize(self, matches):
| if self.private_names:
for match in matches:
if (match.name in self.private_names):
match.private = True
|
'Ignore matches included in ignore_names.
:param matches:
:type matches:
:return:
:rtype:'
| def _matches_ignore(self, matches):
| if self.ignore_names:
for match in list(matches):
if (match.name in self.ignore_names):
matches.remove(match)
|
'List of base patterns defined
:return: A list of base patterns
:rtype: list'
| @abstractproperty
def patterns(self):
| pass
|
'Properties names and values that can ben retrieved by this pattern.
:return:
:rtype:'
| @property
def properties(self):
| if self._properties:
return self._properties
return {}
|
'dict of default options for generated Match objects
:return: **options to pass to Match constructor
:rtype: dict'
| @abstractproperty
def match_options(self):
| pass
|
'Computes all matches for a given pattern and input
:param pattern: the pattern to use
:param input_string: the string to parse
:type input_string: str
:param context: the context
:type context: dict
:return: matches based on input_string for this pattern
:rtype: iterator[Match]'
| @abstractmethod
def _match(self, pattern, input_string, context=None):
| pass
|
'This test fails on travis CI, can\'t find out why there\'s 1 line offset ...'
| def test_rebulk(self):
| assert (self.rebulk._patterns[0].defined_at.lineno in [26, 27])
assert (self.rebulk._patterns[0].defined_at.name == 'rebulk.test.test_debug')
assert self.rebulk._patterns[0].defined_at.filename.endswith('test_debug.py')
assert (str(self.rebulk._patterns[0].defined_at) in ['test_debug.py#L26', 'test_debu... |
'Decode one chunk of the input.
:param input: A byte string.
:param final:
Indicate that no more input is available.
Must be :obj:`True` if this is the last call.
:returns: An Unicode string.'
| def decode(self, input, final=False):
| decoder = self._decoder
if (decoder is not None):
return decoder(input, final)
input = (self._buffer + input)
(encoding, input) = _detect_bom(input)
if (encoding is None):
if ((len(input) < 3) and (not final)):
self._buffer = input
return u''
else:
... |
'Create a :class:`Language` by its `code` using `converter` to
:meth:`~babelfish.converters.LanguageReverseConverter.reverse` it
:param string code: the code to reverse
:param string converter: name of the :class:`~babelfish.converters.LanguageReverseConverter` to use
:return: the corresponding :class:`Language` instan... | @classmethod
def fromcode(cls, code, converter):
| return cls(*language_converters[converter].reverse(code))
|
'Create a :class:`Language` by from an IETF language code
:param string ietf: the ietf code
:return: the corresponding :class:`Language` instance
:rtype: :class:`Language`'
| @classmethod
def fromietf(cls, ietf):
| subtags = ietf.split(u'-')
language_subtag = subtags.pop(0).lower()
if (len(language_subtag) == 2):
language = cls.fromalpha2(language_subtag)
else:
language = cls(language_subtag)
while subtags:
subtag = subtags.pop(0)
if (len(subtag) == 2):
language.coun... |
'English name of the script'
| @property
def name(self):
| return SCRIPTS[self.code]
|
'Like iteritems(), but with all lowercase keys.'
| def lower_items(self):
| return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items())
|
'Convert an alpha3 language code with an alpha2 country code and a script code
into a custom code
:param string alpha3: ISO-639-3 language code
:param country: ISO-3166 country code, if any
:type country: string or None
:param script: ISO-15924 script code, if any
:type script: string or None
:return: the corresponding... | def convert(self, alpha3, country=None, script=None):
| raise NotImplementedError
|
'Reverse a custom code into alpha3, country and script code
:param string code: custom code to reverse
:return: the corresponding alpha3 ISO-639-3 language code, alpha2 ISO-3166-1 country code and ISO-15924 script code
:rtype: tuple
:raise: :class:`~babelfish.exceptions.LanguageReverseError`'
| def reverse(self, code):
| raise NotImplementedError
|
'Convert an alpha2 country code into a custom code
:param string alpha2: ISO-3166-1 language code
:return: the corresponding custom code
:rtype: string
:raise: :class:`~babelfish.exceptions.CountryConvertError`'
| def convert(self, alpha2):
| raise NotImplementedError
|
'Reverse a custom code into alpha2 code
:param string code: custom code to reverse
:return: the corresponding alpha2 ISO-3166-1 country code
:rtype: string
:raise: :class:`~babelfish.exceptions.CountryReverseError`'
| def reverse(self, code):
| raise NotImplementedError
|
'Get a converter, lazy loading it if necessary'
| def __getitem__(self, name):
| if (name in self.converters):
return self.converters[name]
for ep in iter_entry_points(self.entry_point):
if (ep.name == name):
self.converters[ep.name] = ep.load()()
return self.converters[ep.name]
for ep in (EntryPoint.parse(c) for c in (self.registered_converters +... |
'Load a converter'
| def __setitem__(self, name, converter):
| self.converters[name] = converter
|
'Unload a converter'
| def __delitem__(self, name):
| del self.converters[name]
|
'Iterator over loaded converters'
| def __iter__(self):
| return iter(self.converters)
|
'Register a converter
:param string entry_point: converter to register (entry point syntax)
:raise: ValueError if already registered'
| def register(self, entry_point):
| if (entry_point in self.registered_converters):
raise ValueError('Already registered')
self.registered_converters.insert(0, entry_point)
|
'Unregister a converter
:param string entry_point: converter to unregister (entry point syntax)'
| def unregister(self, entry_point):
| self.registered_converters.remove(entry_point)
|
'Create a :class:`Country` by its `code` using `converter` to
:meth:`~babelfish.converters.CountryReverseConverter.reverse` it
:param string code: the code to reverse
:param string converter: name of the :class:`~babelfish.converters.CountryReverseConverter` to use
:return: the corresponding :class:`Country` instance
:... | @classmethod
def fromcode(cls, code, converter):
| return cls(country_converters[converter].reverse(code))
|
'once lock is aquired we can configure the connection for
this particular instance of DBConnection'
| def _set_row_factory(self):
| if (self.row_type == u'dict'):
self.connection.row_factory = DBConnection._dict_factory
else:
self.connection.row_factory = sqlite3.Row
|
'Executes DB query
:param query: Query to execute
:param args: Arguments in query
:param fetchall: Boolean to indicate all results must be fetched
:param fetchone: Boolean to indicate one result must be fetched (to walk results for instance)
:return: query results'
| def _execute(self, query, args=None, fetchall=False, fetchone=False):
| try:
if (not args):
sql_results = self.connection.cursor().execute(query)
else:
sql_results = self.connection.cursor().execute(query, args)
if fetchall:
return sql_results.fetchall()
elif fetchone:
return sql_results.fetchone()
... |
'Fetch major database version
:return: Integer indicating current DB major version'
| def checkDBVersion(self):
| if self.hasColumn(u'db_version', u'db_minor_version'):
warnings.warn(u'Deprecated: Use the version property', DeprecationWarning)
return self.check_db_major_version()
|
'Fetch database version
:return: Integer inidicating current DB version'
| def check_db_major_version(self):
| result = None
try:
if self.hasTable(u'db_version'):
result = self.select(u'SELECT db_version FROM db_version')
except Exception:
return 0
if result:
return int(result[0]['db_version'])
else:
return 0
|
'Fetch database version
:return: Integer inidicating current DB major version'
| def check_db_minor_version(self):
| result = None
try:
if self.hasColumn(u'db_version', u'db_minor_version'):
result = self.select(u'SELECT db_minor_version FROM db_version')
except Exception:
return 0
if result:
return int(result[0]['db_minor_version'])
else:
return 0
|
'The database version
:return: A tuple containing the major and minor versions'
| @property
def version(self):
| return (self.check_db_major_version(), self.check_db_minor_version())
|
'Execute multiple queries
:param querylist: list of queries
:param logTransaction: Boolean to wrap all in one transaction
:param fetchall: Boolean, when using a select query force returning all results
:return: list of results'
| def mass_action(self, querylist=None, logTransaction=False, fetchall=False):
| assert hasattr(querylist, u'__iter__'), u'You passed a non-iterable to mass_action: {0!r}'.format(querylist)
querylist = [i for i in querylist if i]
sql_results = []
attempt = 0
with db_locks[self.filename]:
self._set_row_factory()
while (attempt < 5):
t... |
'Execute single query
:param query: Query string
:param args: Arguments to query string
:param fetchall: Boolean to indicate all results must be fetched
:param fetchone: Boolean to indicate one result must be fetched (to walk results for instance)
:return: query results'
| def action(self, query, args=None, fetchall=False, fetchone=False):
| if (query is None):
return
sql_results = None
attempt = 0
with db_locks[self.filename]:
self._set_row_factory()
while (attempt < 5):
try:
if (args is None):
logger.log(((self.filename + u': ') + query), logger.DB)
... |
'Perform single select query on database
:param query: query string
:param args: arguments to query string
:return: query results'
| def select(self, query, args=None):
| sql_results = self.action(query, args, fetchall=True)
if (sql_results is None):
return []
return sql_results
|
'Perform single select query on database, returning one result
:param query: query string
:param args: arguments to query string
:return: query results'
| def selectOne(self, query, args=None):
| sql_results = self.action(query, args, fetchone=True)
if (sql_results is None):
return []
return sql_results
|
'Update values, or if no updates done, insert values
TODO: Make this return true/false on success/error
:param tableName: table to update/insert
:param valueDict: values in table to update/insert
:param keyDict: columns in table to update/insert'
| def upsert(self, tableName, valueDict, keyDict):
| changesBefore = self.connection.total_changes
def genParams(my_dict):
return [(x + u' = ?') for x in my_dict.keys()]
query = (((((u'UPDATE [' + tableName) + u'] SET ') + u', '.join(genParams(valueDict))) + u' WHERE ') + u' AND '.join(genParams(keyDict)))
self.action... |
'Return information on a database table
:param tableName: name of table
:return: array of name/type info'
| def tableInfo(self, tableName):
| sql_results = self.select(u'PRAGMA table_info(`{0}`)'.format(tableName))
columns = {}
for column in sql_results:
columns[column['name']] = {u'type': column['type']}
return columns
|
'Convert text to six.text_type
:param x: text to parse
:return: six.text_type result'
| @staticmethod
def _unicode_text_factory(x):
| try:
return six.text_type(x, u'utf-8')
except Exception:
return six.text_type(x, sickbeard.SYS_ENCODING, errors=u'ignore')
|
'Check if a table exists in database
:param tableName: table name to check
:return: True if table exists, False if it does not'
| def hasTable(self, tableName):
| return (len(self.select(u'SELECT 1 FROM sqlite_master WHERE name = ?;', (tableName,))) > 0)
|
'Check if a table has a column
:param tableName: Table to check
:param column: Column to check for
:return: True if column exists, False if it does not'
| def hasColumn(self, tableName, column):
| return (column in self.tableInfo(tableName))
|
'Adds a column to a table, default column type is NUMERIC
TODO: Make this return true/false on success/failure
:param table: Table to add column too
:param column: Column name to add
:param type: Column type to add
:param default: Default value for column'
| def addColumn(self, table, column, col_type=u'NUMERIC', default=0):
| self.action(u'ALTER TABLE [{0}] ADD {1} {2}'.format(table, column, col_type))
self.action(u'UPDATE [{0}] SET {1} = ?'.format(table, column), (default,))
|
'calls the appropriate CMD class
looks for a cmd in args and kwargs
or calls the TVDBShorthandWrapper when the first args element is a number
or returns an error that there is no such cmd'
| def call_dispatcher(self, args, kwargs):
| logger.log(((u"API :: all args: '" + str(args)) + u"'"), logger.DEBUG)
logger.log(((u"API :: all kwargs: '" + str(kwargs)) + u"'"), logger.DEBUG)
commands = None
if args:
(commands, args) = (args[0], args[1:])
commands = kwargs.pop(u'cmd', commands)
out_dict = {}
... |
'return only params kwargs that are for cmd
and rename them to a clean version (remove "<cmd>_")
args are shared across all commands
all args and kwargs are lowered
cmd are separated by "|" e.g. &cmd=shows|future
kwargs are name-spaced with "." e.g. show.indexerid=101501
if a kwarg has no namespace asking it anyways (g... | @staticmethod
def filter_params(cmd, args, kwargs):
| cur_args = []
for arg in args:
cur_args.append(arg.lower())
cur_args = tuple(cur_args)
cur_kwargs = {}
for kwarg in kwargs:
if (kwarg.find((cmd + u'.')) == 0):
clean_key = kwarg.rpartition(u'.')[2]
cur_kwargs[clean_key] = kwargs[kwarg].lower()
elif (u'... |
'function to check passed params for the shorthand wrapper
and to detect missing/required params'
| def check_params(self, args, kwargs, key=None, default=None, required=None, arg_type=None, allowed_values=None):
| if (key in indexer_ids):
if (u'tvdbid' in kwargs):
key = u'tvdbid'
self.indexer = indexer_ids.index(key)
if key:
missing = True
org_default = default
if (arg_type == u'bool'):
allowed_values = [0, 1]
if args:
default = args[0]
... |
'checks if value can be converted / parsed to arg_type
will raise an error on failure
or will convert it to arg_type and return new converted value
can check for:
- int: will be converted into int
- bool: will be converted to False / True
- list: will always return a list
- string: will do nothing for now
- ignore: wil... | @staticmethod
def _check_param_type(value, name, arg_type):
| error = False
if (arg_type == u'int'):
if _is_int(value):
value = int(value)
else:
error = True
elif (arg_type == u'bool'):
if (value in (u'0', u'1')):
value = bool(int(value))
elif (value in (u'true', u'True', u'TRUE')):
value ... |
'will check if value (or all values in it ) are in allowed values
will raise an exception if value is "out of range"
if bool(allowed_value) is False a check is not performed and all values are excepted'
| @staticmethod
def _check_param_value(value, name, allowed_values):
| if allowed_values:
error = False
if isinstance(value, list):
for item in value:
if (item not in allowed_values):
error = True
elif (value not in allowed_values):
error = True
if error:
raise ApiError(((((((u"para... |
'internal function wrapper'
| def run(self):
| args = ((self.sid,) + self.origArgs)
if self.e:
return CMDEpisode(args, self.kwargs).run()
elif self.s:
return CMDShowSeasons(args, self.kwargs).run()
else:
return CMDShow(args, self.kwargs).run()
|
'Get help about a given command'
| def run(self):
| if (self.subject in function_mapper):
out = _responds(RESULT_SUCCESS, function_mapper.get(self.subject)((), {u'help': 1}).run())
else:
out = _responds(RESULT_FAILURE, msg=u'No such cmd')
return out
|
'Get the coming episodes'
| def run(self):
| grouped_coming_episodes = ComingEpisodes.get_coming_episodes(self.type, self.sort, True, self.paused)
data = {section: [] for section in grouped_coming_episodes.keys()}
for (section, coming_episodes) in six.iteritems(grouped_coming_episodes):
for coming_episode in coming_episodes:
data[s... |
'Get detailed information about an episode'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
main_db_con = db.DBConnection(row_type=u'dict')
sql_results = main_db_con.select(u'SELECT name, description, airdate, status, location, ... |
'Search for an episode'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
ep_obj = show_obj.getEpisode(self.s, self.e)
if isinstance(ep_obj, str):
return _responds(RESULT_FAILURE, msg=u'Episode not found')
ep_... |
'Set the status of an episode or a season (when no episode is provided)'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
for status in statusStrings:
if (str(statusStrings[status]).lower() == str(self.status).lower()):
self.status = status
break
... |
'Search for an episode subtitles'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
ep_obj = show_obj.getEpisode(self.s, self.e)
if isinstance(ep_obj, str):
return _responds(RESULT_FAILURE, msg=u'Episode not found')
try... |
'Get the scene exceptions for all or a given show'
| def run(self):
| cache_db_con = db.DBConnection(u'cache.db', row_type=u'dict')
if (self.indexerid is None):
sql_results = cache_db_con.select(u"SELECT show_name, indexer_id AS 'indexerid' FROM scene_exceptions")
scene_exceptions = {}
for row in sql_results:
indexerid = row['... |
'Get the downloaded and/or snatched history'
| def run(self):
| data = History().get(self.limit, self.type)
results = []
for row in data:
(status, quality) = Quality.splitCompositeStatus(int(row['action']))
status = _get_status_strings(status)
if (self.type and (not (status.lower() == self.type))):
continue
row['status'] = sta... |
'Clear the entire history'
| def run(self):
| History().clear()
return _responds(RESULT_SUCCESS, msg=u'History cleared')
|
'Trim history entries older than 30 days'
| def run(self):
| History().trim()
return _responds(RESULT_SUCCESS, msg=u'Removed history entries older than 30 days')
|
'Get the failed downloads'
| def run(self):
| failed_db_con = db.DBConnection(u'failed.db', row_type=u'dict')
u_limit = min(int(self.limit), 100)
if (u_limit == 0):
sql_results = failed_db_con.select(u'SELECT * FROM failed')
else:
sql_results = failed_db_con.select(u'SELECT * FROM failed LIMIT ?', [u_limit])
... |
'Get the backlogged episodes'
| def run(self):
| shows = []
main_db_con = db.DBConnection(row_type=u'dict')
for curShow in sickbeard.showList:
show_eps = []
sql_results = main_db_con.select(u'SELECT tv_episodes.*, tv_shows.paused FROM tv_episodes INNER JOIN tv_shows ON tv_episodes.showid = tv_shows.indexer_... |
'Get the logs'
| def run(self):
| min_level = logger.LOGGING_LEVELS[str(self.min_level).upper()]
data = []
if ek(os.path.isfile, logger.log_file):
with io.open(logger.log_file, u'r', encoding=u'utf-8') as f:
data = f.readlines()
regex = u'^(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)\\s*(\\d\\d)\\:(\\d\\d):(\\d\\d)\\s*([A-Z]... |
'Clear the logs'
| def run(self):
| if (self.level == u'error'):
msg = u'Error logs cleared'
classes.ErrorViewer.clear()
elif (self.level == u'warning'):
msg = u'Warning logs cleared'
classes.WarningViewer.clear()
else:
return _responds(RESULT_FAILURE, msg=u'Unknown log level: {0}'.... |
'Manually post-process the files in the download folder'
| def run(self):
| if ((not self.path) and (not sickbeard.TV_DOWNLOAD_DIR)):
return _responds(RESULT_FAILURE, msg=u'You need to provide a path or set TV Download Dir')
if (not self.path):
self.path = sickbeard.TV_DOWNLOAD_DIR
if (not self.type):
self.type = u'manual'
d... |
'dGet miscellaneous information about SickRage'
| def run(self):
| data = {u'sr_version': sickbeard.BRANCH, u'api_version': self.version, u'api_commands': sorted(function_mapper.keys())}
return _responds(RESULT_SUCCESS, data)
|
'Add a new root (parent) directory to SickRage'
| def run(self):
| self.location = urllib.parse.unquote_plus(self.location)
location_matched = 0
index = 0
if (not ek(os.path.isdir, self.location)):
return _responds(RESULT_FAILURE, msg=u'Location is invalid')
root_dirs = []
if (sickbeard.ROOT_DIRS == u''):
self.default = 1
else:
... |
'Get information about the scheduler'
| def run(self):
| main_db_con = db.DBConnection(row_type=u'dict')
sql_results = main_db_con.select(u'SELECT last_backlog FROM info')
backlog_paused = sickbeard.searchQueueScheduler.action.is_backlog_paused()
backlog_running = sickbeard.searchQueueScheduler.action.is_backlog_in_progress()
next_backlog = sickb... |
'Delete a root (parent) directory from SickRage'
| def run(self):
| if (sickbeard.ROOT_DIRS == u''):
return _responds(RESULT_FAILURE, _get_root_dirs(), msg=u'No root directories detected')
new_index = 0
root_dirs_new = []
root_dirs = sickbeard.ROOT_DIRS.split(u'|')
index = int(root_dirs[0])
root_dirs.pop(0)
root_dirs = [urllib.parse.unquote_... |
'Get SickRage\'s user default configuration value'
| def run(self):
| (any_qualities, best_qualities) = _map_quality(sickbeard.QUALITY_DEFAULT)
data = {u'status': statusStrings[sickbeard.STATUS_DEFAULT].lower(), u'flatten_folders': int((not sickbeard.SEASON_FOLDERS_DEFAULT)), u'season_folders': int(sickbeard.SEASON_FOLDERS_DEFAULT), u'initial': any_qualities, u'archive': best_qua... |
'Get all root (parent) directories'
| def run(self):
| return _responds(RESULT_SUCCESS, _get_root_dirs())
|
'Pause or un-pause the backlog search'
| def run(self):
| if self.pause:
sickbeard.searchQueueScheduler.action.pause_backlog()
return _responds(RESULT_SUCCESS, msg=u'Backlog paused')
else:
sickbeard.searchQueueScheduler.action.unpause_backlog()
return _responds(RESULT_SUCCESS, msg=u'Backlog un-paused')
|
'Ping SickRage to check if it is running'
| def run(self):
| if sickbeard.started:
return _responds(RESULT_SUCCESS, {u'pid': sickbeard.PID}, u'Pong')
else:
return _responds(RESULT_SUCCESS, msg=u'Pong')
|
'Restart SickRage'
| def run(self):
| if (not Restart.restart(sickbeard.PID)):
return _responds(RESULT_FAILURE, msg=u'SickRage can not be restarted')
return _responds(RESULT_SUCCESS, msg=u'SickRage is restarting...')
|
'Search for a show with a given name on all the indexers, in a specific language'
| def run(self):
| results = []
lang_id = self.valid_languages[self.lang]
if (self.name and (not self.indexerid)):
for _indexer in (sickbeard.indexerApi().indexers if (self.indexer == 0) else [int(self.indexer)]):
indexer_api_params = sickbeard.indexerApi(_indexer).api_params.copy()
indexer_api... |
'Set SickRage\'s user default configuration value'
| def run(self):
| i_quality_id = []
a_quality_id = []
if self.initial:
for quality in self.initial:
i_quality_id.append(QUALITY_MAP[quality])
if self.archive:
for quality in self.archive:
a_quality_id.append(QUALITY_MAP[quality])
if (i_quality_id or a_quality_id):
sickb... |
'Shutdown SickRage'
| def run(self):
| if (not Shutdown.stop(sickbeard.PID)):
return _responds(RESULT_FAILURE, msg=u'SickRage can not be shut down')
return _responds(RESULT_SUCCESS, msg=u'SickRage is shutting down...')
|
'Get detailed information about a show'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
show_dict = {u'season_list': CMDShowSeasonList((), {u'indexerid': self.indexerid}).run()[u'data'], u'cache': CMDShowCache((), {u'indexerid': self.indexerid})... |
'Add an existing show in SickRage'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if show_obj:
return _responds(RESULT_FAILURE, msg=u'An existing indexerid already exists in the database')
if (not ek(os.path.isdir, self.location)):
return _responds(RESULT_FAILURE, msg=u'Not a valid ... |
'Add a new show to SickRage'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if show_obj:
return _responds(RESULT_FAILURE, msg=u'An existing indexerid already exists in database')
if (not self.location):
if (sickbeard.ROOT_DIRS != u''):
root_dirs = sickbeard.ROOT_DIRS.split(u'... |
'Check SickRage\'s cache to see if the images (poster, banner, fanart) for a show are valid'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
cache_obj = image_cache.ImageCache()
has_poster = 0
has_banner = 0
if ek(os.path.isfile, cache_obj.poster_path(show_obj.indexerid)):
has_... |
'Delete a show in SickRage'
| def run(self):
| (error, show) = Show.delete(self.indexerid, self.removefiles)
if error:
return _responds(RESULT_FAILURE, msg=error)
return _responds(RESULT_SUCCESS, msg=u'{0} has been queued to be deleted'.format(show.name))
|
'Get the quality setting of a show'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
(any_qualities, best_qualities) = _map_quality(show_obj.quality)
return _responds(RESULT_SUCCESS, {u'initial': any_qualities, u'archive': best_qualities}... |
'Get the poster a show'
| def run(self):
| return {u'outputType': u'image', u'image': ShowPoster(self.indexerid, self.media_format)}
|
'Get the banner of a show'
| def run(self):
| return {u'outputType': u'image', u'image': ShowBanner(self.indexerid, self.media_format)}
|
':return: Get the network logo of a show'
| def run(self):
| return {u'outputType': u'image', u'image': ShowNetworkLogo(self.indexerid)}
|
'Get the fan art of a show'
| def run(self):
| return {u'outputType': u'image', u'image': ShowFanArt(self.indexerid)}
|
'Pause or un-pause a show'
| def run(self):
| (error, show) = Show.pause(self.indexerid, self.pause)
if error:
return _responds(RESULT_FAILURE, msg=error)
return _responds(RESULT_SUCCESS, msg=u'{0} has been {1}'.format(show.name, (u'resumed', u'paused')[show.paused]))
|
'Refresh a show in SickRage'
| def run(self):
| (error, show) = Show.refresh(self.indexerid)
if error:
return _responds(RESULT_FAILURE, msg=error)
return _responds(RESULT_SUCCESS, msg=u'{0} has queued to be refreshed'.format(show.name))
|
'Get the list of seasons of a show'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
main_db_con = db.DBConnection(row_type=u'dict')
if (self.sort == u'asc'):
sql_results = main_db_con.select(u'SELECT DISTINCT season FROM... |
'Get the list of episodes for one or all seasons of a show'
| def run(self):
| sho_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not sho_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
main_db_con = db.DBConnection(row_type=u'dict')
if (self.season is None):
sql_results = main_db_con.select(u'SELECT name, episode, airdate... |
'Set the quality setting of a show. If no quality is provided, the default user setting is used.'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
new_quality = int(sickbeard.QUALITY_DEFAULT)
i_quality_id = []
a_quality_id = []
if self.initial:
for quality in self.initial:
... |
'Get episode statistics for a given show'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
episode_status_counts_total = {u'total': 0}
for status in statusStrings:
if (status in [UNKNOWN, DOWNLOADED, SNATCHED, SNATCHED_PROPER, ARCHIVED]... |
'Update a show in SickRage'
| def run(self):
| show_obj = Show.find(sickbeard.showList, int(self.indexerid))
if (not show_obj):
return _responds(RESULT_FAILURE, msg=u'Show not found')
try:
sickbeard.showQueueScheduler.action.update_show(show_obj, True)
return _responds(RESULT_SUCCESS, msg=(str(show_obj.name) + u' has ... |
'Get all shows in SickRage'
| def run(self):
| shows = {}
for curShow in sickbeard.showList:
if ((self.paused is not None) and (self.paused != curShow.paused)):
continue
indexer_show = helpers.mapIndexersToShow(curShow)
show_dict = {u'paused': (0, 1)[curShow.paused], u'quality': get_quality_string(curShow.quality), u'lang... |
'Get the global shows and episodes statistics'
| def run(self):
| stats = Show.overall_stats()
return _responds(RESULT_SUCCESS, {u'ep_downloaded': stats[u'episodes'][u'downloaded'], u'ep_snatched': stats[u'episodes'][u'snatched'], u'ep_total': stats[u'episodes'][u'total'], u'shows_active': stats[u'shows'][u'active'], u'shows_total': stats[u'shows'][u'total']})
|
'Creates a new post processor with the given file path and optionally an NZB name.
file_path: The path to the file to be processed
nzb_name: The name of the NZB which resulted in this file being downloaded (optional)'
| def __init__(self, file_path, nzb_name=None, process_method=None, is_priority=None):
| self.folder_path = ek(os.path.dirname, ek(os.path.abspath, file_path))
self.file_path = file_path
self.file_name = ek(os.path.basename, file_path)
self.folder_name = ek(os.path.basename, self.folder_path)
self.nzb_name = nzb_name
self.process_method = (process_method if process_method else sickb... |
'A wrapper for the internal logger which also keeps track of messages and saves them to a string for later.
:param message: The string to log (six.text_type)
:param level: The log level to use (optional)'
| def _log(self, message, level=logger.INFO):
| logger.log(message, level)
self.log += (message + u'\n')
|
'Checks if a file exists already and if it does whether it\'s bigger or smaller than
the file we are post processing
;param existing_file: The file to compare to
:return:
DOESNT_EXIST if the file doesn\'t exist
EXISTS_LARGER if the file exists and is larger than the file we are post processing
EXISTS_SMALLER if the fil... | def _checkForExistingFile(self, existing_file):
| if (not existing_file):
self._log(u"There is no existing file so there's no worries about replacing it", logger.DEBUG)
return PostProcessor.DOESNT_EXIST
if ek(os.path.isfile, existing_file):
if (ek(os.path.getsize, existing_file) > ek(os.path.getsize, sel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.