def _format_dependency(dep_info): lines = [] if 'version' not in dep_info: lines.append('%s: not found' % dep_info['name']) else: if 'path' in dep_info: source = ' from %s' % dep_info['path'] else: source = '' lines.append('%s: %s%s' % ( dep_info['name'], dep_info['version'], source, )) if 'other' in dep_info: lines.append(' Detailed information: %s' % ( formatting.indent(dep_info['other'], places=4)),) if dep_info.get('dependencies', []): for sub_dep_info in dep_info['dependencies']: sub_dep_lines = _format_dependency(sub_dep_info) lines.append( formatting.indent(sub_dep_lines, places=2, singles=True)) return '\n'.join(lines)
def _format_dependency(dep_info): lines = [] if 'version' not in dep_info: lines.append('%s: not found' % dep_info['name']) else: if 'path' in dep_info: source = ' from %s' % dep_info['path'] else: source = '' lines.append('%s: %s%s' % ( dep_info['name'], dep_info['version'], source, )) if 'other' in dep_info: lines.append( ' Detailed information: %s' % (formatting.indent(dep_info['other'], places=4)), ) if dep_info.get('dependencies', []): for sub_dep_info in dep_info['dependencies']: sub_dep_lines = _format_dependency(sub_dep_info) lines.append( formatting.indent(sub_dep_lines, places=2, singles=True)) return '\n'.join(lines)
def format_settings_list(settings): errors = settings.get_errors() lines = [] for (key, value) in sorted(settings.current.iteritems()): default_value = settings.default.get(key) masked_value = mask_value_if_secret(key, value) lines.append('%s: %s' % ( key, formatting.indent(pprint.pformat(masked_value), places=2))) if value != default_value and default_value is not None: lines.append( ' Default: %s' % formatting.indent(pprint.pformat(default_value), places=4)) if errors.get(key) is not None: lines.append(' Error: %s' % errors[key]) return '\n'.join(lines)
def validate(self, interactive): if interactive: self._read_missing_settings_from_stdin(self.current, self.runtime) if self.get_errors(): logger.error('Settings validation errors: %s', formatting.indent(self.get_errors_as_string())) raise exceptions.SettingsError('Settings validation failed.')
def validate(self, interactive): if interactive: self._read_missing_settings_from_stdin(self.current, self.runtime) if self.get_errors(): logger.error( 'Settings validation errors: %s', formatting.indent(self.get_errors_as_string())) raise exceptions.SettingsError('Settings validation failed.')
def on_line_received(self, line): logger.debug("Request from [%s]:%s: %s", self.host, self.port, line) response = self.dispatcher.handle_request(line) if not response: return logger.debug("Response to [%s]:%s: %s", self.host, self.port, formatting.indent(self.terminator.join(response))) self.send_lines(response)
def on_line_received(self, line): logger.debug('Request from [%s]:%s: %s', self.host, self.port, line) response = self.dispatcher.handle_request(line) if not response: return logger.debug('Response to [%s]:%s: %s', self.host, self.port, formatting.indent(self.terminator.join(response))) self.send_lines(response)
def _get_request_handlers(self): request_handlers = [] request_handlers.extend(self._get_app_request_handlers()) request_handlers.extend(self._get_static_request_handlers()) request_handlers.extend(self._get_mopidy_request_handlers()) logger.debug( "HTTP routes from extensions: %s", formatting.indent("\n".join("%r: %r" % (r[0], r[1]) for r in request_handlers)), ) return request_handlers
def _get_request_handlers(self): request_handlers = [] request_handlers.extend(self._get_app_request_handlers()) request_handlers.extend(self._get_static_request_handlers()) request_handlers.extend(self._get_mopidy_request_handlers()) logger.debug( 'HTTP routes from extensions: %s', formatting.indent('\n'.join('%r: %r' % (r[0], r[1]) for r in request_handlers))) return request_handlers
def _get_request_handlers(self): request_handlers = [] request_handlers.extend(self._get_app_request_handlers()) request_handlers.extend(self._get_static_request_handlers()) request_handlers.extend(self._get_mopidy_request_handlers()) logger.debug( 'HTTP routes from extensions: %s', formatting.indent('\n'.join( '%r: %r' % (r[0], r[1]) for r in request_handlers))) return request_handlers
def on_line_received(self, line): logger.debug('Request from [%s]:%s: %s', self.host, self.port, line) if self.special: match = self.addid.match(line) if match is not None: line = 'addid "'+self.special+'"' dictator_res = self.dictator_filter(line, self.host) if dictator_res is not True: self.send_lines(dictator_res) return response = self.dispatcher.handle_request(line) if not response: return logger.debug( 'Response to [%s]:%s: %s', self.host, self.port, formatting.indent(self.terminator.join(response))) self.send_lines(response)
def on_line_received(self, line): logger.info('Request from [%s]:%s: %s', self.host, self.port, line) tokens = line.split(' ') response = ['ERROR_OK'] if (len(tokens) == 2 and tokens[0] == 'SUBSCRIBE'): port = int(tokens[1]) host = self.host.split(':')[-1] ret = self.backend._start_rtp_session(host, port) if (not ret): response = ['ERROR_SUBSCRIBER_LIMIT_REACHED'] elif (len(tokens) == 2 and tokens[0] == 'UNSUBSCRIBE'): port = int(tokens[1]) self.backend._stop_rtp_session(self.host, port) else: response = ['ERROR_UNRECOGNIZED_COMMAND'] logger.debug( 'Response to [%s]:%s: %s', self.host, self.port, formatting.indent(self.terminator.join(response))) self.send_lines(response)
def decorator(func): match = re.search('([a-z_]+)', pattern) if match is not None: mpd_commands.add( MpdCommand(name=match.group(), auth_required=auth_required)) compiled_pattern = re.compile(pattern, flags=(re.UNICODE | re.VERBOSE)) if compiled_pattern in request_handlers: raise ValueError('Tried to redefine handler for %s with %s' % ( pattern, func)) request_handlers[compiled_pattern] = func func.__doc__ = """ *Pattern:* .. code-block:: text %(pattern)s %(docs)s """ % { 'pattern': formatting.indent(pattern, places=8, singles=True), 'docs': func.__doc__ or '', } return func