repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
dswah/pyGAM
pygam/terms.py
TermList.info
def info(self): """get information about the terms in the term list Parameters ---------- Returns ------- dict containing information to duplicate the term list """ info = {'term_type': 'term_list', 'verbose': self.verbose} info.update({'terms':[...
python
def info(self): """get information about the terms in the term list Parameters ---------- Returns ------- dict containing information to duplicate the term list """ info = {'term_type': 'term_list', 'verbose': self.verbose} info.update({'terms':[...
[ "def", "info", "(", "self", ")", ":", "info", "=", "{", "'term_type'", ":", "'term_list'", ",", "'verbose'", ":", "self", ".", "verbose", "}", "info", ".", "update", "(", "{", "'terms'", ":", "[", "term", ".", "info", "for", "term", "in", "self", "...
get information about the terms in the term list Parameters ---------- Returns ------- dict containing information to duplicate the term list
[ "get", "information", "about", "the", "terms", "in", "the", "term", "list" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/terms.py#L1572-L1584
train
dswah/pyGAM
pygam/terms.py
TermList.build_from_info
def build_from_info(cls, info): """build a TermList instance from a dict Parameters ---------- cls : class info : dict contains all information needed to build the term Return ------ TermList instance """ info = deepcopy(info...
python
def build_from_info(cls, info): """build a TermList instance from a dict Parameters ---------- cls : class info : dict contains all information needed to build the term Return ------ TermList instance """ info = deepcopy(info...
[ "def", "build_from_info", "(", "cls", ",", "info", ")", ":", "info", "=", "deepcopy", "(", "info", ")", "terms", "=", "[", "]", "for", "term_info", "in", "info", "[", "'terms'", "]", ":", "terms", ".", "append", "(", "Term", ".", "build_from_info", "...
build a TermList instance from a dict Parameters ---------- cls : class info : dict contains all information needed to build the term Return ------ TermList instance
[ "build", "a", "TermList", "instance", "from", "a", "dict" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/terms.py#L1587-L1605
train
dswah/pyGAM
pygam/terms.py
TermList.pop
def pop(self, i=None): """remove the ith term from the term list Parameters --------- i : int, optional term to remove from term list by default the last term is popped. Returns ------- term : Term """ if i == None: ...
python
def pop(self, i=None): """remove the ith term from the term list Parameters --------- i : int, optional term to remove from term list by default the last term is popped. Returns ------- term : Term """ if i == None: ...
[ "def", "pop", "(", "self", ",", "i", "=", "None", ")", ":", "if", "i", "==", "None", ":", "i", "=", "len", "(", "self", ")", "-", "1", "if", "i", ">=", "len", "(", "self", ".", "_terms", ")", "or", "i", "<", "0", ":", "raise", "ValueError",...
remove the ith term from the term list Parameters --------- i : int, optional term to remove from term list by default the last term is popped. Returns ------- term : Term
[ "remove", "the", "ith", "term", "from", "the", "term", "list" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/terms.py#L1632-L1655
train
dswah/pyGAM
pygam/terms.py
TermList.get_coef_indices
def get_coef_indices(self, i=-1): """get the indices for the coefficients of a term in the term list Parameters --------- i : int by default `int=-1`, meaning that coefficient indices are returned for all terms in the term list Returns ------- ...
python
def get_coef_indices(self, i=-1): """get the indices for the coefficients of a term in the term list Parameters --------- i : int by default `int=-1`, meaning that coefficient indices are returned for all terms in the term list Returns ------- ...
[ "def", "get_coef_indices", "(", "self", ",", "i", "=", "-", "1", ")", ":", "if", "i", "==", "-", "1", ":", "return", "list", "(", "range", "(", "self", ".", "n_coefs", ")", ")", "if", "i", ">=", "len", "(", "self", ".", "_terms", ")", ":", "r...
get the indices for the coefficients of a term in the term list Parameters --------- i : int by default `int=-1`, meaning that coefficient indices are returned for all terms in the term list Returns ------- list of integers
[ "get", "the", "indices", "for", "the", "coefficients", "of", "a", "term", "in", "the", "term", "list" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/terms.py#L1672-L1696
train
thoughtworksarts/EmoPy
EmoPy/src/csv_data_loader.py
CSVDataLoader.load_data
def load_data(self): """ Loads image and label data from specified csv file path. :return: Dataset object containing image and label data. """ print('Extracting training data from csv...') images = list() labels = list() emotion_index_map = dict() ...
python
def load_data(self): """ Loads image and label data from specified csv file path. :return: Dataset object containing image and label data. """ print('Extracting training data from csv...') images = list() labels = list() emotion_index_map = dict() ...
[ "def", "load_data", "(", "self", ")", ":", "print", "(", "'Extracting training data from csv...'", ")", "images", "=", "list", "(", ")", "labels", "=", "list", "(", ")", "emotion_index_map", "=", "dict", "(", ")", "with", "open", "(", "self", ".", "datapat...
Loads image and label data from specified csv file path. :return: Dataset object containing image and label data.
[ "Loads", "image", "and", "label", "data", "from", "specified", "csv", "file", "path", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/csv_data_loader.py#L26-L54
train
thoughtworksarts/EmoPy
EmoPy/src/data_loader.py
_DataLoader._load_dataset
def _load_dataset(self, images, labels, emotion_index_map): """ Loads Dataset object with images, labels, and other data. :param images: numpy array of image data :param labels: numpy array of one-hot vector labels :param emotion_index_map: map linking string/integer emotion cla...
python
def _load_dataset(self, images, labels, emotion_index_map): """ Loads Dataset object with images, labels, and other data. :param images: numpy array of image data :param labels: numpy array of one-hot vector labels :param emotion_index_map: map linking string/integer emotion cla...
[ "def", "_load_dataset", "(", "self", ",", "images", ",", "labels", ",", "emotion_index_map", ")", ":", "train_images", ",", "test_images", ",", "train_labels", ",", "test_labels", "=", "train_test_split", "(", "images", ",", "labels", ",", "test_size", "=", "s...
Loads Dataset object with images, labels, and other data. :param images: numpy array of image data :param labels: numpy array of one-hot vector labels :param emotion_index_map: map linking string/integer emotion class to integer index used in labels vectors :return: Dataset object cont...
[ "Loads", "Dataset", "object", "with", "images", "labels", "and", "other", "data", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/data_loader.py#L27-L39
train
thoughtworksarts/EmoPy
EmoPy/src/directory_data_loader.py
DirectoryDataLoader.load_data
def load_data(self): """ Loads image and label data from specified directory path. :return: Dataset object containing image and label data. """ images = list() labels = list() emotion_index_map = dict() label_directories = [dir for dir in os.listdir(self....
python
def load_data(self): """ Loads image and label data from specified directory path. :return: Dataset object containing image and label data. """ images = list() labels = list() emotion_index_map = dict() label_directories = [dir for dir in os.listdir(self....
[ "def", "load_data", "(", "self", ")", ":", "images", "=", "list", "(", ")", "labels", "=", "list", "(", ")", "emotion_index_map", "=", "dict", "(", ")", "label_directories", "=", "[", "dir", "for", "dir", "in", "os", ".", "listdir", "(", "self", ".",...
Loads image and label data from specified directory path. :return: Dataset object containing image and label data.
[ "Loads", "image", "and", "label", "data", "from", "specified", "directory", "path", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/directory_data_loader.py#L23-L47
train
thoughtworksarts/EmoPy
EmoPy/src/directory_data_loader.py
DirectoryDataLoader._check_directory_arguments
def _check_directory_arguments(self): """ Validates arguments for loading from directories, including static image and time series directories. """ if not os.path.isdir(self.datapath): raise (NotADirectoryError('Directory does not exist: %s' % self.datapath)) if self....
python
def _check_directory_arguments(self): """ Validates arguments for loading from directories, including static image and time series directories. """ if not os.path.isdir(self.datapath): raise (NotADirectoryError('Directory does not exist: %s' % self.datapath)) if self....
[ "def", "_check_directory_arguments", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "datapath", ")", ":", "raise", "(", "NotADirectoryError", "(", "'Directory does not exist: %s'", "%", "self", ".", "datapath", ")", ")...
Validates arguments for loading from directories, including static image and time series directories.
[ "Validates", "arguments", "for", "loading", "from", "directories", "including", "static", "image", "and", "time", "series", "directories", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/directory_data_loader.py#L86-L96
train
thoughtworksarts/EmoPy
EmoPy/src/fermodel.py
FERModel.predict
def predict(self, image_file): """ Predicts discrete emotion for given image. :param images: image file (jpg or png format) """ image = misc.imread(image_file) gray_image = image if len(image.shape) > 2: gray_image = cv2.cvtColor(image, code=cv2.COLOR...
python
def predict(self, image_file): """ Predicts discrete emotion for given image. :param images: image file (jpg or png format) """ image = misc.imread(image_file) gray_image = image if len(image.shape) > 2: gray_image = cv2.cvtColor(image, code=cv2.COLOR...
[ "def", "predict", "(", "self", ",", "image_file", ")", ":", "image", "=", "misc", ".", "imread", "(", "image_file", ")", "gray_image", "=", "image", "if", "len", "(", "image", ".", "shape", ")", ">", "2", ":", "gray_image", "=", "cv2", ".", "cvtColor...
Predicts discrete emotion for given image. :param images: image file (jpg or png format)
[ "Predicts", "discrete", "emotion", "for", "given", "image", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/fermodel.py#L47-L62
train
thoughtworksarts/EmoPy
EmoPy/src/fermodel.py
FERModel._check_emotion_set_is_supported
def _check_emotion_set_is_supported(self): """ Validates set of user-supplied target emotions. """ supported_emotion_subsets = [ set(['anger', 'fear', 'surprise', 'calm']), set(['happiness', 'disgust', 'surprise']), set(['anger', 'fear', 'surprise']), ...
python
def _check_emotion_set_is_supported(self): """ Validates set of user-supplied target emotions. """ supported_emotion_subsets = [ set(['anger', 'fear', 'surprise', 'calm']), set(['happiness', 'disgust', 'surprise']), set(['anger', 'fear', 'surprise']), ...
[ "def", "_check_emotion_set_is_supported", "(", "self", ")", ":", "supported_emotion_subsets", "=", "[", "set", "(", "[", "'anger'", ",", "'fear'", ",", "'surprise'", ",", "'calm'", "]", ")", ",", "set", "(", "[", "'happiness'", ",", "'disgust'", ",", "'surpr...
Validates set of user-supplied target emotions.
[ "Validates", "set", "of", "user", "-", "supplied", "target", "emotions", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/fermodel.py#L64-L87
train
thoughtworksarts/EmoPy
EmoPy/src/fermodel.py
FERModel._choose_model_from_target_emotions
def _choose_model_from_target_emotions(self): """ Initializes pre-trained deep learning model for the set of target emotions supplied by user. """ model_indices = [self.emotion_index_map[emotion] for emotion in self.target_emotions] sorted_indices = [str(idx) for idx in sorted(mo...
python
def _choose_model_from_target_emotions(self): """ Initializes pre-trained deep learning model for the set of target emotions supplied by user. """ model_indices = [self.emotion_index_map[emotion] for emotion in self.target_emotions] sorted_indices = [str(idx) for idx in sorted(mo...
[ "def", "_choose_model_from_target_emotions", "(", "self", ")", ":", "model_indices", "=", "[", "self", ".", "emotion_index_map", "[", "emotion", "]", "for", "emotion", "in", "self", ".", "target_emotions", "]", "sorted_indices", "=", "[", "str", "(", "idx", ")...
Initializes pre-trained deep learning model for the set of target emotions supplied by user.
[ "Initializes", "pre", "-", "trained", "deep", "learning", "model", "for", "the", "set", "of", "target", "emotions", "supplied", "by", "user", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/fermodel.py#L89-L100
train
thoughtworksarts/EmoPy
EmoPy/library/image.py
apply_transform
def apply_transform(sample, transform_matrix, channel_axis=0, fill_mode='nearest', cval=0.): """Apply the image transformation specified by a matrix. # Arguments sample: 2D numpy array, single sample. transform_matr...
python
def apply_transform(sample, transform_matrix, channel_axis=0, fill_mode='nearest', cval=0.): """Apply the image transformation specified by a matrix. # Arguments sample: 2D numpy array, single sample. transform_matr...
[ "def", "apply_transform", "(", "sample", ",", "transform_matrix", ",", "channel_axis", "=", "0", ",", "fill_mode", "=", "'nearest'", ",", "cval", "=", "0.", ")", ":", "if", "sample", ".", "ndim", "==", "4", ":", "channel_axis", "=", "channel_axis", "-", ...
Apply the image transformation specified by a matrix. # Arguments sample: 2D numpy array, single sample. transform_matrix: Numpy array specifying the geometric transformation. channel_axis: Index of axis for channels in the input tensor. fill_mode: Points outside the boundaries of t...
[ "Apply", "the", "image", "transformation", "specified", "by", "a", "matrix", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/library/image.py#L75-L101
train
thoughtworksarts/EmoPy
EmoPy/library/image.py
ImageDataGenerator.standardize
def standardize(self, x): """Apply the normalization configuration to a batch of inputs. # Arguments x: batch of inputs to be normalized. # Returns The inputs, normalized. """ if self.preprocessing_function: x = self.preprocessing_function(x)...
python
def standardize(self, x): """Apply the normalization configuration to a batch of inputs. # Arguments x: batch of inputs to be normalized. # Returns The inputs, normalized. """ if self.preprocessing_function: x = self.preprocessing_function(x)...
[ "def", "standardize", "(", "self", ",", "x", ")", ":", "if", "self", ".", "preprocessing_function", ":", "x", "=", "self", ".", "preprocessing_function", "(", "x", ")", "if", "self", ".", "rescale", ":", "x", "*=", "self", ".", "rescale", "if", "self",...
Apply the normalization configuration to a batch of inputs. # Arguments x: batch of inputs to be normalized. # Returns The inputs, normalized.
[ "Apply", "the", "normalization", "configuration", "to", "a", "batch", "of", "inputs", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/library/image.py#L247-L291
train
thoughtworksarts/EmoPy
EmoPy/library/image.py
ImageDataGenerator.fit
def fit(self, x, augment=False, rounds=1, seed=None): """Fits internal statistics to some sample data. Required for featurewise_center, featurewise_std_normalization and zca_whitening. # Arguments x: Numpy array, the data to fit on. Shoul...
python
def fit(self, x, augment=False, rounds=1, seed=None): """Fits internal statistics to some sample data. Required for featurewise_center, featurewise_std_normalization and zca_whitening. # Arguments x: Numpy array, the data to fit on. Shoul...
[ "def", "fit", "(", "self", ",", "x", ",", "augment", "=", "False", ",", "rounds", "=", "1", ",", "seed", "=", "None", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ",", "dtype", "=", "K", ".", "floatx", "(", ")", ")", "if", "x", ".", ...
Fits internal statistics to some sample data. Required for featurewise_center, featurewise_std_normalization and zca_whitening. # Arguments x: Numpy array, the data to fit on. Should have rank 5 or 4 when time_delay is None. In case of grayscale data, ...
[ "Fits", "internal", "statistics", "to", "some", "sample", "data", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/library/image.py#L404-L461
train
thoughtworksarts/EmoPy
EmoPy/library/image.py
NumpyArrayIterator.next
def next(self): """For python 2.x. # Returns The next batch. """ # Keeps under lock only the mechanism which advances # the indexing of each batch. with self.lock: index_array = next(self.index_generator) # The transformation of images is ...
python
def next(self): """For python 2.x. # Returns The next batch. """ # Keeps under lock only the mechanism which advances # the indexing of each batch. with self.lock: index_array = next(self.index_generator) # The transformation of images is ...
[ "def", "next", "(", "self", ")", ":", "# Keeps under lock only the mechanism which advances", "# the indexing of each batch.", "with", "self", ".", "lock", ":", "index_array", "=", "next", "(", "self", ".", "index_generator", ")", "# The transformation of images is not unde...
For python 2.x. # Returns The next batch.
[ "For", "python", "2", ".", "x", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/library/image.py#L625-L637
train
thoughtworksarts/EmoPy
EmoPy/src/neuralnets.py
ConvolutionalLstmNN._init_model
def _init_model(self): """ Composes all layers of CNN. """ model = Sequential() model.add(ConvLSTM2D(filters=self.filters, kernel_size=self.kernel_size, activation=self.activation, input_shape=[self.time_delay] + list(self.image_size) + [self.channels...
python
def _init_model(self): """ Composes all layers of CNN. """ model = Sequential() model.add(ConvLSTM2D(filters=self.filters, kernel_size=self.kernel_size, activation=self.activation, input_shape=[self.time_delay] + list(self.image_size) + [self.channels...
[ "def", "_init_model", "(", "self", ")", ":", "model", "=", "Sequential", "(", ")", "model", ".", "add", "(", "ConvLSTM2D", "(", "filters", "=", "self", ".", "filters", ",", "kernel_size", "=", "self", ".", "kernel_size", ",", "activation", "=", "self", ...
Composes all layers of CNN.
[ "Composes", "all", "layers", "of", "CNN", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/neuralnets.py#L166-L186
train
thoughtworksarts/EmoPy
EmoPy/src/neuralnets.py
ConvolutionalNN._init_model
def _init_model(self): """ Composes all layers of 2D CNN. """ model = Sequential() model.add(Conv2D(input_shape=list(self.image_size) + [self.channels], filters=self.filters, kernel_size=self.kernel_size, activation='relu', data_format='channels_last')) ...
python
def _init_model(self): """ Composes all layers of 2D CNN. """ model = Sequential() model.add(Conv2D(input_shape=list(self.image_size) + [self.channels], filters=self.filters, kernel_size=self.kernel_size, activation='relu', data_format='channels_last')) ...
[ "def", "_init_model", "(", "self", ")", ":", "model", "=", "Sequential", "(", ")", "model", ".", "add", "(", "Conv2D", "(", "input_shape", "=", "list", "(", "self", ".", "image_size", ")", "+", "[", "self", ".", "channels", "]", ",", "filters", "=", ...
Composes all layers of 2D CNN.
[ "Composes", "all", "layers", "of", "2D", "CNN", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/neuralnets.py#L232-L252
train
thoughtworksarts/EmoPy
EmoPy/src/neuralnets.py
TimeDelayConvNN._init_model
def _init_model(self): """ Composes all layers of 3D CNN. """ model = Sequential() model.add(Conv3D(input_shape=[self.time_delay] + list(self.image_size) + [self.channels], filters=self.filters, kernel_size=self.kernel_size, activation='relu', data_format...
python
def _init_model(self): """ Composes all layers of 3D CNN. """ model = Sequential() model.add(Conv3D(input_shape=[self.time_delay] + list(self.image_size) + [self.channels], filters=self.filters, kernel_size=self.kernel_size, activation='relu', data_format...
[ "def", "_init_model", "(", "self", ")", ":", "model", "=", "Sequential", "(", ")", "model", ".", "add", "(", "Conv3D", "(", "input_shape", "=", "[", "self", ".", "time_delay", "]", "+", "list", "(", "self", ".", "image_size", ")", "+", "[", "self", ...
Composes all layers of 3D CNN.
[ "Composes", "all", "layers", "of", "3D", "CNN", "." ]
a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7
https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/neuralnets.py#L300-L320
train
sosreport/sos
sos/plugins/foreman.py
Foreman.build_query_cmd
def build_query_cmd(self, query, csv=False): """ Builds the command needed to invoke the pgsql query as the postgres user. The query requires significant quoting work to satisfy both the shell and postgres parsing requirements. Note that this will generate a large amount ...
python
def build_query_cmd(self, query, csv=False): """ Builds the command needed to invoke the pgsql query as the postgres user. The query requires significant quoting work to satisfy both the shell and postgres parsing requirements. Note that this will generate a large amount ...
[ "def", "build_query_cmd", "(", "self", ",", "query", ",", "csv", "=", "False", ")", ":", "_cmd", "=", "\"su postgres -c %s\"", "if", "not", "csv", ":", "_dbcmd", "=", "\"psql foreman -c %s\"", "else", ":", "_dbcmd", "=", "\"psql foreman -A -F , -X -c %s\"", "dbq...
Builds the command needed to invoke the pgsql query as the postgres user. The query requires significant quoting work to satisfy both the shell and postgres parsing requirements. Note that this will generate a large amount of quoting in sos logs referencing the command being run
[ "Builds", "the", "command", "needed", "to", "invoke", "the", "pgsql", "query", "as", "the", "postgres", "user", ".", "The", "query", "requires", "significant", "quoting", "work", "to", "satisfy", "both", "the", "shell", "and", "postgres", "parsing", "requireme...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/foreman.py#L163-L177
train
sosreport/sos
sos/policies/__init__.py
InitSystem.is_enabled
def is_enabled(self, name): """Check if given service name is enabled """ if self.services and name in self.services: return self.services[name]['config'] == 'enabled' return False
python
def is_enabled(self, name): """Check if given service name is enabled """ if self.services and name in self.services: return self.services[name]['config'] == 'enabled' return False
[ "def", "is_enabled", "(", "self", ",", "name", ")", ":", "if", "self", ".", "services", "and", "name", "in", "self", ".", "services", ":", "return", "self", ".", "services", "[", "name", "]", "[", "'config'", "]", "==", "'enabled'", "return", "False" ]
Check if given service name is enabled
[ "Check", "if", "given", "service", "name", "is", "enabled" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L70-L74
train
sosreport/sos
sos/policies/__init__.py
InitSystem.is_disabled
def is_disabled(self, name): """Check if a given service name is disabled """ if self.services and name in self.services: return self.services[name]['config'] == 'disabled' return False
python
def is_disabled(self, name): """Check if a given service name is disabled """ if self.services and name in self.services: return self.services[name]['config'] == 'disabled' return False
[ "def", "is_disabled", "(", "self", ",", "name", ")", ":", "if", "self", ".", "services", "and", "name", "in", "self", ".", "services", ":", "return", "self", ".", "services", "[", "name", "]", "[", "'config'", "]", "==", "'disabled'", "return", "False"...
Check if a given service name is disabled
[ "Check", "if", "a", "given", "service", "name", "is", "disabled" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L76-L80
train
sosreport/sos
sos/policies/__init__.py
InitSystem._query_service
def _query_service(self, name): """Query an individual service""" if self.query_cmd: try: return sos_get_command_output("%s %s" % (self.query_cmd, name)) except Exception: return None return None
python
def _query_service(self, name): """Query an individual service""" if self.query_cmd: try: return sos_get_command_output("%s %s" % (self.query_cmd, name)) except Exception: return None return None
[ "def", "_query_service", "(", "self", ",", "name", ")", ":", "if", "self", ".", "query_cmd", ":", "try", ":", "return", "sos_get_command_output", "(", "\"%s %s\"", "%", "(", "self", ".", "query_cmd", ",", "name", ")", ")", "except", "Exception", ":", "re...
Query an individual service
[ "Query", "an", "individual", "service" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L106-L113
train
sosreport/sos
sos/policies/__init__.py
InitSystem.get_service_status
def get_service_status(self, name): """Returns the status for the given service name along with the output of the query command """ svc = self._query_service(name) if svc is not None: return {'name': name, 'status': self.parse_query(svc['output']),...
python
def get_service_status(self, name): """Returns the status for the given service name along with the output of the query command """ svc = self._query_service(name) if svc is not None: return {'name': name, 'status': self.parse_query(svc['output']),...
[ "def", "get_service_status", "(", "self", ",", "name", ")", ":", "svc", "=", "self", ".", "_query_service", "(", "name", ")", "if", "svc", "is", "not", "None", ":", "return", "{", "'name'", ":", "name", ",", "'status'", ":", "self", ".", "parse_query",...
Returns the status for the given service name along with the output of the query command
[ "Returns", "the", "status", "for", "the", "given", "service", "name", "along", "with", "the", "output", "of", "the", "query", "command" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L123-L137
train
sosreport/sos
sos/policies/__init__.py
PackageManager.all_pkgs_by_name_regex
def all_pkgs_by_name_regex(self, regex_name, flags=0): """ Return a list of packages that match regex_name. """ reg = re.compile(regex_name, flags) return [pkg for pkg in self.all_pkgs().keys() if reg.match(pkg)]
python
def all_pkgs_by_name_regex(self, regex_name, flags=0): """ Return a list of packages that match regex_name. """ reg = re.compile(regex_name, flags) return [pkg for pkg in self.all_pkgs().keys() if reg.match(pkg)]
[ "def", "all_pkgs_by_name_regex", "(", "self", ",", "regex_name", ",", "flags", "=", "0", ")", ":", "reg", "=", "re", ".", "compile", "(", "regex_name", ",", "flags", ")", "return", "[", "pkg", "for", "pkg", "in", "self", ".", "all_pkgs", "(", ")", "....
Return a list of packages that match regex_name.
[ "Return", "a", "list", "of", "packages", "that", "match", "regex_name", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L210-L215
train
sosreport/sos
sos/policies/__init__.py
PackageManager.pkg_by_name
def pkg_by_name(self, name): """ Return a single package that matches name. """ pkgmatches = self.all_pkgs_by_name(name) if (len(pkgmatches) != 0): return self.all_pkgs_by_name(name)[-1] else: return None
python
def pkg_by_name(self, name): """ Return a single package that matches name. """ pkgmatches = self.all_pkgs_by_name(name) if (len(pkgmatches) != 0): return self.all_pkgs_by_name(name)[-1] else: return None
[ "def", "pkg_by_name", "(", "self", ",", "name", ")", ":", "pkgmatches", "=", "self", ".", "all_pkgs_by_name", "(", "name", ")", "if", "(", "len", "(", "pkgmatches", ")", "!=", "0", ")", ":", "return", "self", ".", "all_pkgs_by_name", "(", "name", ")", ...
Return a single package that matches name.
[ "Return", "a", "single", "package", "that", "matches", "name", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L217-L225
train
sosreport/sos
sos/policies/__init__.py
PackageManager.all_pkgs
def all_pkgs(self): """ Return a list of all packages. """ if not self.packages: self.packages = self.get_pkg_list() return self.packages
python
def all_pkgs(self): """ Return a list of all packages. """ if not self.packages: self.packages = self.get_pkg_list() return self.packages
[ "def", "all_pkgs", "(", "self", ")", ":", "if", "not", "self", ".", "packages", ":", "self", ".", "packages", "=", "self", ".", "get_pkg_list", "(", ")", "return", "self", ".", "packages" ]
Return a list of all packages.
[ "Return", "a", "list", "of", "all", "packages", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L258-L264
train
sosreport/sos
sos/policies/__init__.py
PackageManager.all_files
def all_files(self): """ Returns a list of files known by the package manager """ if self.files_command and not self.files: cmd = self.files_command files = shell_out(cmd, timeout=0, chroot=self.chroot) self.files = files.splitlines() return se...
python
def all_files(self): """ Returns a list of files known by the package manager """ if self.files_command and not self.files: cmd = self.files_command files = shell_out(cmd, timeout=0, chroot=self.chroot) self.files = files.splitlines() return se...
[ "def", "all_files", "(", "self", ")", ":", "if", "self", ".", "files_command", "and", "not", "self", ".", "files", ":", "cmd", "=", "self", ".", "files_command", "files", "=", "shell_out", "(", "cmd", ",", "timeout", "=", "0", ",", "chroot", "=", "se...
Returns a list of files known by the package manager
[ "Returns", "a", "list", "of", "files", "known", "by", "the", "package", "manager" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L272-L280
train
sosreport/sos
sos/policies/__init__.py
PresetDefaults.write
def write(self, presets_path): """Write this preset to disk in JSON notation. :param presets_path: the directory where the preset will be written. """ if self.builtin: raise TypeError("Cannot write built-in preset") # Make dictio...
python
def write(self, presets_path): """Write this preset to disk in JSON notation. :param presets_path: the directory where the preset will be written. """ if self.builtin: raise TypeError("Cannot write built-in preset") # Make dictio...
[ "def", "write", "(", "self", ",", "presets_path", ")", ":", "if", "self", ".", "builtin", ":", "raise", "TypeError", "(", "\"Cannot write built-in preset\"", ")", "# Make dictionaries of PresetDefaults values", "odict", "=", "self", ".", "opts", ".", "dict", "(", ...
Write this preset to disk in JSON notation. :param presets_path: the directory where the preset will be written.
[ "Write", "this", "preset", "to", "disk", "in", "JSON", "notation", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L374-L391
train
sosreport/sos
sos/policies/__init__.py
Policy.get_archive_name
def get_archive_name(self): """ This function should return the filename of the archive without the extension. This uses the policy's name_pattern attribute to determine the name. There are two pre-defined naming patterns - 'legacy' and 'friendly' that give names like th...
python
def get_archive_name(self): """ This function should return the filename of the archive without the extension. This uses the policy's name_pattern attribute to determine the name. There are two pre-defined naming patterns - 'legacy' and 'friendly' that give names like th...
[ "def", "get_archive_name", "(", "self", ")", ":", "name", "=", "self", ".", "get_local_name", "(", ")", ".", "split", "(", "'.'", ")", "[", "0", "]", "case", "=", "self", ".", "case_id", "label", "=", "self", ".", "commons", "[", "'cmdlineopts'", "]"...
This function should return the filename of the archive without the extension. This uses the policy's name_pattern attribute to determine the name. There are two pre-defined naming patterns - 'legacy' and 'friendly' that give names like the following: legacy - 'sosreport-tux.12...
[ "This", "function", "should", "return", "the", "filename", "of", "the", "archive", "without", "the", "extension", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L496-L547
train
sosreport/sos
sos/policies/__init__.py
Policy.validate_plugin
def validate_plugin(self, plugin_class, experimental=False): """ Verifies that the plugin_class should execute under this policy """ valid_subclasses = [IndependentPlugin] + self.valid_subclasses if experimental: valid_subclasses += [ExperimentalPlugin] return...
python
def validate_plugin(self, plugin_class, experimental=False): """ Verifies that the plugin_class should execute under this policy """ valid_subclasses = [IndependentPlugin] + self.valid_subclasses if experimental: valid_subclasses += [ExperimentalPlugin] return...
[ "def", "validate_plugin", "(", "self", ",", "plugin_class", ",", "experimental", "=", "False", ")", ":", "valid_subclasses", "=", "[", "IndependentPlugin", "]", "+", "self", ".", "valid_subclasses", "if", "experimental", ":", "valid_subclasses", "+=", "[", "Expe...
Verifies that the plugin_class should execute under this policy
[ "Verifies", "that", "the", "plugin_class", "should", "execute", "under", "this", "policy" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L591-L599
train
sosreport/sos
sos/policies/__init__.py
Policy._print
def _print(self, msg=None, always=False): """A wrapper around print that only prints if we are not running in quiet mode""" if always or not self.commons['cmdlineopts'].quiet: if msg: print_(msg) else: print_()
python
def _print(self, msg=None, always=False): """A wrapper around print that only prints if we are not running in quiet mode""" if always or not self.commons['cmdlineopts'].quiet: if msg: print_(msg) else: print_()
[ "def", "_print", "(", "self", ",", "msg", "=", "None", ",", "always", "=", "False", ")", ":", "if", "always", "or", "not", "self", ".", "commons", "[", "'cmdlineopts'", "]", ".", "quiet", ":", "if", "msg", ":", "print_", "(", "msg", ")", "else", ...
A wrapper around print that only prints if we are not running in quiet mode
[ "A", "wrapper", "around", "print", "that", "only", "prints", "if", "we", "are", "not", "running", "in", "quiet", "mode" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L671-L678
train
sosreport/sos
sos/policies/__init__.py
Policy.get_msg
def get_msg(self): """This method is used to prepare the preamble text to display to the user in non-batch mode. If your policy sets self.distro that text will be substituted accordingly. You can also override this method to do something more complicated.""" width = 72 _m...
python
def get_msg(self): """This method is used to prepare the preamble text to display to the user in non-batch mode. If your policy sets self.distro that text will be substituted accordingly. You can also override this method to do something more complicated.""" width = 72 _m...
[ "def", "get_msg", "(", "self", ")", ":", "width", "=", "72", "_msg", "=", "self", ".", "msg", "%", "{", "'distro'", ":", "self", ".", "distro", ",", "'vendor'", ":", "self", ".", "vendor", ",", "'vendor_url'", ":", "self", ".", "vendor_url", ",", "...
This method is used to prepare the preamble text to display to the user in non-batch mode. If your policy sets self.distro that text will be substituted accordingly. You can also override this method to do something more complicated.
[ "This", "method", "is", "used", "to", "prepare", "the", "preamble", "text", "to", "display", "to", "the", "user", "in", "non", "-", "batch", "mode", ".", "If", "your", "policy", "sets", "self", ".", "distro", "that", "text", "will", "be", "substituted", ...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L680-L693
train
sosreport/sos
sos/policies/__init__.py
Policy.register_presets
def register_presets(self, presets, replace=False): """Add new presets to this policy object. Merges the presets dictionary ``presets`` into this ``Policy`` object, or replaces the current presets if ``replace`` is ``True``. ``presets`` should be a dictionary ma...
python
def register_presets(self, presets, replace=False): """Add new presets to this policy object. Merges the presets dictionary ``presets`` into this ``Policy`` object, or replaces the current presets if ``replace`` is ``True``. ``presets`` should be a dictionary ma...
[ "def", "register_presets", "(", "self", ",", "presets", ",", "replace", "=", "False", ")", ":", "if", "replace", ":", "self", ".", "presets", "=", "{", "}", "self", ".", "presets", ".", "update", "(", "presets", ")" ]
Add new presets to this policy object. Merges the presets dictionary ``presets`` into this ``Policy`` object, or replaces the current presets if ``replace`` is ``True``. ``presets`` should be a dictionary mapping ``str`` preset names to ``<class PresetDefaul...
[ "Add", "new", "presets", "to", "this", "policy", "object", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L695-L711
train
sosreport/sos
sos/policies/__init__.py
Policy.find_preset
def find_preset(self, preset): """Find a preset profile matching the specified preset string. :param preset: a string containing a preset profile name. :returns: a matching PresetProfile. """ # FIXME: allow fuzzy matching? for match in self.presets.keys(): ...
python
def find_preset(self, preset): """Find a preset profile matching the specified preset string. :param preset: a string containing a preset profile name. :returns: a matching PresetProfile. """ # FIXME: allow fuzzy matching? for match in self.presets.keys(): ...
[ "def", "find_preset", "(", "self", ",", "preset", ")", ":", "# FIXME: allow fuzzy matching?", "for", "match", "in", "self", ".", "presets", ".", "keys", "(", ")", ":", "if", "match", "==", "preset", ":", "return", "self", ".", "presets", "[", "match", "]...
Find a preset profile matching the specified preset string. :param preset: a string containing a preset profile name. :returns: a matching PresetProfile.
[ "Find", "a", "preset", "profile", "matching", "the", "specified", "preset", "string", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L713-L724
train
sosreport/sos
sos/policies/__init__.py
Policy.load_presets
def load_presets(self, presets_path=None): """Load presets from disk. Read JSON formatted preset data from the specified path, or the default location at ``/var/lib/sos/presets``. :param presets_path: a directory containing JSON presets. """ presets_path = p...
python
def load_presets(self, presets_path=None): """Load presets from disk. Read JSON formatted preset data from the specified path, or the default location at ``/var/lib/sos/presets``. :param presets_path: a directory containing JSON presets. """ presets_path = p...
[ "def", "load_presets", "(", "self", ",", "presets_path", "=", "None", ")", ":", "presets_path", "=", "presets_path", "or", "self", ".", "presets_path", "if", "not", "os", ".", "path", ".", "exists", "(", "presets_path", ")", ":", "return", "for", "preset_p...
Load presets from disk. Read JSON formatted preset data from the specified path, or the default location at ``/var/lib/sos/presets``. :param presets_path: a directory containing JSON presets.
[ "Load", "presets", "from", "disk", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L735-L765
train
sosreport/sos
sos/policies/__init__.py
Policy.add_preset
def add_preset(self, name=None, desc=None, note=None, opts=SoSOptions()): """Add a new on-disk preset and write it to the configured presets path. :param preset: the new PresetDefaults to add """ presets_path = self.presets_path if not name: raise Va...
python
def add_preset(self, name=None, desc=None, note=None, opts=SoSOptions()): """Add a new on-disk preset and write it to the configured presets path. :param preset: the new PresetDefaults to add """ presets_path = self.presets_path if not name: raise Va...
[ "def", "add_preset", "(", "self", ",", "name", "=", "None", ",", "desc", "=", "None", ",", "note", "=", "None", ",", "opts", "=", "SoSOptions", "(", ")", ")", ":", "presets_path", "=", "self", ".", "presets_path", "if", "not", "name", ":", "raise", ...
Add a new on-disk preset and write it to the configured presets path. :param preset: the new PresetDefaults to add
[ "Add", "a", "new", "on", "-", "disk", "preset", "and", "write", "it", "to", "the", "configured", "presets", "path", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L767-L784
train
sosreport/sos
sos/policies/__init__.py
LinuxPolicy.lsmod
def lsmod(self): """Return a list of kernel module names as strings. """ lines = shell_out("lsmod", timeout=0).splitlines() return [line.split()[0].strip() for line in lines]
python
def lsmod(self): """Return a list of kernel module names as strings. """ lines = shell_out("lsmod", timeout=0).splitlines() return [line.split()[0].strip() for line in lines]
[ "def", "lsmod", "(", "self", ")", ":", "lines", "=", "shell_out", "(", "\"lsmod\"", ",", "timeout", "=", "0", ")", ".", "splitlines", "(", ")", "return", "[", "line", ".", "split", "(", ")", "[", "0", "]", ".", "strip", "(", ")", "for", "line", ...
Return a list of kernel module names as strings.
[ "Return", "a", "list", "of", "kernel", "module", "names", "as", "strings", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/__init__.py#L873-L877
train
sosreport/sos
sos/plugins/lvm2.py
Lvm2.do_lvmdump
def do_lvmdump(self, metadata=False): """Collects an lvmdump in standard format with optional metadata archives for each physical volume present. """ lvmdump_path = self.get_cmd_output_path(name="lvmdump", make=False) lvmdump_cmd = "lvmdump %s -d '%s'" lvmdump_opts = "...
python
def do_lvmdump(self, metadata=False): """Collects an lvmdump in standard format with optional metadata archives for each physical volume present. """ lvmdump_path = self.get_cmd_output_path(name="lvmdump", make=False) lvmdump_cmd = "lvmdump %s -d '%s'" lvmdump_opts = "...
[ "def", "do_lvmdump", "(", "self", ",", "metadata", "=", "False", ")", ":", "lvmdump_path", "=", "self", ".", "get_cmd_output_path", "(", "name", "=", "\"lvmdump\"", ",", "make", "=", "False", ")", "lvmdump_cmd", "=", "\"lvmdump %s -d '%s'\"", "lvmdump_opts", "...
Collects an lvmdump in standard format with optional metadata archives for each physical volume present.
[ "Collects", "an", "lvmdump", "in", "standard", "format", "with", "optional", "metadata", "archives", "for", "each", "physical", "volume", "present", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/lvm2.py#L24-L37
train
sosreport/sos
sos/__init__.py
SoSOptions.__str
def __str(self, quote=False, sep=" ", prefix="", suffix=""): """Format a SoSOptions object as a human or machine readable string. :param quote: quote option values :param sep: list separator string :param prefix: arbitrary prefix string :param suffix: arbitrary s...
python
def __str(self, quote=False, sep=" ", prefix="", suffix=""): """Format a SoSOptions object as a human or machine readable string. :param quote: quote option values :param sep: list separator string :param prefix: arbitrary prefix string :param suffix: arbitrary s...
[ "def", "__str", "(", "self", ",", "quote", "=", "False", ",", "sep", "=", "\" \"", ",", "prefix", "=", "\"\"", ",", "suffix", "=", "\"\"", ")", ":", "args", "=", "prefix", "arg_fmt", "=", "\"=%s\"", "for", "arg", "in", "_arg_names", ":", "args", "+...
Format a SoSOptions object as a human or machine readable string. :param quote: quote option values :param sep: list separator string :param prefix: arbitrary prefix string :param suffix: arbitrary suffix string :param literal: print values as Python literals
[ "Format", "a", "SoSOptions", "object", "as", "a", "human", "or", "machine", "readable", "string", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L111-L136
train
sosreport/sos
sos/__init__.py
SoSOptions.from_args
def from_args(cls, args): """Initialise a new SoSOptions object from a ``Namespace`` obtained by parsing command line arguments. :param args: parsed command line arguments :returns: an initialised SoSOptions object :returntype: SoSOptions """ opts...
python
def from_args(cls, args): """Initialise a new SoSOptions object from a ``Namespace`` obtained by parsing command line arguments. :param args: parsed command line arguments :returns: an initialised SoSOptions object :returntype: SoSOptions """ opts...
[ "def", "from_args", "(", "cls", ",", "args", ")", ":", "opts", "=", "SoSOptions", "(", ")", "opts", ".", "_merge_opts", "(", "args", ",", "True", ")", "return", "opts" ]
Initialise a new SoSOptions object from a ``Namespace`` obtained by parsing command line arguments. :param args: parsed command line arguments :returns: an initialised SoSOptions object :returntype: SoSOptions
[ "Initialise", "a", "new", "SoSOptions", "object", "from", "a", "Namespace", "obtained", "by", "parsing", "command", "line", "arguments", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L201-L211
train
sosreport/sos
sos/__init__.py
SoSOptions.merge
def merge(self, src, skip_default=True): """Merge another set of ``SoSOptions`` into this object. Merge two ``SoSOptions`` objects by setting unset or default values to their value in the ``src`` object. :param src: the ``SoSOptions`` object to copy from :param ...
python
def merge(self, src, skip_default=True): """Merge another set of ``SoSOptions`` into this object. Merge two ``SoSOptions`` objects by setting unset or default values to their value in the ``src`` object. :param src: the ``SoSOptions`` object to copy from :param ...
[ "def", "merge", "(", "self", ",", "src", ",", "skip_default", "=", "True", ")", ":", "for", "arg", "in", "_arg_names", ":", "if", "not", "hasattr", "(", "src", ",", "arg", ")", ":", "continue", "if", "getattr", "(", "src", ",", "arg", ")", "is", ...
Merge another set of ``SoSOptions`` into this object. Merge two ``SoSOptions`` objects by setting unset or default values to their value in the ``src`` object. :param src: the ``SoSOptions`` object to copy from :param is_default: ``True`` if new default values are to be...
[ "Merge", "another", "set", "of", "SoSOptions", "into", "this", "object", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L272-L285
train
sosreport/sos
sos/__init__.py
SoSOptions.dict
def dict(self): """Return this ``SoSOptions`` option values as a dictionary of argument name to value mappings. :returns: a name:value dictionary of option values. """ odict = {} for arg in _arg_names: value = getattr(self, arg) # Do not a...
python
def dict(self): """Return this ``SoSOptions`` option values as a dictionary of argument name to value mappings. :returns: a name:value dictionary of option values. """ odict = {} for arg in _arg_names: value = getattr(self, arg) # Do not a...
[ "def", "dict", "(", "self", ")", ":", "odict", "=", "{", "}", "for", "arg", "in", "_arg_names", ":", "value", "=", "getattr", "(", "self", ",", "arg", ")", "# Do not attempt to store preset option values in presets", "if", "arg", "in", "(", "'add_preset'", "...
Return this ``SoSOptions`` option values as a dictionary of argument name to value mappings. :returns: a name:value dictionary of option values.
[ "Return", "this", "SoSOptions", "option", "values", "as", "a", "dictionary", "of", "argument", "name", "to", "value", "mappings", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L287-L300
train
sosreport/sos
sos/__init__.py
SoSOptions.to_args
def to_args(self): """Return command arguments for this object. Return a list of the non-default options of this ``SoSOptions`` object in ``sosreport`` command line argument notation: ``["--all-logs", "-vvv"]`` """ def has_value(name, value): ...
python
def to_args(self): """Return command arguments for this object. Return a list of the non-default options of this ``SoSOptions`` object in ``sosreport`` command line argument notation: ``["--all-logs", "-vvv"]`` """ def has_value(name, value): ...
[ "def", "to_args", "(", "self", ")", ":", "def", "has_value", "(", "name", ",", "value", ")", ":", "\"\"\" Test for non-null option values.\n \"\"\"", "null_values", "=", "(", "\"False\"", ",", "\"None\"", ",", "\"[]\"", ",", "'\"\"'", ",", "\"''\"", "...
Return command arguments for this object. Return a list of the non-default options of this ``SoSOptions`` object in ``sosreport`` command line argument notation: ``["--all-logs", "-vvv"]``
[ "Return", "command", "arguments", "for", "this", "object", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L302-L350
train
sosreport/sos
sos/plugins/autofs.py
Autofs.checkdebug
def checkdebug(self): """ testing if autofs debug has been enabled anywhere """ # Global debugging opt = self.file_grep(r"^(DEFAULT_LOGGING|DAEMONOPTIONS)=(.*)", *self.files) for opt1 in opt: for opt2 in opt1.split(" "): if...
python
def checkdebug(self): """ testing if autofs debug has been enabled anywhere """ # Global debugging opt = self.file_grep(r"^(DEFAULT_LOGGING|DAEMONOPTIONS)=(.*)", *self.files) for opt1 in opt: for opt2 in opt1.split(" "): if...
[ "def", "checkdebug", "(", "self", ")", ":", "# Global debugging", "opt", "=", "self", ".", "file_grep", "(", "r\"^(DEFAULT_LOGGING|DAEMONOPTIONS)=(.*)\"", ",", "*", "self", ".", "files", ")", "for", "opt1", "in", "opt", ":", "for", "opt2", "in", "opt1", ".",...
testing if autofs debug has been enabled anywhere
[ "testing", "if", "autofs", "debug", "has", "been", "enabled", "anywhere" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/autofs.py#L24-L34
train
sosreport/sos
sos/plugins/autofs.py
Autofs.getdaemondebug
def getdaemondebug(self): """ capture daemon debug output """ debugout = self.file_grep(r"^(daemon.*)\s+(\/var\/log\/.*)", *self.files) for i in debugout: return i[1]
python
def getdaemondebug(self): """ capture daemon debug output """ debugout = self.file_grep(r"^(daemon.*)\s+(\/var\/log\/.*)", *self.files) for i in debugout: return i[1]
[ "def", "getdaemondebug", "(", "self", ")", ":", "debugout", "=", "self", ".", "file_grep", "(", "r\"^(daemon.*)\\s+(\\/var\\/log\\/.*)\"", ",", "*", "self", ".", "files", ")", "for", "i", "in", "debugout", ":", "return", "i", "[", "1", "]" ]
capture daemon debug output
[ "capture", "daemon", "debug", "output" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/autofs.py#L36-L42
train
sosreport/sos
sos/plugins/jars.py
Jars.is_jar
def is_jar(path): """Check whether given file is a JAR file. JARs are ZIP files which usually include a manifest at the canonical location 'META-INF/MANIFEST.MF'. """ if os.path.isfile(path) and zipfile.is_zipfile(path): try: with zipfile.ZipFile(path...
python
def is_jar(path): """Check whether given file is a JAR file. JARs are ZIP files which usually include a manifest at the canonical location 'META-INF/MANIFEST.MF'. """ if os.path.isfile(path) and zipfile.is_zipfile(path): try: with zipfile.ZipFile(path...
[ "def", "is_jar", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", "and", "zipfile", ".", "is_zipfile", "(", "path", ")", ":", "try", ":", "with", "zipfile", ".", "ZipFile", "(", "path", ")", "as", "f", ":", "if", ...
Check whether given file is a JAR file. JARs are ZIP files which usually include a manifest at the canonical location 'META-INF/MANIFEST.MF'.
[ "Check", "whether", "given", "file", "is", "a", "JAR", "file", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/jars.py#L84-L97
train
sosreport/sos
sos/plugins/jars.py
Jars.get_maven_id
def get_maven_id(jar_path): """Extract Maven coordinates from a given JAR file, if possible. JARs build by Maven (most popular Java build system) contain 'pom.properties' file. We can extract Maven coordinates from there. """ props = {} try: with zip...
python
def get_maven_id(jar_path): """Extract Maven coordinates from a given JAR file, if possible. JARs build by Maven (most popular Java build system) contain 'pom.properties' file. We can extract Maven coordinates from there. """ props = {} try: with zip...
[ "def", "get_maven_id", "(", "jar_path", ")", ":", "props", "=", "{", "}", "try", ":", "with", "zipfile", ".", "ZipFile", "(", "jar_path", ")", "as", "f", ":", "r", "=", "re", ".", "compile", "(", "\"META-INF/maven/[^/]+/[^/]+/pom.properties$\"", ")", "resu...
Extract Maven coordinates from a given JAR file, if possible. JARs build by Maven (most popular Java build system) contain 'pom.properties' file. We can extract Maven coordinates from there.
[ "Extract", "Maven", "coordinates", "from", "a", "given", "JAR", "file", "if", "possible", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/jars.py#L100-L127
train
sosreport/sos
sos/plugins/jars.py
Jars.get_jar_id
def get_jar_id(jar_path): """Compute JAR id. Returns sha1 hash of a given JAR file. """ jar_id = "" try: with open(jar_path, mode="rb") as f: m = hashlib.sha1() for buf in iter(partial(f.read, 4096), b''): m.update(...
python
def get_jar_id(jar_path): """Compute JAR id. Returns sha1 hash of a given JAR file. """ jar_id = "" try: with open(jar_path, mode="rb") as f: m = hashlib.sha1() for buf in iter(partial(f.read, 4096), b''): m.update(...
[ "def", "get_jar_id", "(", "jar_path", ")", ":", "jar_id", "=", "\"\"", "try", ":", "with", "open", "(", "jar_path", ",", "mode", "=", "\"rb\"", ")", "as", "f", ":", "m", "=", "hashlib", ".", "sha1", "(", ")", "for", "buf", "in", "iter", "(", "par...
Compute JAR id. Returns sha1 hash of a given JAR file.
[ "Compute", "JAR", "id", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/jars.py#L130-L144
train
sosreport/sos
sos/plugins/qpid.py
Qpid.setup
def setup(self): """ performs data collection for qpid broker """ options = "" amqps_prefix = "" # set amqps:// when SSL is used if self.get_option("ssl"): amqps_prefix = "amqps://" # for either present option, add --option=value to 'options' variable for opt...
python
def setup(self): """ performs data collection for qpid broker """ options = "" amqps_prefix = "" # set amqps:// when SSL is used if self.get_option("ssl"): amqps_prefix = "amqps://" # for either present option, add --option=value to 'options' variable for opt...
[ "def", "setup", "(", "self", ")", ":", "options", "=", "\"\"", "amqps_prefix", "=", "\"\"", "# set amqps:// when SSL is used", "if", "self", ".", "get_option", "(", "\"ssl\"", ")", ":", "amqps_prefix", "=", "\"amqps://\"", "# for either present option, add --option=va...
performs data collection for qpid broker
[ "performs", "data", "collection", "for", "qpid", "broker" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/qpid.py#L27-L80
train
sosreport/sos
sos/sosreport.py
SoSReport._exception
def _exception(etype, eval_, etrace): """ Wrap exception in debugger if not in tty """ if hasattr(sys, 'ps1') or not sys.stderr.isatty(): # we are in interactive mode or we don't have a tty-like # device, so we call the default hook sys.__excepthook__(etype, eval_, et...
python
def _exception(etype, eval_, etrace): """ Wrap exception in debugger if not in tty """ if hasattr(sys, 'ps1') or not sys.stderr.isatty(): # we are in interactive mode or we don't have a tty-like # device, so we call the default hook sys.__excepthook__(etype, eval_, et...
[ "def", "_exception", "(", "etype", ",", "eval_", ",", "etrace", ")", ":", "if", "hasattr", "(", "sys", ",", "'ps1'", ")", "or", "not", "sys", ".", "stderr", ".", "isatty", "(", ")", ":", "# we are in interactive mode or we don't have a tty-like", "# device, so...
Wrap exception in debugger if not in tty
[ "Wrap", "exception", "in", "debugger", "if", "not", "in", "tty" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/sosreport.py#L404-L416
train
sosreport/sos
sos/sosreport.py
SoSReport.add_preset
def add_preset(self, name, desc="", note=""): """Add a new command line preset for the current options with the specified name. :param name: the name of the new preset :returns: True on success or False otherwise """ policy = self.policy if policy.fin...
python
def add_preset(self, name, desc="", note=""): """Add a new command line preset for the current options with the specified name. :param name: the name of the new preset :returns: True on success or False otherwise """ policy = self.policy if policy.fin...
[ "def", "add_preset", "(", "self", ",", "name", ",", "desc", "=", "\"\"", ",", "note", "=", "\"\"", ")", ":", "policy", "=", "self", ".", "policy", "if", "policy", ".", "find_preset", "(", "name", ")", ":", "self", ".", "ui_log", ".", "error", "(", ...
Add a new command line preset for the current options with the specified name. :param name: the name of the new preset :returns: True on success or False otherwise
[ "Add", "a", "new", "command", "line", "preset", "for", "the", "current", "options", "with", "the", "specified", "name", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/sosreport.py#L802-L829
train
sosreport/sos
sos/sosreport.py
SoSReport.del_preset
def del_preset(self, name): """Delete a named command line preset. :param name: the name of the preset to delete :returns: True on success or False otherwise """ policy = self.policy if not policy.find_preset(name): self.ui_log.error("Preset '%s' not ...
python
def del_preset(self, name): """Delete a named command line preset. :param name: the name of the preset to delete :returns: True on success or False otherwise """ policy = self.policy if not policy.find_preset(name): self.ui_log.error("Preset '%s' not ...
[ "def", "del_preset", "(", "self", ",", "name", ")", ":", "policy", "=", "self", ".", "policy", "if", "not", "policy", ".", "find_preset", "(", "name", ")", ":", "self", ".", "ui_log", ".", "error", "(", "\"Preset '%s' not found\"", "%", "name", ")", "r...
Delete a named command line preset. :param name: the name of the preset to delete :returns: True on success or False otherwise
[ "Delete", "a", "named", "command", "line", "preset", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/sosreport.py#L831-L849
train
sosreport/sos
sos/sosreport.py
SoSReport.version
def version(self): """Fetch version information from all plugins and store in the report version file""" versions = [] versions.append("sosreport: %s" % __version__) for plugname, plug in self.loaded_plugins: versions.append("%s: %s" % (plugname, plug.version)) ...
python
def version(self): """Fetch version information from all plugins and store in the report version file""" versions = [] versions.append("sosreport: %s" % __version__) for plugname, plug in self.loaded_plugins: versions.append("%s: %s" % (plugname, plug.version)) ...
[ "def", "version", "(", "self", ")", ":", "versions", "=", "[", "]", "versions", ".", "append", "(", "\"sosreport: %s\"", "%", "__version__", ")", "for", "plugname", ",", "plug", "in", "self", ".", "loaded_plugins", ":", "versions", ".", "append", "(", "\...
Fetch version information from all plugins and store in the report version file
[ "Fetch", "version", "information", "from", "all", "plugins", "and", "store", "in", "the", "report", "version", "file" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/sosreport.py#L949-L960
train
sosreport/sos
sos/plugins/navicli.py
Navicli.get_navicli_SP_info
def get_navicli_SP_info(self, SP_address): """ EMC Navisphere Host Agent NAVICLI specific information - CLARiiON - commands """ self.add_cmd_output([ "navicli -h %s getall" % SP_address, "navicli -h %s getsptime -spa" % SP_address, "navicli -h %s getsp...
python
def get_navicli_SP_info(self, SP_address): """ EMC Navisphere Host Agent NAVICLI specific information - CLARiiON - commands """ self.add_cmd_output([ "navicli -h %s getall" % SP_address, "navicli -h %s getsptime -spa" % SP_address, "navicli -h %s getsp...
[ "def", "get_navicli_SP_info", "(", "self", ",", "SP_address", ")", ":", "self", ".", "add_cmd_output", "(", "[", "\"navicli -h %s getall\"", "%", "SP_address", ",", "\"navicli -h %s getsptime -spa\"", "%", "SP_address", ",", "\"navicli -h %s getsptime -spb\"", "%", "SP_...
EMC Navisphere Host Agent NAVICLI specific information - CLARiiON - commands
[ "EMC", "Navisphere", "Host", "Agent", "NAVICLI", "specific", "information", "-", "CLARiiON", "-", "commands" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/navicli.py#L41-L60
train
sosreport/sos
sos/plugins/origin.py
OpenShiftOrigin.is_static_etcd
def is_static_etcd(self): '''Determine if we are on a node running etcd''' return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml"))
python
def is_static_etcd(self): '''Determine if we are on a node running etcd''' return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml"))
[ "def", "is_static_etcd", "(", "self", ")", ":", "return", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "self", ".", "static_pod_dir", ",", "\"etcd.yaml\"", ")", ")" ]
Determine if we are on a node running etcd
[ "Determine", "if", "we", "are", "on", "a", "node", "running", "etcd" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/origin.py#L78-L80
train
sosreport/sos
sos/plugins/networking.py
Networking.get_ip_netns
def get_ip_netns(self, ip_netns_file): """Returns a list for which items are namespaces in the output of ip netns stored in the ip_netns_file. """ out = [] try: ip_netns_out = open(ip_netns_file).read() except IOError: return out for line i...
python
def get_ip_netns(self, ip_netns_file): """Returns a list for which items are namespaces in the output of ip netns stored in the ip_netns_file. """ out = [] try: ip_netns_out = open(ip_netns_file).read() except IOError: return out for line i...
[ "def", "get_ip_netns", "(", "self", ",", "ip_netns_file", ")", ":", "out", "=", "[", "]", "try", ":", "ip_netns_out", "=", "open", "(", "ip_netns_file", ")", ".", "read", "(", ")", "except", "IOError", ":", "return", "out", "for", "line", "in", "ip_net...
Returns a list for which items are namespaces in the output of ip netns stored in the ip_netns_file.
[ "Returns", "a", "list", "for", "which", "items", "are", "namespaces", "in", "the", "output", "of", "ip", "netns", "stored", "in", "the", "ip_netns_file", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/networking.py#L28-L44
train
sosreport/sos
sos/plugins/networking.py
Networking.collect_iptable
def collect_iptable(self, tablename): """ When running the iptables command, it unfortunately auto-loads the modules before trying to get output. Some people explicitly don't want this, so check if the modules are loaded before running the command. If they aren't loaded, there can't po...
python
def collect_iptable(self, tablename): """ When running the iptables command, it unfortunately auto-loads the modules before trying to get output. Some people explicitly don't want this, so check if the modules are loaded before running the command. If they aren't loaded, there can't po...
[ "def", "collect_iptable", "(", "self", ",", "tablename", ")", ":", "modname", "=", "\"iptable_\"", "+", "tablename", "if", "self", ".", "check_ext_prog", "(", "\"grep -q %s /proc/modules\"", "%", "modname", ")", ":", "cmd", "=", "\"iptables -t \"", "+", "tablena...
When running the iptables command, it unfortunately auto-loads the modules before trying to get output. Some people explicitly don't want this, so check if the modules are loaded before running the command. If they aren't loaded, there can't possibly be any relevant rules in that table
[ "When", "running", "the", "iptables", "command", "it", "unfortunately", "auto", "-", "loads", "the", "modules", "before", "trying", "to", "get", "output", ".", "Some", "people", "explicitly", "don", "t", "want", "this", "so", "check", "if", "the", "modules",...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/networking.py#L46-L56
train
sosreport/sos
sos/plugins/networking.py
Networking.collect_ip6table
def collect_ip6table(self, tablename): """ Same as function above, but for ipv6 """ modname = "ip6table_"+tablename if self.check_ext_prog("grep -q %s /proc/modules" % modname): cmd = "ip6tables -t "+tablename+" -nvL" self.add_cmd_output(cmd)
python
def collect_ip6table(self, tablename): """ Same as function above, but for ipv6 """ modname = "ip6table_"+tablename if self.check_ext_prog("grep -q %s /proc/modules" % modname): cmd = "ip6tables -t "+tablename+" -nvL" self.add_cmd_output(cmd)
[ "def", "collect_ip6table", "(", "self", ",", "tablename", ")", ":", "modname", "=", "\"ip6table_\"", "+", "tablename", "if", "self", ".", "check_ext_prog", "(", "\"grep -q %s /proc/modules\"", "%", "modname", ")", ":", "cmd", "=", "\"ip6tables -t \"", "+", "tabl...
Same as function above, but for ipv6
[ "Same", "as", "function", "above", "but", "for", "ipv6" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/networking.py#L58-L64
train
sosreport/sos
sos/plugins/ovirt.py
Ovirt.postproc
def postproc(self): """ Obfuscate sensitive keys. """ self.do_file_sub( "/etc/ovirt-engine/engine-config/engine-config.properties", r"Password.type=(.*)", r"Password.type=********" ) self.do_file_sub( "/etc/rhevm/rhevm-confi...
python
def postproc(self): """ Obfuscate sensitive keys. """ self.do_file_sub( "/etc/ovirt-engine/engine-config/engine-config.properties", r"Password.type=(.*)", r"Password.type=********" ) self.do_file_sub( "/etc/rhevm/rhevm-confi...
[ "def", "postproc", "(", "self", ")", ":", "self", ".", "do_file_sub", "(", "\"/etc/ovirt-engine/engine-config/engine-config.properties\"", ",", "r\"Password.type=(.*)\"", ",", "r\"Password.type=********\"", ")", "self", ".", "do_file_sub", "(", "\"/etc/rhevm/rhevm-config/rhev...
Obfuscate sensitive keys.
[ "Obfuscate", "sensitive", "keys", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/ovirt.py#L135-L226
train
sosreport/sos
sos/plugins/watchdog.py
Watchdog.get_log_dir
def get_log_dir(self, conf_file): """Get watchdog log directory. Get watchdog log directory path configured in ``conf_file``. :returns: The watchdog log directory path. :returntype: str. :raises: IOError if ``conf_file`` is not readable. """ log_...
python
def get_log_dir(self, conf_file): """Get watchdog log directory. Get watchdog log directory path configured in ``conf_file``. :returns: The watchdog log directory path. :returntype: str. :raises: IOError if ``conf_file`` is not readable. """ log_...
[ "def", "get_log_dir", "(", "self", ",", "conf_file", ")", ":", "log_dir", "=", "None", "with", "open", "(", "conf_file", ",", "'r'", ")", "as", "conf_f", ":", "for", "line", "in", "conf_f", ":", "line", "=", "line", ".", "split", "(", "'#'", ")", "...
Get watchdog log directory. Get watchdog log directory path configured in ``conf_file``. :returns: The watchdog log directory path. :returntype: str. :raises: IOError if ``conf_file`` is not readable.
[ "Get", "watchdog", "log", "directory", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/watchdog.py#L27-L49
train
sosreport/sos
sos/plugins/watchdog.py
Watchdog.setup
def setup(self): """Collect watchdog information. Collect configuration files, custom executables for test-binary and repair-binary, and stdout/stderr logs. """ conf_file = self.get_option('conf_file') log_dir = '/var/log/watchdog' # Get service configur...
python
def setup(self): """Collect watchdog information. Collect configuration files, custom executables for test-binary and repair-binary, and stdout/stderr logs. """ conf_file = self.get_option('conf_file') log_dir = '/var/log/watchdog' # Get service configur...
[ "def", "setup", "(", "self", ")", ":", "conf_file", "=", "self", ".", "get_option", "(", "'conf_file'", ")", "log_dir", "=", "'/var/log/watchdog'", "# Get service configuration and sysconfig files", "self", ".", "add_copy_spec", "(", "[", "conf_file", ",", "'/etc/sy...
Collect watchdog information. Collect configuration files, custom executables for test-binary and repair-binary, and stdout/stderr logs.
[ "Collect", "watchdog", "information", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/watchdog.py#L51-L90
train
sosreport/sos
sos/plugins/gluster.py
Gluster.get_volume_names
def get_volume_names(self, volume_file): """Return a dictionary for which key are volume names according to the output of gluster volume info stored in volume_file. """ out = [] fp = open(volume_file, 'r') for line in fp.readlines(): if not line.startswith("Vo...
python
def get_volume_names(self, volume_file): """Return a dictionary for which key are volume names according to the output of gluster volume info stored in volume_file. """ out = [] fp = open(volume_file, 'r') for line in fp.readlines(): if not line.startswith("Vo...
[ "def", "get_volume_names", "(", "self", ",", "volume_file", ")", ":", "out", "=", "[", "]", "fp", "=", "open", "(", "volume_file", ",", "'r'", ")", "for", "line", "in", "fp", ".", "readlines", "(", ")", ":", "if", "not", "line", ".", "startswith", ...
Return a dictionary for which key are volume names according to the output of gluster volume info stored in volume_file.
[ "Return", "a", "dictionary", "for", "which", "key", "are", "volume", "names", "according", "to", "the", "output", "of", "gluster", "volume", "info", "stored", "in", "volume_file", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/gluster.py#L29-L41
train
sosreport/sos
sos/policies/ubuntu.py
UbuntuPolicy.dist_version
def dist_version(self): """ Returns the version stated in DISTRIB_RELEASE """ try: with open('/etc/lsb-release', 'r') as fp: lines = fp.readlines() for line in lines: if "DISTRIB_RELEASE" in line: return line...
python
def dist_version(self): """ Returns the version stated in DISTRIB_RELEASE """ try: with open('/etc/lsb-release', 'r') as fp: lines = fp.readlines() for line in lines: if "DISTRIB_RELEASE" in line: return line...
[ "def", "dist_version", "(", "self", ")", ":", "try", ":", "with", "open", "(", "'/etc/lsb-release'", ",", "'r'", ")", "as", "fp", ":", "lines", "=", "fp", ".", "readlines", "(", ")", "for", "line", "in", "lines", ":", "if", "\"DISTRIB_RELEASE\"", "in",...
Returns the version stated in DISTRIB_RELEASE
[ "Returns", "the", "version", "stated", "in", "DISTRIB_RELEASE" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/ubuntu.py#L26-L37
train
sosreport/sos
sos/archive.py
FileCacheArchive._make_leading_paths
def _make_leading_paths(self, src, mode=0o700): """Create leading path components The standard python `os.makedirs` is insufficient for our needs: it will only create directories, and ignores the fact that some path components may be symbolic links. :param src: ...
python
def _make_leading_paths(self, src, mode=0o700): """Create leading path components The standard python `os.makedirs` is insufficient for our needs: it will only create directories, and ignores the fact that some path components may be symbolic links. :param src: ...
[ "def", "_make_leading_paths", "(", "self", ",", "src", ",", "mode", "=", "0o700", ")", ":", "self", ".", "log_debug", "(", "\"Making leading paths for %s\"", "%", "src", ")", "root", "=", "self", ".", "_archive_root", "dest", "=", "src", "def", "in_archive",...
Create leading path components The standard python `os.makedirs` is insufficient for our needs: it will only create directories, and ignores the fact that some path components may be symbolic links. :param src: The source path in the host file system for which ...
[ "Create", "leading", "path", "components" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L159-L243
train
sosreport/sos
sos/archive.py
FileCacheArchive._check_path
def _check_path(self, src, path_type, dest=None, force=False): """Check a new destination path in the archive. Since it is possible for multiple plugins to collect the same paths, and since plugins can now run concurrently, it is possible for two threads to race in archive m...
python
def _check_path(self, src, path_type, dest=None, force=False): """Check a new destination path in the archive. Since it is possible for multiple plugins to collect the same paths, and since plugins can now run concurrently, it is possible for two threads to race in archive m...
[ "def", "_check_path", "(", "self", ",", "src", ",", "path_type", ",", "dest", "=", "None", ",", "force", "=", "False", ")", ":", "dest", "=", "dest", "or", "self", ".", "dest_path", "(", "src", ")", "if", "path_type", "==", "P_DIR", ":", "dest_dir", ...
Check a new destination path in the archive. Since it is possible for multiple plugins to collect the same paths, and since plugins can now run concurrently, it is possible for two threads to race in archive methods: historically the archive class only needed to test for...
[ "Check", "a", "new", "destination", "path", "in", "the", "archive", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L245-L318
train
sosreport/sos
sos/archive.py
FileCacheArchive.makedirs
def makedirs(self, path, mode=0o700): """Create path, including leading components. Used by sos.sosreport to set up sos_* directories. """ os.makedirs(os.path.join(self._archive_root, path), mode=mode) self.log_debug("created directory at '%s' in FileCacheArchive '%s'" ...
python
def makedirs(self, path, mode=0o700): """Create path, including leading components. Used by sos.sosreport to set up sos_* directories. """ os.makedirs(os.path.join(self._archive_root, path), mode=mode) self.log_debug("created directory at '%s' in FileCacheArchive '%s'" ...
[ "def", "makedirs", "(", "self", ",", "path", ",", "mode", "=", "0o700", ")", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "join", "(", "self", ".", "_archive_root", ",", "path", ")", ",", "mode", "=", "mode", ")", "self", ".", "log_de...
Create path, including leading components. Used by sos.sosreport to set up sos_* directories.
[ "Create", "path", "including", "leading", "components", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L510-L517
train
sosreport/sos
sos/archive.py
FileCacheArchive._encrypt
def _encrypt(self, archive): """Encrypts the compressed archive using GPG. If encryption fails for any reason, it should be logged by sos but not cause execution to stop. The assumption is that the unencrypted archive would still be of use to the user, and/or that the end user has anoth...
python
def _encrypt(self, archive): """Encrypts the compressed archive using GPG. If encryption fails for any reason, it should be logged by sos but not cause execution to stop. The assumption is that the unencrypted archive would still be of use to the user, and/or that the end user has anoth...
[ "def", "_encrypt", "(", "self", ",", "archive", ")", ":", "arc_name", "=", "archive", ".", "replace", "(", "\"sosreport-\"", ",", "\"secured-sosreport-\"", ")", "arc_name", "+=", "\".gpg\"", "enc_cmd", "=", "\"gpg --batch -o %s \"", "%", "arc_name", "env", "=", ...
Encrypts the compressed archive using GPG. If encryption fails for any reason, it should be logged by sos but not cause execution to stop. The assumption is that the unencrypted archive would still be of use to the user, and/or that the end user has another means of securing the archive...
[ "Encrypts", "the", "compressed", "archive", "using", "GPG", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L552-L593
train
sosreport/sos
sos/utilities.py
tail
def tail(filename, number_of_bytes): """Returns the last number_of_bytes of filename""" with open(filename, "rb") as f: if os.stat(filename).st_size > number_of_bytes: f.seek(-number_of_bytes, 2) return f.read()
python
def tail(filename, number_of_bytes): """Returns the last number_of_bytes of filename""" with open(filename, "rb") as f: if os.stat(filename).st_size > number_of_bytes: f.seek(-number_of_bytes, 2) return f.read()
[ "def", "tail", "(", "filename", ",", "number_of_bytes", ")", ":", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "f", ":", "if", "os", ".", "stat", "(", "filename", ")", ".", "st_size", ">", "number_of_bytes", ":", "f", ".", "seek", "(", ...
Returns the last number_of_bytes of filename
[ "Returns", "the", "last", "number_of_bytes", "of", "filename" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L29-L34
train
sosreport/sos
sos/utilities.py
fileobj
def fileobj(path_or_file, mode='r'): """Returns a file-like object that can be used as a context manager""" if isinstance(path_or_file, six.string_types): try: return open(path_or_file, mode) except IOError: log = logging.getLogger('sos') log.debug("fileobj: %...
python
def fileobj(path_or_file, mode='r'): """Returns a file-like object that can be used as a context manager""" if isinstance(path_or_file, six.string_types): try: return open(path_or_file, mode) except IOError: log = logging.getLogger('sos') log.debug("fileobj: %...
[ "def", "fileobj", "(", "path_or_file", ",", "mode", "=", "'r'", ")", ":", "if", "isinstance", "(", "path_or_file", ",", "six", ".", "string_types", ")", ":", "try", ":", "return", "open", "(", "path_or_file", ",", "mode", ")", "except", "IOError", ":", ...
Returns a file-like object that can be used as a context manager
[ "Returns", "a", "file", "-", "like", "object", "that", "can", "be", "used", "as", "a", "context", "manager" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L37-L47
train
sosreport/sos
sos/utilities.py
convert_bytes
def convert_bytes(bytes_, K=1 << 10, M=1 << 20, G=1 << 30, T=1 << 40): """Converts a number of bytes to a shorter, more human friendly format""" fn = float(bytes_) if bytes_ >= T: return '%.1fT' % (fn / T) elif bytes_ >= G: return '%.1fG' % (fn / G) elif bytes_ >= M: return '...
python
def convert_bytes(bytes_, K=1 << 10, M=1 << 20, G=1 << 30, T=1 << 40): """Converts a number of bytes to a shorter, more human friendly format""" fn = float(bytes_) if bytes_ >= T: return '%.1fT' % (fn / T) elif bytes_ >= G: return '%.1fG' % (fn / G) elif bytes_ >= M: return '...
[ "def", "convert_bytes", "(", "bytes_", ",", "K", "=", "1", "<<", "10", ",", "M", "=", "1", "<<", "20", ",", "G", "=", "1", "<<", "30", ",", "T", "=", "1", "<<", "40", ")", ":", "fn", "=", "float", "(", "bytes_", ")", "if", "bytes_", ">=", ...
Converts a number of bytes to a shorter, more human friendly format
[ "Converts", "a", "number", "of", "bytes", "to", "a", "shorter", "more", "human", "friendly", "format" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L50-L62
train
sosreport/sos
sos/utilities.py
grep
def grep(pattern, *files_or_paths): """Returns lines matched in fnames, where fnames can either be pathnames to files to grep through or open file objects to grep through line by line""" matches = [] for fop in files_or_paths: with fileobj(fop) as fo: matches.extend((line for line i...
python
def grep(pattern, *files_or_paths): """Returns lines matched in fnames, where fnames can either be pathnames to files to grep through or open file objects to grep through line by line""" matches = [] for fop in files_or_paths: with fileobj(fop) as fo: matches.extend((line for line i...
[ "def", "grep", "(", "pattern", ",", "*", "files_or_paths", ")", ":", "matches", "=", "[", "]", "for", "fop", "in", "files_or_paths", ":", "with", "fileobj", "(", "fop", ")", "as", "fo", ":", "matches", ".", "extend", "(", "(", "line", "for", "line", ...
Returns lines matched in fnames, where fnames can either be pathnames to files to grep through or open file objects to grep through line by line
[ "Returns", "lines", "matched", "in", "fnames", "where", "fnames", "can", "either", "be", "pathnames", "to", "files", "to", "grep", "through", "or", "open", "file", "objects", "to", "grep", "through", "line", "by", "line" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L87-L96
train
sosreport/sos
sos/utilities.py
is_executable
def is_executable(command): """Returns if a command matches an executable on the PATH""" paths = os.environ.get("PATH", "").split(os.path.pathsep) candidates = [command] + [os.path.join(p, command) for p in paths] return any(os.access(path, os.X_OK) for path in candidates)
python
def is_executable(command): """Returns if a command matches an executable on the PATH""" paths = os.environ.get("PATH", "").split(os.path.pathsep) candidates = [command] + [os.path.join(p, command) for p in paths] return any(os.access(path, os.X_OK) for path in candidates)
[ "def", "is_executable", "(", "command", ")", ":", "paths", "=", "os", ".", "environ", ".", "get", "(", "\"PATH\"", ",", "\"\"", ")", ".", "split", "(", "os", ".", "path", ".", "pathsep", ")", "candidates", "=", "[", "command", "]", "+", "[", "os", ...
Returns if a command matches an executable on the PATH
[ "Returns", "if", "a", "command", "matches", "an", "executable", "on", "the", "PATH" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L99-L104
train
sosreport/sos
sos/utilities.py
sos_get_command_output
def sos_get_command_output(command, timeout=300, stderr=False, chroot=None, chdir=None, env=None, binary=False, sizelimit=None, poller=None): """Execute a command and return a dictionary of status and output, optionally changing root or current working direc...
python
def sos_get_command_output(command, timeout=300, stderr=False, chroot=None, chdir=None, env=None, binary=False, sizelimit=None, poller=None): """Execute a command and return a dictionary of status and output, optionally changing root or current working direc...
[ "def", "sos_get_command_output", "(", "command", ",", "timeout", "=", "300", ",", "stderr", "=", "False", ",", "chroot", "=", "None", ",", "chdir", "=", "None", ",", "env", "=", "None", ",", "binary", "=", "False", ",", "sizelimit", "=", "None", ",", ...
Execute a command and return a dictionary of status and output, optionally changing root or current working directory before executing command.
[ "Execute", "a", "command", "and", "return", "a", "dictionary", "of", "status", "and", "output", "optionally", "changing", "root", "or", "current", "working", "directory", "before", "executing", "command", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L107-L177
train
sosreport/sos
sos/utilities.py
import_module
def import_module(module_fqname, superclasses=None): """Imports the module module_fqname and returns a list of defined classes from that module. If superclasses is defined then the classes returned will be subclasses of the specified superclass or superclasses. If superclasses is plural it must be a tup...
python
def import_module(module_fqname, superclasses=None): """Imports the module module_fqname and returns a list of defined classes from that module. If superclasses is defined then the classes returned will be subclasses of the specified superclass or superclasses. If superclasses is plural it must be a tup...
[ "def", "import_module", "(", "module_fqname", ",", "superclasses", "=", "None", ")", ":", "module_name", "=", "module_fqname", ".", "rpartition", "(", "\".\"", ")", "[", "-", "1", "]", "module", "=", "__import__", "(", "module_fqname", ",", "globals", "(", ...
Imports the module module_fqname and returns a list of defined classes from that module. If superclasses is defined then the classes returned will be subclasses of the specified superclass or superclasses. If superclasses is plural it must be a tuple of classes.
[ "Imports", "the", "module", "module_fqname", "and", "returns", "a", "list", "of", "defined", "classes", "from", "that", "module", ".", "If", "superclasses", "is", "defined", "then", "the", "classes", "returned", "will", "be", "subclasses", "of", "the", "specif...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L180-L193
train
sosreport/sos
sos/utilities.py
shell_out
def shell_out(cmd, timeout=30, chroot=None, runat=None): """Shell out to an external command and return the output or the empty string in case of error. """ return sos_get_command_output(cmd, timeout=timeout, chroot=chroot, chdir=runat)['output']
python
def shell_out(cmd, timeout=30, chroot=None, runat=None): """Shell out to an external command and return the output or the empty string in case of error. """ return sos_get_command_output(cmd, timeout=timeout, chroot=chroot, chdir=runat)['output']
[ "def", "shell_out", "(", "cmd", ",", "timeout", "=", "30", ",", "chroot", "=", "None", ",", "runat", "=", "None", ")", ":", "return", "sos_get_command_output", "(", "cmd", ",", "timeout", "=", "timeout", ",", "chroot", "=", "chroot", ",", "chdir", "=",...
Shell out to an external command and return the output or the empty string in case of error.
[ "Shell", "out", "to", "an", "external", "command", "and", "return", "the", "output", "or", "the", "empty", "string", "in", "case", "of", "error", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L196-L201
train
sosreport/sos
sos/utilities.py
AsyncReader.get_contents
def get_contents(self): '''Returns the contents of the deque as a string''' # block until command completes or timesout (separate from the plugin # hitting a timeout) while self.running: pass if not self.binary: return ''.join(ln.decode('utf-8', 'ignore') ...
python
def get_contents(self): '''Returns the contents of the deque as a string''' # block until command completes or timesout (separate from the plugin # hitting a timeout) while self.running: pass if not self.binary: return ''.join(ln.decode('utf-8', 'ignore') ...
[ "def", "get_contents", "(", "self", ")", ":", "# block until command completes or timesout (separate from the plugin", "# hitting a timeout)", "while", "self", ".", "running", ":", "pass", "if", "not", "self", ".", "binary", ":", "return", "''", ".", "join", "(", "l...
Returns the contents of the deque as a string
[ "Returns", "the", "contents", "of", "the", "deque", "as", "a", "string" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L246-L255
train
sosreport/sos
sos/utilities.py
ImporterHelper._plugin_name
def _plugin_name(self, path): "Returns the plugin module name given the path" base = os.path.basename(path) name, ext = os.path.splitext(base) return name
python
def _plugin_name(self, path): "Returns the plugin module name given the path" base = os.path.basename(path) name, ext = os.path.splitext(base) return name
[ "def", "_plugin_name", "(", "self", ",", "path", ")", ":", "base", "=", "os", ".", "path", ".", "basename", "(", "path", ")", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "base", ")", "return", "name" ]
Returns the plugin module name given the path
[ "Returns", "the", "plugin", "module", "name", "given", "the", "path" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L270-L274
train
sosreport/sos
sos/utilities.py
ImporterHelper.get_modules
def get_modules(self): """Returns the list of importable modules in the configured python package. """ plugins = [] for path in self.package.__path__: if os.path.isdir(path): plugins.extend(self._find_plugins_in_dir(path)) return plugins
python
def get_modules(self): """Returns the list of importable modules in the configured python package. """ plugins = [] for path in self.package.__path__: if os.path.isdir(path): plugins.extend(self._find_plugins_in_dir(path)) return plugins
[ "def", "get_modules", "(", "self", ")", ":", "plugins", "=", "[", "]", "for", "path", "in", "self", ".", "package", ".", "__path__", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "plugins", ".", "extend", "(", "self", ".", "_...
Returns the list of importable modules in the configured python package.
[ "Returns", "the", "list", "of", "importable", "modules", "in", "the", "configured", "python", "package", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L292-L300
train
sosreport/sos
sos/policies/redhat.py
RedHatPolicy.check_usrmove
def check_usrmove(self, pkgs): """Test whether the running system implements UsrMove. If the 'filesystem' package is present, it will check that the version is greater than 3. If the package is not present the '/bin' and '/sbin' paths are checked and UsrMove is assumed ...
python
def check_usrmove(self, pkgs): """Test whether the running system implements UsrMove. If the 'filesystem' package is present, it will check that the version is greater than 3. If the package is not present the '/bin' and '/sbin' paths are checked and UsrMove is assumed ...
[ "def", "check_usrmove", "(", "self", ",", "pkgs", ")", ":", "if", "'filesystem'", "not", "in", "pkgs", ":", "return", "os", ".", "path", ".", "islink", "(", "'/bin'", ")", "and", "os", ".", "path", ".", "islink", "(", "'/sbin'", ")", "else", ":", "...
Test whether the running system implements UsrMove. If the 'filesystem' package is present, it will check that the version is greater than 3. If the package is not present the '/bin' and '/sbin' paths are checked and UsrMove is assumed if both are symbolic links. ...
[ "Test", "whether", "the", "running", "system", "implements", "UsrMove", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L100-L114
train
sosreport/sos
sos/policies/redhat.py
RedHatPolicy.mangle_package_path
def mangle_package_path(self, files): """Mangle paths for post-UsrMove systems. If the system implements UsrMove, all files will be in '/usr/[s]bin'. This method substitutes all the /[s]bin references in the 'files' list with '/usr/[s]bin'. :param files: the lis...
python
def mangle_package_path(self, files): """Mangle paths for post-UsrMove systems. If the system implements UsrMove, all files will be in '/usr/[s]bin'. This method substitutes all the /[s]bin references in the 'files' list with '/usr/[s]bin'. :param files: the lis...
[ "def", "mangle_package_path", "(", "self", ",", "files", ")", ":", "paths", "=", "[", "]", "def", "transform_path", "(", "path", ")", ":", "# Some packages actually own paths in /bin: in this case,", "# duplicate the path as both the / and /usr version.", "skip_paths", "=",...
Mangle paths for post-UsrMove systems. If the system implements UsrMove, all files will be in '/usr/[s]bin'. This method substitutes all the /[s]bin references in the 'files' list with '/usr/[s]bin'. :param files: the list of package managed files
[ "Mangle", "paths", "for", "post", "-", "UsrMove", "systems", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L116-L140
train
sosreport/sos
sos/policies/redhat.py
RedHatPolicy._container_init
def _container_init(self): """Check if sos is running in a container and perform container specific initialisation based on ENV_HOST_SYSROOT. """ if ENV_CONTAINER in os.environ: if os.environ[ENV_CONTAINER] in ['docker', 'oci']: self._in_container = True ...
python
def _container_init(self): """Check if sos is running in a container and perform container specific initialisation based on ENV_HOST_SYSROOT. """ if ENV_CONTAINER in os.environ: if os.environ[ENV_CONTAINER] in ['docker', 'oci']: self._in_container = True ...
[ "def", "_container_init", "(", "self", ")", ":", "if", "ENV_CONTAINER", "in", "os", ".", "environ", ":", "if", "os", ".", "environ", "[", "ENV_CONTAINER", "]", "in", "[", "'docker'", ",", "'oci'", "]", ":", "self", ".", "_in_container", "=", "True", "i...
Check if sos is running in a container and perform container specific initialisation based on ENV_HOST_SYSROOT.
[ "Check", "if", "sos", "is", "running", "in", "a", "container", "and", "perform", "container", "specific", "initialisation", "based", "on", "ENV_HOST_SYSROOT", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L142-L155
train
sosreport/sos
sos/policies/redhat.py
RHELPolicy.check
def check(cls): """Test to see if the running host is a RHEL installation. Checks for the presence of the "Red Hat Enterprise Linux" release string at the beginning of the NAME field in the `/etc/os-release` file and returns ``True`` if it is found, and ``False``...
python
def check(cls): """Test to see if the running host is a RHEL installation. Checks for the presence of the "Red Hat Enterprise Linux" release string at the beginning of the NAME field in the `/etc/os-release` file and returns ``True`` if it is found, and ``False``...
[ "def", "check", "(", "cls", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "OS_RELEASE", ")", ":", "return", "False", "with", "open", "(", "OS_RELEASE", ",", "\"r\"", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if", "line"...
Test to see if the running host is a RHEL installation. Checks for the presence of the "Red Hat Enterprise Linux" release string at the beginning of the NAME field in the `/etc/os-release` file and returns ``True`` if it is found, and ``False`` otherwise. :r...
[ "Test", "to", "see", "if", "the", "running", "host", "is", "a", "RHEL", "installation", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L274-L295
train
sosreport/sos
sos/plugins/lustre.py
Lustre.get_params
def get_params(self, name, param_list): '''Use lctl get_param to collect a selection of parameters into a file. ''' self.add_cmd_output("lctl get_param %s" % " ".join(param_list), suggest_filename="params-%s" % name, stderr=Fal...
python
def get_params(self, name, param_list): '''Use lctl get_param to collect a selection of parameters into a file. ''' self.add_cmd_output("lctl get_param %s" % " ".join(param_list), suggest_filename="params-%s" % name, stderr=Fal...
[ "def", "get_params", "(", "self", ",", "name", ",", "param_list", ")", ":", "self", ".", "add_cmd_output", "(", "\"lctl get_param %s\"", "%", "\" \"", ".", "join", "(", "param_list", ")", ",", "suggest_filename", "=", "\"params-%s\"", "%", "name", ",", "stde...
Use lctl get_param to collect a selection of parameters into a file.
[ "Use", "lctl", "get_param", "to", "collect", "a", "selection", "of", "parameters", "into", "a", "file", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/lustre.py#L19-L26
train
sosreport/sos
sos/plugins/qpid_dispatch.py
QpidDispatch.setup
def setup(self): """ performs data collection for qpid dispatch router """ options = "" if self.get_option("port"): options = (options + " -b " + gethostname() + ":%s" % (self.get_option("port"))) # gethostname() is due to DISPATCH-156 # for ei...
python
def setup(self): """ performs data collection for qpid dispatch router """ options = "" if self.get_option("port"): options = (options + " -b " + gethostname() + ":%s" % (self.get_option("port"))) # gethostname() is due to DISPATCH-156 # for ei...
[ "def", "setup", "(", "self", ")", ":", "options", "=", "\"\"", "if", "self", ".", "get_option", "(", "\"port\"", ")", ":", "options", "=", "(", "options", "+", "\" -b \"", "+", "gethostname", "(", ")", "+", "\":%s\"", "%", "(", "self", ".", "get_opti...
performs data collection for qpid dispatch router
[ "performs", "data", "collection", "for", "qpid", "dispatch", "router" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/qpid_dispatch.py#L30-L53
train
sosreport/sos
sos/plugins/__init__.py
SoSPredicate.__str
def __str(self, quote=False, prefix="", suffix=""): """Return a string representation of this SoSPredicate with optional prefix, suffix and value quoting. """ quotes = '"%s"' pstr = "dry_run=%s, " % self._dry_run kmods = self._kmods kmods = [quotes % k for k ...
python
def __str(self, quote=False, prefix="", suffix=""): """Return a string representation of this SoSPredicate with optional prefix, suffix and value quoting. """ quotes = '"%s"' pstr = "dry_run=%s, " % self._dry_run kmods = self._kmods kmods = [quotes % k for k ...
[ "def", "__str", "(", "self", ",", "quote", "=", "False", ",", "prefix", "=", "\"\"", ",", "suffix", "=", "\"\"", ")", ":", "quotes", "=", "'\"%s\"'", "pstr", "=", "\"dry_run=%s, \"", "%", "self", ".", "_dry_run", "kmods", "=", "self", ".", "_kmods", ...
Return a string representation of this SoSPredicate with optional prefix, suffix and value quoting.
[ "Return", "a", "string", "representation", "of", "this", "SoSPredicate", "with", "optional", "prefix", "suffix", "and", "value", "quoting", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L117-L132
train
sosreport/sos
sos/plugins/__init__.py
Plugin.do_file_sub
def do_file_sub(self, srcpath, regexp, subst): '''Apply a regexp substitution to a file archived by sosreport. srcpath is the path in the archive where the file can be found. regexp can be a regexp string or a compiled re object. subst is a string to replace each occurance of regexp in...
python
def do_file_sub(self, srcpath, regexp, subst): '''Apply a regexp substitution to a file archived by sosreport. srcpath is the path in the archive where the file can be found. regexp can be a regexp string or a compiled re object. subst is a string to replace each occurance of regexp in...
[ "def", "do_file_sub", "(", "self", ",", "srcpath", ",", "regexp", ",", "subst", ")", ":", "try", ":", "path", "=", "self", ".", "_get_dest_for_srcpath", "(", "srcpath", ")", "self", ".", "_log_debug", "(", "\"substituting scrpath '%s'\"", "%", "srcpath", ")"...
Apply a regexp substitution to a file archived by sosreport. srcpath is the path in the archive where the file can be found. regexp can be a regexp string or a compiled re object. subst is a string to replace each occurance of regexp in the content of srcpath. This function returns th...
[ "Apply", "a", "regexp", "substitution", "to", "a", "file", "archived", "by", "sosreport", ".", "srcpath", "is", "the", "path", "in", "the", "archive", "where", "the", "file", "can", "be", "found", ".", "regexp", "can", "be", "a", "regexp", "string", "or"...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L482-L516
train
sosreport/sos
sos/plugins/__init__.py
Plugin.do_path_regex_sub
def do_path_regex_sub(self, pathexp, regexp, subst): '''Apply a regexp substituation to a set of files archived by sos. The set of files to be substituted is generated by matching collected file pathnames against pathexp which may be a regular expression string or compiled re object. The...
python
def do_path_regex_sub(self, pathexp, regexp, subst): '''Apply a regexp substituation to a set of files archived by sos. The set of files to be substituted is generated by matching collected file pathnames against pathexp which may be a regular expression string or compiled re object. The...
[ "def", "do_path_regex_sub", "(", "self", ",", "pathexp", ",", "regexp", ",", "subst", ")", ":", "if", "not", "hasattr", "(", "pathexp", ",", "\"match\"", ")", ":", "pathexp", "=", "re", ".", "compile", "(", "pathexp", ")", "match", "=", "pathexp", ".",...
Apply a regexp substituation to a set of files archived by sos. The set of files to be substituted is generated by matching collected file pathnames against pathexp which may be a regular expression string or compiled re object. The portion of the file to be replaced is specified via reg...
[ "Apply", "a", "regexp", "substituation", "to", "a", "set", "of", "files", "archived", "by", "sos", ".", "The", "set", "of", "files", "to", "be", "substituted", "is", "generated", "by", "matching", "collected", "file", "pathnames", "against", "pathexp", "whic...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L518-L530
train
sosreport/sos
sos/plugins/__init__.py
Plugin._do_copy_path
def _do_copy_path(self, srcpath, dest=None): '''Copy file or directory to the destination tree. If a directory, then everything below it is recursively copied. A list of copied files are saved for use later in preparing a report. ''' if self._is_forbidden_path(srcpath): ...
python
def _do_copy_path(self, srcpath, dest=None): '''Copy file or directory to the destination tree. If a directory, then everything below it is recursively copied. A list of copied files are saved for use later in preparing a report. ''' if self._is_forbidden_path(srcpath): ...
[ "def", "_do_copy_path", "(", "self", ",", "srcpath", ",", "dest", "=", "None", ")", ":", "if", "self", ".", "_is_forbidden_path", "(", "srcpath", ")", ":", "self", ".", "_log_debug", "(", "\"skipping forbidden path '%s'\"", "%", "srcpath", ")", "return", "''...
Copy file or directory to the destination tree. If a directory, then everything below it is recursively copied. A list of copied files are saved for use later in preparing a report.
[ "Copy", "file", "or", "directory", "to", "the", "destination", "tree", ".", "If", "a", "directory", "then", "everything", "below", "it", "is", "recursively", "copied", ".", "A", "list", "of", "copied", "files", "are", "saved", "for", "use", "later", "in", ...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L627-L678
train
sosreport/sos
sos/plugins/__init__.py
Plugin.set_option
def set_option(self, optionname, value): """Set the named option to value. Ensure the original type of the option value is preserved. """ for name, parms in zip(self.opt_names, self.opt_parms): if name == optionname: # FIXME: ensure that the resulting type ...
python
def set_option(self, optionname, value): """Set the named option to value. Ensure the original type of the option value is preserved. """ for name, parms in zip(self.opt_names, self.opt_parms): if name == optionname: # FIXME: ensure that the resulting type ...
[ "def", "set_option", "(", "self", ",", "optionname", ",", "value", ")", ":", "for", "name", ",", "parms", "in", "zip", "(", "self", ".", "opt_names", ",", "self", ".", "opt_parms", ")", ":", "if", "name", "==", "optionname", ":", "# FIXME: ensure that th...
Set the named option to value. Ensure the original type of the option value is preserved.
[ "Set", "the", "named", "option", "to", "value", ".", "Ensure", "the", "original", "type", "of", "the", "option", "value", "is", "preserved", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L699-L716
train
sosreport/sos
sos/plugins/__init__.py
Plugin.get_option
def get_option(self, optionname, default=0): """Returns the first value that matches 'optionname' in parameters passed in via the command line or set via set_option or via the global_plugin_options dictionary, in that order. optionaname may be iterable, in which case the first option th...
python
def get_option(self, optionname, default=0): """Returns the first value that matches 'optionname' in parameters passed in via the command line or set via set_option or via the global_plugin_options dictionary, in that order. optionaname may be iterable, in which case the first option th...
[ "def", "get_option", "(", "self", ",", "optionname", ",", "default", "=", "0", ")", ":", "global_options", "=", "(", "'verify'", ",", "'all_logs'", ",", "'log_size'", ",", "'plugin_timeout'", ")", "if", "optionname", "in", "global_options", ":", "return", "g...
Returns the first value that matches 'optionname' in parameters passed in via the command line or set via set_option or via the global_plugin_options dictionary, in that order. optionaname may be iterable, in which case the first option that matches any of the option names is returned.
[ "Returns", "the", "first", "value", "that", "matches", "optionname", "in", "parameters", "passed", "in", "via", "the", "command", "line", "or", "set", "via", "set_option", "or", "via", "the", "global_plugin_options", "dictionary", "in", "that", "order", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L718-L738
train
sosreport/sos
sos/plugins/__init__.py
Plugin.get_option_as_list
def get_option_as_list(self, optionname, delimiter=",", default=None): '''Will try to return the option as a list separated by the delimiter. ''' option = self.get_option(optionname) try: opt_list = [opt.strip() for opt in option.split(delimiter)] return l...
python
def get_option_as_list(self, optionname, delimiter=",", default=None): '''Will try to return the option as a list separated by the delimiter. ''' option = self.get_option(optionname) try: opt_list = [opt.strip() for opt in option.split(delimiter)] return l...
[ "def", "get_option_as_list", "(", "self", ",", "optionname", ",", "delimiter", "=", "\",\"", ",", "default", "=", "None", ")", ":", "option", "=", "self", ".", "get_option", "(", "optionname", ")", "try", ":", "opt_list", "=", "[", "opt", ".", "strip", ...
Will try to return the option as a list separated by the delimiter.
[ "Will", "try", "to", "return", "the", "option", "as", "a", "list", "separated", "by", "the", "delimiter", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L740-L749
train
sosreport/sos
sos/plugins/__init__.py
Plugin.add_copy_spec
def add_copy_spec(self, copyspecs, sizelimit=None, tailit=True, pred=None): """Add a file or glob but limit it to sizelimit megabytes. If fname is a single file the file will be tailed to meet sizelimit. If the first file in a glob is too large it will be tailed to meet the sizelimit. ""...
python
def add_copy_spec(self, copyspecs, sizelimit=None, tailit=True, pred=None): """Add a file or glob but limit it to sizelimit megabytes. If fname is a single file the file will be tailed to meet sizelimit. If the first file in a glob is too large it will be tailed to meet the sizelimit. ""...
[ "def", "add_copy_spec", "(", "self", ",", "copyspecs", ",", "sizelimit", "=", "None", ",", "tailit", "=", "True", ",", "pred", "=", "None", ")", ":", "if", "not", "self", ".", "test_predicate", "(", "pred", "=", "pred", ")", ":", "self", ".", "_log_i...
Add a file or glob but limit it to sizelimit megabytes. If fname is a single file the file will be tailed to meet sizelimit. If the first file in a glob is too large it will be tailed to meet the sizelimit.
[ "Add", "a", "file", "or", "glob", "but", "limit", "it", "to", "sizelimit", "megabytes", ".", "If", "fname", "is", "a", "single", "file", "the", "file", "will", "be", "tailed", "to", "meet", "sizelimit", ".", "If", "the", "first", "file", "in", "a", "...
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L754-L827
train
sosreport/sos
sos/plugins/__init__.py
Plugin.call_ext_prog
def call_ext_prog(self, prog, timeout=300, stderr=True, chroot=True, runat=None): """Execute a command independantly of the output gathering part of sosreport. """ return self.get_command_output(prog, timeout=timeout, stderr=stderr, ...
python
def call_ext_prog(self, prog, timeout=300, stderr=True, chroot=True, runat=None): """Execute a command independantly of the output gathering part of sosreport. """ return self.get_command_output(prog, timeout=timeout, stderr=stderr, ...
[ "def", "call_ext_prog", "(", "self", ",", "prog", ",", "timeout", "=", "300", ",", "stderr", "=", "True", ",", "chroot", "=", "True", ",", "runat", "=", "None", ")", ":", "return", "self", ".", "get_command_output", "(", "prog", ",", "timeout", "=", ...
Execute a command independantly of the output gathering part of sosreport.
[ "Execute", "a", "command", "independantly", "of", "the", "output", "gathering", "part", "of", "sosreport", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L862-L868
train
sosreport/sos
sos/plugins/__init__.py
Plugin._add_cmd_output
def _add_cmd_output(self, cmd, suggest_filename=None, root_symlink=None, timeout=300, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None): """Internal helper to add a single command to the collection lis...
python
def _add_cmd_output(self, cmd, suggest_filename=None, root_symlink=None, timeout=300, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None): """Internal helper to add a single command to the collection lis...
[ "def", "_add_cmd_output", "(", "self", ",", "cmd", ",", "suggest_filename", "=", "None", ",", "root_symlink", "=", "None", ",", "timeout", "=", "300", ",", "stderr", "=", "True", ",", "chroot", "=", "True", ",", "runat", "=", "None", ",", "env", "=", ...
Internal helper to add a single command to the collection list.
[ "Internal", "helper", "to", "add", "a", "single", "command", "to", "the", "collection", "list", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L877-L896
train
sosreport/sos
sos/plugins/__init__.py
Plugin.add_cmd_output
def add_cmd_output(self, cmds, suggest_filename=None, root_symlink=None, timeout=300, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None): """Run a program or a list of programs and collect the output""" ...
python
def add_cmd_output(self, cmds, suggest_filename=None, root_symlink=None, timeout=300, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None): """Run a program or a list of programs and collect the output""" ...
[ "def", "add_cmd_output", "(", "self", ",", "cmds", ",", "suggest_filename", "=", "None", ",", "root_symlink", "=", "None", ",", "timeout", "=", "300", ",", "stderr", "=", "True", ",", "chroot", "=", "True", ",", "runat", "=", "None", ",", "env", "=", ...
Run a program or a list of programs and collect the output
[ "Run", "a", "program", "or", "a", "list", "of", "programs", "and", "collect", "the", "output" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L898-L914
train
sosreport/sos
sos/plugins/__init__.py
Plugin.get_cmd_output_path
def get_cmd_output_path(self, name=None, make=True): """Return a path into which this module should store collected command output """ cmd_output_path = os.path.join(self.archive.get_tmp_dir(), 'sos_commands', self.name()) if name: ...
python
def get_cmd_output_path(self, name=None, make=True): """Return a path into which this module should store collected command output """ cmd_output_path = os.path.join(self.archive.get_tmp_dir(), 'sos_commands', self.name()) if name: ...
[ "def", "get_cmd_output_path", "(", "self", ",", "name", "=", "None", ",", "make", "=", "True", ")", ":", "cmd_output_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "archive", ".", "get_tmp_dir", "(", ")", ",", "'sos_commands'", ",", "sel...
Return a path into which this module should store collected command output
[ "Return", "a", "path", "into", "which", "this", "module", "should", "store", "collected", "command", "output" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L916-L927
train
sosreport/sos
sos/plugins/__init__.py
Plugin._make_command_filename
def _make_command_filename(self, exe): """The internal function to build up a filename based on a command.""" outfn = os.path.join(self.commons['cmddir'], self.name(), self._mangle_command(exe)) # check for collisions if os.path.exists(outfn): i...
python
def _make_command_filename(self, exe): """The internal function to build up a filename based on a command.""" outfn = os.path.join(self.commons['cmddir'], self.name(), self._mangle_command(exe)) # check for collisions if os.path.exists(outfn): i...
[ "def", "_make_command_filename", "(", "self", ",", "exe", ")", ":", "outfn", "=", "os", ".", "path", ".", "join", "(", "self", ".", "commons", "[", "'cmddir'", "]", ",", "self", ".", "name", "(", ")", ",", "self", ".", "_mangle_command", "(", "exe", ...
The internal function to build up a filename based on a command.
[ "The", "internal", "function", "to", "build", "up", "a", "filename", "based", "on", "a", "command", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L940-L956
train
sosreport/sos
sos/plugins/__init__.py
Plugin.add_string_as_file
def add_string_as_file(self, content, filename, pred=None): """Add a string to the archive as a file named `filename`""" # Generate summary string for logging summary = content.splitlines()[0] if content else '' if not isinstance(summary, six.string_types): summary = content...
python
def add_string_as_file(self, content, filename, pred=None): """Add a string to the archive as a file named `filename`""" # Generate summary string for logging summary = content.splitlines()[0] if content else '' if not isinstance(summary, six.string_types): summary = content...
[ "def", "add_string_as_file", "(", "self", ",", "content", ",", "filename", ",", "pred", "=", "None", ")", ":", "# Generate summary string for logging", "summary", "=", "content", ".", "splitlines", "(", ")", "[", "0", "]", "if", "content", "else", "''", "if"...
Add a string to the archive as a file named `filename`
[ "Add", "a", "string", "to", "the", "archive", "as", "a", "file", "named", "filename" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L958-L972
train
sosreport/sos
sos/plugins/__init__.py
Plugin.add_journal
def add_journal(self, units=None, boot=None, since=None, until=None, lines=None, allfields=False, output=None, timeout=None, identifier=None, catalog=None, sizelimit=None, pred=None): """Collect journald logs from one of more units. :param units: A string, or lis...
python
def add_journal(self, units=None, boot=None, since=None, until=None, lines=None, allfields=False, output=None, timeout=None, identifier=None, catalog=None, sizelimit=None, pred=None): """Collect journald logs from one of more units. :param units: A string, or lis...
[ "def", "add_journal", "(", "self", ",", "units", "=", "None", ",", "boot", "=", "None", ",", "since", "=", "None", ",", "until", "=", "None", ",", "lines", "=", "None", ",", "allfields", "=", "False", ",", "output", "=", "None", ",", "timeout", "="...
Collect journald logs from one of more units. :param units: A string, or list of strings specifying the systemd units for which journal entries will be collected. :param boot: A string selecting a boot index using the journalctl synta...
[ "Collect", "journald", "logs", "from", "one", "of", "more", "units", "." ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1046-L1133
train
sosreport/sos
sos/plugins/__init__.py
Plugin.add_udev_info
def add_udev_info(self, device, attrs=False): """Collect udevadm info output for a given device :param device: A string or list of strings of device names or sysfs paths. E.G. either '/sys/class/scsi_host/host0' or '/dev/sda' is valid. :param attrs:...
python
def add_udev_info(self, device, attrs=False): """Collect udevadm info output for a given device :param device: A string or list of strings of device names or sysfs paths. E.G. either '/sys/class/scsi_host/host0' or '/dev/sda' is valid. :param attrs:...
[ "def", "add_udev_info", "(", "self", ",", "device", ",", "attrs", "=", "False", ")", ":", "udev_cmd", "=", "'udevadm info'", "if", "attrs", ":", "udev_cmd", "+=", "' -a'", "if", "isinstance", "(", "device", ",", "six", ".", "string_types", ")", ":", "dev...
Collect udevadm info output for a given device :param device: A string or list of strings of device names or sysfs paths. E.G. either '/sys/class/scsi_host/host0' or '/dev/sda' is valid. :param attrs: If True, run udevadm with the --attribute-walk option.
[ "Collect", "udevadm", "info", "output", "for", "a", "given", "device" ]
2ebc04da53dc871c8dd5243567afa4f8592dca29
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1135-L1152
train