repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
cmap/cmapPy
cmapPy/pandasGEXpress/concat.py
assemble_concatenated_meta
def assemble_concatenated_meta(concated_meta_dfs, remove_all_metadata_fields): """ Assemble the concatenated metadata dfs together. For example, if horizontally concatenating, the concatenated metadata dfs are the column metadata dfs. Both indices are sorted. Args: concated_meta_dfs (list of pa...
python
def assemble_concatenated_meta(concated_meta_dfs, remove_all_metadata_fields): """ Assemble the concatenated metadata dfs together. For example, if horizontally concatenating, the concatenated metadata dfs are the column metadata dfs. Both indices are sorted. Args: concated_meta_dfs (list of pa...
Assemble the concatenated metadata dfs together. For example, if horizontally concatenating, the concatenated metadata dfs are the column metadata dfs. Both indices are sorted. Args: concated_meta_dfs (list of pandas dfs) Returns: all_concated_meta_df_sorted (pandas df)
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/concat.py#L423-L452
cmap/cmapPy
cmapPy/pandasGEXpress/concat.py
assemble_data
def assemble_data(data_dfs, concat_direction): """ Assemble the data dfs together. Both indices are sorted. Args: data_dfs (list of pandas dfs) concat_direction (string): 'horiz' or 'vert' Returns: all_data_df_sorted (pandas df) """ if concat_direction == "horiz": ...
python
def assemble_data(data_dfs, concat_direction): """ Assemble the data dfs together. Both indices are sorted. Args: data_dfs (list of pandas dfs) concat_direction (string): 'horiz' or 'vert' Returns: all_data_df_sorted (pandas df) """ if concat_direction == "horiz": ...
Assemble the data dfs together. Both indices are sorted. Args: data_dfs (list of pandas dfs) concat_direction (string): 'horiz' or 'vert' Returns: all_data_df_sorted (pandas df)
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/concat.py#L455-L492
cmap/cmapPy
cmapPy/pandasGEXpress/concat.py
do_reset_ids
def do_reset_ids(concatenated_meta_df, data_df, concat_direction): """ Reset ids in concatenated metadata and data dfs to unique integers and save the old ids in a metadata column. Note that the dataframes are modified in-place. Args: concatenated_meta_df (pandas df) data_df (pandas df...
python
def do_reset_ids(concatenated_meta_df, data_df, concat_direction): """ Reset ids in concatenated metadata and data dfs to unique integers and save the old ids in a metadata column. Note that the dataframes are modified in-place. Args: concatenated_meta_df (pandas df) data_df (pandas df...
Reset ids in concatenated metadata and data dfs to unique integers and save the old ids in a metadata column. Note that the dataframes are modified in-place. Args: concatenated_meta_df (pandas df) data_df (pandas df) concat_direction (string): 'horiz' or 'vert' Returns: ...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/concat.py#L495-L534
cmap/cmapPy
cmapPy/pandasGEXpress/concat.py
reset_ids_in_meta_df
def reset_ids_in_meta_df(meta_df): """ Meta_df is modified inplace. """ # Record original index name, and then change it so that the column that it # becomes will be appropriately named original_index_name = meta_df.index.name meta_df.index.name = "old_id" # Reset index meta_df.reset_index...
python
def reset_ids_in_meta_df(meta_df): """ Meta_df is modified inplace. """ # Record original index name, and then change it so that the column that it # becomes will be appropriately named original_index_name = meta_df.index.name meta_df.index.name = "old_id" # Reset index meta_df.reset_index...
Meta_df is modified inplace.
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/concat.py#L537-L549
cmap/cmapPy
cmapPy/pandasGEXpress/subset_gctoo.py
subset_gctoo
def subset_gctoo(gctoo, row_bool=None, col_bool=None, rid=None, cid=None, ridx=None, cidx=None, exclude_rid=None, exclude_cid=None): """ Extract a subset of data from a GCToo object in a variety of ways. The order of rows and columns will be preserved. Args: gctoo (GCToo object) ...
python
def subset_gctoo(gctoo, row_bool=None, col_bool=None, rid=None, cid=None, ridx=None, cidx=None, exclude_rid=None, exclude_cid=None): """ Extract a subset of data from a GCToo object in a variety of ways. The order of rows and columns will be preserved. Args: gctoo (GCToo object) ...
Extract a subset of data from a GCToo object in a variety of ways. The order of rows and columns will be preserved. Args: gctoo (GCToo object) row_bool (list of bools): length must equal gctoo.data_df.shape[0] col_bool (list of bools): length must equal gctoo.data_df.shape[1] ri...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/subset_gctoo.py#L19-L65
cmap/cmapPy
cmapPy/pandasGEXpress/subset_gctoo.py
get_rows_to_keep
def get_rows_to_keep(gctoo, rid=None, row_bool=None, ridx=None, exclude_rid=None): """ Figure out based on the possible row inputs which rows to keep. Args: gctoo (GCToo object): rid (list of strings): row_bool (boolean array): ridx (list of integers): exclude_rid (list ...
python
def get_rows_to_keep(gctoo, rid=None, row_bool=None, ridx=None, exclude_rid=None): """ Figure out based on the possible row inputs which rows to keep. Args: gctoo (GCToo object): rid (list of strings): row_bool (boolean array): ridx (list of integers): exclude_rid (list ...
Figure out based on the possible row inputs which rows to keep. Args: gctoo (GCToo object): rid (list of strings): row_bool (boolean array): ridx (list of integers): exclude_rid (list of strings): Returns: rows_to_keep (list of strings): row ids to be kept
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/subset_gctoo.py#L68-L126
cmap/cmapPy
cmapPy/pandasGEXpress/subset_gctoo.py
get_cols_to_keep
def get_cols_to_keep(gctoo, cid=None, col_bool=None, cidx=None, exclude_cid=None): """ Figure out based on the possible columns inputs which columns to keep. Args: gctoo (GCToo object): cid (list of strings): col_bool (boolean array): cidx (list of integers): exclude_cid...
python
def get_cols_to_keep(gctoo, cid=None, col_bool=None, cidx=None, exclude_cid=None): """ Figure out based on the possible columns inputs which columns to keep. Args: gctoo (GCToo object): cid (list of strings): col_bool (boolean array): cidx (list of integers): exclude_cid...
Figure out based on the possible columns inputs which columns to keep. Args: gctoo (GCToo object): cid (list of strings): col_bool (boolean array): cidx (list of integers): exclude_cid (list of strings): Returns: cols_to_keep (list of strings): col ids to be kep...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/subset_gctoo.py#L129-L188
cmap/cmapPy
cmapPy/set_io/grp.py
read
def read(in_path): """ Read a grp file at the path specified by in_path. Args: in_path (string): path to GRP file Returns: grp (list) """ assert os.path.exists(in_path), "The following GRP file can't be found. in_path: {}".format(in_path) with open(in_path, "r") as f: ...
python
def read(in_path): """ Read a grp file at the path specified by in_path. Args: in_path (string): path to GRP file Returns: grp (list) """ assert os.path.exists(in_path), "The following GRP file can't be found. in_path: {}".format(in_path) with open(in_path, "r") as f: ...
Read a grp file at the path specified by in_path. Args: in_path (string): path to GRP file Returns: grp (list)
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/set_io/grp.py#L16-L33
cmap/cmapPy
cmapPy/set_io/grp.py
write
def write(grp, out_path): """ Write a GRP to a text file. Args: grp (list): GRP object to write to new-line delimited text file out_path (string): output path Returns: None """ with open(out_path, "w") as f: for x in grp: f.write(str(x) + "\n")
python
def write(grp, out_path): """ Write a GRP to a text file. Args: grp (list): GRP object to write to new-line delimited text file out_path (string): output path Returns: None """ with open(out_path, "w") as f: for x in grp: f.write(str(x) + "\n")
Write a GRP to a text file. Args: grp (list): GRP object to write to new-line delimited text file out_path (string): output path Returns: None
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/set_io/grp.py#L36-L49
cmap/cmapPy
cmapPy/math/fast_corr.py
fast_corr
def fast_corr(x, y=None, destination=None): """calculate the pearson correlation matrix for the columns of x (with dimensions MxN), or optionally, the pearson correlaton matrix between x and y (with dimensions OxP). If destination is provided, put the results there. In the language of statistics the colu...
python
def fast_corr(x, y=None, destination=None): """calculate the pearson correlation matrix for the columns of x (with dimensions MxN), or optionally, the pearson correlaton matrix between x and y (with dimensions OxP). If destination is provided, put the results there. In the language of statistics the colu...
calculate the pearson correlation matrix for the columns of x (with dimensions MxN), or optionally, the pearson correlaton matrix between x and y (with dimensions OxP). If destination is provided, put the results there. In the language of statistics the columns are the variables and the rows are the observat...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/math/fast_corr.py#L11-L37
cmap/cmapPy
cmapPy/math/fast_corr.py
fast_spearman
def fast_spearman(x, y=None, destination=None): """calculate the spearman correlation matrix for the columns of x (with dimensions MxN), or optionally, the spearman correlaton matrix between the columns of x and the columns of y (with dimensions OxP). If destination is provided, put the results there. In t...
python
def fast_spearman(x, y=None, destination=None): """calculate the spearman correlation matrix for the columns of x (with dimensions MxN), or optionally, the spearman correlaton matrix between the columns of x and the columns of y (with dimensions OxP). If destination is provided, put the results there. In t...
calculate the spearman correlation matrix for the columns of x (with dimensions MxN), or optionally, the spearman correlaton matrix between the columns of x and the columns of y (with dimensions OxP). If destination is provided, put the results there. In the language of statistics the columns are the variables...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/math/fast_corr.py#L40-L65
cmap/cmapPy
cmapPy/pandasGEXpress/random_slice.py
make_specified_size_gctoo
def make_specified_size_gctoo(og_gctoo, num_entries, dim): """ Subsets a GCToo instance along either rows or columns to obtain a specified size. Input: - og_gctoo (GCToo): a GCToo instance - num_entries (int): the number of entries to keep - dim (str): the dimension along which to subset. Must be "row" or...
python
def make_specified_size_gctoo(og_gctoo, num_entries, dim): """ Subsets a GCToo instance along either rows or columns to obtain a specified size. Input: - og_gctoo (GCToo): a GCToo instance - num_entries (int): the number of entries to keep - dim (str): the dimension along which to subset. Must be "row" or...
Subsets a GCToo instance along either rows or columns to obtain a specified size. Input: - og_gctoo (GCToo): a GCToo instance - num_entries (int): the number of entries to keep - dim (str): the dimension along which to subset. Must be "row" or "col" Output: - new_gctoo (GCToo): the GCToo instance subsetted...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/random_slice.py#L15-L55
cmap/cmapPy
cmapPy/clue_api_client/clue_api_client.py
ClueApiClient.run_filter_query
def run_filter_query(self, resource_name, filter_clause): """run a query (get) against the CLUE api, using the API and user key fields of self and the fitler_clause provided Args: resource_name: str - name of the resource / collection to query - e.g. genes, perts, cells etc. fil...
python
def run_filter_query(self, resource_name, filter_clause): """run a query (get) against the CLUE api, using the API and user key fields of self and the fitler_clause provided Args: resource_name: str - name of the resource / collection to query - e.g. genes, perts, cells etc. fil...
run a query (get) against the CLUE api, using the API and user key fields of self and the fitler_clause provided Args: resource_name: str - name of the resource / collection to query - e.g. genes, perts, cells etc. filter_clause: dictionary - contains filter to pass to API to; uses loop...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/clue_api_client/clue_api_client.py#L28-L45
cmap/cmapPy
cmapPy/pandasGEXpress/write_gctx.py
write
def write(gctoo_object, out_file_name, convert_back_to_neg_666=True, gzip_compression_level=6, max_chunk_kb=1024, matrix_dtype=numpy.float32): """ Writes a GCToo instance to specified file. Input: - gctoo_object (GCToo): A GCToo instance. - out_file_name (str): file name to write gctoo_object to. ...
python
def write(gctoo_object, out_file_name, convert_back_to_neg_666=True, gzip_compression_level=6, max_chunk_kb=1024, matrix_dtype=numpy.float32): """ Writes a GCToo instance to specified file. Input: - gctoo_object (GCToo): A GCToo instance. - out_file_name (str): file name to write gctoo_object to. ...
Writes a GCToo instance to specified file. Input: - gctoo_object (GCToo): A GCToo instance. - out_file_name (str): file name to write gctoo_object to. - convert_back_to_neg_666 (bool): whether to convert np.NAN in metadata back to "-666" - gzip_compression_level (int, default=6): Compression level...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/write_gctx.py#L19-L61
cmap/cmapPy
cmapPy/pandasGEXpress/write_gctx.py
write_src
def write_src(hdf5_out, gctoo_object, out_file_name): """ Writes src as attribute of gctx out file. Input: - hdf5_out (h5py): hdf5 file to write to - gctoo_object (GCToo): GCToo instance to be written to .gctx - out_file_name (str): name of hdf5 out file. """ if gctoo_object.src == None: hd...
python
def write_src(hdf5_out, gctoo_object, out_file_name): """ Writes src as attribute of gctx out file. Input: - hdf5_out (h5py): hdf5 file to write to - gctoo_object (GCToo): GCToo instance to be written to .gctx - out_file_name (str): name of hdf5 out file. """ if gctoo_object.src == None: hd...
Writes src as attribute of gctx out file. Input: - hdf5_out (h5py): hdf5 file to write to - gctoo_object (GCToo): GCToo instance to be written to .gctx - out_file_name (str): name of hdf5 out file.
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/write_gctx.py#L80-L92
cmap/cmapPy
cmapPy/pandasGEXpress/write_gctx.py
calculate_elem_per_kb
def calculate_elem_per_kb(max_chunk_kb, matrix_dtype): """ Calculates the number of elem per kb depending on the max chunk size set. Input: - max_chunk_kb (int, default=1024): The maximum number of KB a given chunk will occupy - matrix_dtype (numpy dtype, default=numpy.float32): Storage d...
python
def calculate_elem_per_kb(max_chunk_kb, matrix_dtype): """ Calculates the number of elem per kb depending on the max chunk size set. Input: - max_chunk_kb (int, default=1024): The maximum number of KB a given chunk will occupy - matrix_dtype (numpy dtype, default=numpy.float32): Storage d...
Calculates the number of elem per kb depending on the max chunk size set. Input: - max_chunk_kb (int, default=1024): The maximum number of KB a given chunk will occupy - matrix_dtype (numpy dtype, default=numpy.float32): Storage data type for data matrix. Currently needs to be np.flo...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/write_gctx.py#L104-L123
cmap/cmapPy
cmapPy/pandasGEXpress/write_gctx.py
set_data_matrix_chunk_size
def set_data_matrix_chunk_size(df_shape, max_chunk_kb, elem_per_kb): """ Sets chunk size to use for writing data matrix. Note. Calculation used here is for compatibility with cmapM and cmapR. Input: - df_shape (tuple): shape of input data_df. - max_chunk_kb (int, default=1024): The m...
python
def set_data_matrix_chunk_size(df_shape, max_chunk_kb, elem_per_kb): """ Sets chunk size to use for writing data matrix. Note. Calculation used here is for compatibility with cmapM and cmapR. Input: - df_shape (tuple): shape of input data_df. - max_chunk_kb (int, default=1024): The m...
Sets chunk size to use for writing data matrix. Note. Calculation used here is for compatibility with cmapM and cmapR. Input: - df_shape (tuple): shape of input data_df. - max_chunk_kb (int, default=1024): The maximum number of KB a given chunk will occupy - elem_per_kb (int): Number...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/write_gctx.py#L126-L141
cmap/cmapPy
cmapPy/pandasGEXpress/write_gctx.py
write_metadata
def write_metadata(hdf5_out, dim, metadata_df, convert_back_to_neg_666, gzip_compression): """ Writes either column or row metadata to proper node of gctx out (hdf5) file. Input: - hdf5_out (h5py): open hdf5 file to write to - dim (str; must be "row" or "col"): dimension of metadata to write to - metadata...
python
def write_metadata(hdf5_out, dim, metadata_df, convert_back_to_neg_666, gzip_compression): """ Writes either column or row metadata to proper node of gctx out (hdf5) file. Input: - hdf5_out (h5py): open hdf5 file to write to - dim (str; must be "row" or "col"): dimension of metadata to write to - metadata...
Writes either column or row metadata to proper node of gctx out (hdf5) file. Input: - hdf5_out (h5py): open hdf5 file to write to - dim (str; must be "row" or "col"): dimension of metadata to write to - metadata_df (pandas DataFrame): metadata DataFrame to write to file - convert_back_to_neg_666 (bool): Whe...
https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/write_gctx.py#L143-L182
danfairs/django-lazysignup
lazysignup/models.py
LazyUserManager.create_lazy_user
def create_lazy_user(self): """ Create a lazy user. Returns a 2-tuple of the underlying User object (which may be of a custom class), and the username. """ user_class = self.model.get_user_class() username = self.generate_username(user_class) user = user_class.objects.cre...
python
def create_lazy_user(self): """ Create a lazy user. Returns a 2-tuple of the underlying User object (which may be of a custom class), and the username. """ user_class = self.model.get_user_class() username = self.generate_username(user_class) user = user_class.objects.cre...
Create a lazy user. Returns a 2-tuple of the underlying User object (which may be of a custom class), and the username.
https://github.com/danfairs/django-lazysignup/blob/cfe77e12976d439e1a5aae4387531b2f0f835c6a/lazysignup/models.py#L37-L45
danfairs/django-lazysignup
lazysignup/models.py
LazyUserManager.convert
def convert(self, form): """ Convert a lazy user to a non-lazy one. The form passed in is expected to be a ModelForm instance, bound to the user to be converted. The converted ``User`` object is returned. Raises a TypeError if the user is not lazy. """ if not is...
python
def convert(self, form): """ Convert a lazy user to a non-lazy one. The form passed in is expected to be a ModelForm instance, bound to the user to be converted. The converted ``User`` object is returned. Raises a TypeError if the user is not lazy. """ if not is...
Convert a lazy user to a non-lazy one. The form passed in is expected to be a ModelForm instance, bound to the user to be converted. The converted ``User`` object is returned. Raises a TypeError if the user is not lazy.
https://github.com/danfairs/django-lazysignup/blob/cfe77e12976d439e1a5aae4387531b2f0f835c6a/lazysignup/models.py#L47-L65
danfairs/django-lazysignup
lazysignup/models.py
LazyUserManager.generate_username
def generate_username(self, user_class): """ Generate a new username for a user """ m = getattr(user_class, 'generate_username', None) if m: return m() else: max_length = user_class._meta.get_field( self.username_field).max_length ...
python
def generate_username(self, user_class): """ Generate a new username for a user """ m = getattr(user_class, 'generate_username', None) if m: return m() else: max_length = user_class._meta.get_field( self.username_field).max_length ...
Generate a new username for a user
https://github.com/danfairs/django-lazysignup/blob/cfe77e12976d439e1a5aae4387531b2f0f835c6a/lazysignup/models.py#L67-L76
danfairs/django-lazysignup
lazysignup/views.py
convert
def convert(request, form_class=None, redirect_field_name='redirect_to', anonymous_redirect=settings.LOGIN_URL, template_name='lazysignup/convert.html', ajax_template_name='lazysignup/convert_ajax.html'): """ Convert a temporary user to a real one. Reject users who do...
python
def convert(request, form_class=None, redirect_field_name='redirect_to', anonymous_redirect=settings.LOGIN_URL, template_name='lazysignup/convert.html', ajax_template_name='lazysignup/convert_ajax.html'): """ Convert a temporary user to a real one. Reject users who do...
Convert a temporary user to a real one. Reject users who don't appear to be temporary users (ie. they have a usable password)
https://github.com/danfairs/django-lazysignup/blob/cfe77e12976d439e1a5aae4387531b2f0f835c6a/lazysignup/views.py#L19-L84
danfairs/django-lazysignup
lazysignup/utils.py
is_lazy_user
def is_lazy_user(user): """ Return True if the passed user is a lazy user. """ # Anonymous users are not lazy. if user.is_anonymous: return False # Check the user backend. If the lazy signup backend # authenticated them, then the user is lazy. backend = getattr(user, 'backend', None) ...
python
def is_lazy_user(user): """ Return True if the passed user is a lazy user. """ # Anonymous users are not lazy. if user.is_anonymous: return False # Check the user backend. If the lazy signup backend # authenticated them, then the user is lazy. backend = getattr(user, 'backend', None) ...
Return True if the passed user is a lazy user.
https://github.com/danfairs/django-lazysignup/blob/cfe77e12976d439e1a5aae4387531b2f0f835c6a/lazysignup/utils.py#L1-L16
bslatkin/dpxdt
dpxdt/server/work_queue.py
add
def add(queue_name, payload=None, content_type=None, source=None, task_id=None, build_id=None, release_id=None, run_id=None): """Adds a work item to a queue. Args: queue_name: Name of the queue to add the work item to. payload: Optional. Payload that describes the work to do as a string...
python
def add(queue_name, payload=None, content_type=None, source=None, task_id=None, build_id=None, release_id=None, run_id=None): """Adds a work item to a queue. Args: queue_name: Name of the queue to add the work item to. payload: Optional. Payload that describes the work to do as a string...
Adds a work item to a queue. Args: queue_name: Name of the queue to add the work item to. payload: Optional. Payload that describes the work to do as a string. If not a string and content_type is not provided, then this function assumes the payload is a JSON-able Python obje...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L100-L145
bslatkin/dpxdt
dpxdt/server/work_queue.py
_task_to_dict
def _task_to_dict(task): """Converts a WorkQueue to a JSON-able dictionary.""" payload = task.payload if payload and task.content_type == 'application/json': payload = json.loads(payload) return dict( task_id=task.task_id, queue_name=task.queue_name, eta=_datetime_to_epo...
python
def _task_to_dict(task): """Converts a WorkQueue to a JSON-able dictionary.""" payload = task.payload if payload and task.content_type == 'application/json': payload = json.loads(payload) return dict( task_id=task.task_id, queue_name=task.queue_name, eta=_datetime_to_epo...
Converts a WorkQueue to a JSON-able dictionary.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L155-L170
bslatkin/dpxdt
dpxdt/server/work_queue.py
lease
def lease(queue_name, owner, count=1, timeout_seconds=60): """Leases a work item from a queue, usually the oldest task available. Args: queue_name: Name of the queue to lease work from. owner: Who or what is leasing the task. count: Lease up to this many tasks. Return value will never h...
python
def lease(queue_name, owner, count=1, timeout_seconds=60): """Leases a work item from a queue, usually the oldest task available. Args: queue_name: Name of the queue to lease work from. owner: Who or what is leasing the task. count: Lease up to this many tasks. Return value will never h...
Leases a work item from a queue, usually the oldest task available. Args: queue_name: Name of the queue to lease work from. owner: Who or what is leasing the task. count: Lease up to this many tasks. Return value will never have more than this many items present. timeout...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L177-L216
bslatkin/dpxdt
dpxdt/server/work_queue.py
_get_task_with_policy
def _get_task_with_policy(queue_name, task_id, owner): """Fetches the specified task and enforces ownership policy. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. Returns: ...
python
def _get_task_with_policy(queue_name, task_id, owner): """Fetches the specified task and enforces ownership policy. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. Returns: ...
Fetches the specified task and enforces ownership policy. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. Returns: The valid WorkQueue task that is currently owned. Rai...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L219-L256
bslatkin/dpxdt
dpxdt/server/work_queue.py
heartbeat
def heartbeat(queue_name, task_id, owner, message, index): """Sets the heartbeat status of the task and extends its lease. The task's lease is extended by the same amount as its last lease to ensure that any operations following the heartbeat will still hold the lock for the original lock period. ...
python
def heartbeat(queue_name, task_id, owner, message, index): """Sets the heartbeat status of the task and extends its lease. The task's lease is extended by the same amount as its last lease to ensure that any operations following the heartbeat will still hold the lock for the original lock period. ...
Sets the heartbeat status of the task and extends its lease. The task's lease is extended by the same amount as its last lease to ensure that any operations following the heartbeat will still hold the lock for the original lock period. Args: queue_name: Name of the queue the work item is on. ...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L259-L303
bslatkin/dpxdt
dpxdt/server/work_queue.py
finish
def finish(queue_name, task_id, owner, error=False): """Marks a work item on a queue as finished. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. error: Defaults to false. Tr...
python
def finish(queue_name, task_id, owner, error=False): """Marks a work item on a queue as finished. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. error: Defaults to false. Tr...
Marks a work item on a queue as finished. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. error: Defaults to false. True if this task's final state is an error. Returns: ...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L306-L342
bslatkin/dpxdt
dpxdt/server/work_queue.py
_query
def _query(queue_name=None, build_id=None, release_id=None, run_id=None, count=None): """Queries for work items based on their criteria. Args: queue_name: Optional queue name to restrict to. build_id: Optional build ID to restrict to. release_id: Optional release ID to restri...
python
def _query(queue_name=None, build_id=None, release_id=None, run_id=None, count=None): """Queries for work items based on their criteria. Args: queue_name: Optional queue name to restrict to. build_id: Optional build ID to restrict to. release_id: Optional release ID to restri...
Queries for work items based on their criteria. Args: queue_name: Optional queue name to restrict to. build_id: Optional build ID to restrict to. release_id: Optional release ID to restrict to. run_id: Optional run ID to restrict to. count: How many tasks to fetch. Defaults ...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L345-L377
bslatkin/dpxdt
dpxdt/server/work_queue.py
query
def query(**kwargs): """Queries for work items based on their criteria. Args: queue_name: Optional queue name to restrict to. build_id: Optional build ID to restrict to. release_id: Optional release ID to restrict to. run_id: Optional run ID to restrict to. count: How ma...
python
def query(**kwargs): """Queries for work items based on their criteria. Args: queue_name: Optional queue name to restrict to. build_id: Optional build ID to restrict to. release_id: Optional release ID to restrict to. run_id: Optional run ID to restrict to. count: How ma...
Queries for work items based on their criteria. Args: queue_name: Optional queue name to restrict to. build_id: Optional build ID to restrict to. release_id: Optional release ID to restrict to. run_id: Optional run ID to restrict to. count: How many tasks to fetch. Defaults ...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L380-L407
bslatkin/dpxdt
dpxdt/server/work_queue.py
cancel
def cancel(**kwargs): """Cancels work items based on their criteria. Args: **kwargs: Same parameters as the query() method. Returns: The number of tasks that were canceled. """ task_list = _query(**kwargs) for task in task_list: task.status = WorkQueue.CANCELED ...
python
def cancel(**kwargs): """Cancels work items based on their criteria. Args: **kwargs: Same parameters as the query() method. Returns: The number of tasks that were canceled. """ task_list = _query(**kwargs) for task in task_list: task.status = WorkQueue.CANCELED ...
Cancels work items based on their criteria. Args: **kwargs: Same parameters as the query() method. Returns: The number of tasks that were canceled.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L410-L424
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
handle_add
def handle_add(queue_name): """Adds a task to a queue.""" source = request.form.get('source', request.remote_addr, type=str) try: task_id = work_queue.add( queue_name, payload=request.form.get('payload', type=str), content_type=request.form.get('content_type', typ...
python
def handle_add(queue_name): """Adds a task to a queue.""" source = request.form.get('source', request.remote_addr, type=str) try: task_id = work_queue.add( queue_name, payload=request.form.get('payload', type=str), content_type=request.form.get('content_type', typ...
Adds a task to a queue.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L37-L53
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
handle_lease
def handle_lease(queue_name): """Leases a task from a queue.""" owner = request.form.get('owner', request.remote_addr, type=str) try: task_list = work_queue.lease( queue_name, owner, request.form.get('count', 1, type=int), request.form.get('timeout', 6...
python
def handle_lease(queue_name): """Leases a task from a queue.""" owner = request.form.get('owner', request.remote_addr, type=str) try: task_list = work_queue.lease( queue_name, owner, request.form.get('count', 1, type=int), request.form.get('timeout', 6...
Leases a task from a queue.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L59-L78
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
handle_heartbeat
def handle_heartbeat(queue_name): """Updates the heartbeat message for a task.""" task_id = request.form.get('task_id', type=str) message = request.form.get('message', type=str) index = request.form.get('index', type=int) try: work_queue.heartbeat( queue_name, task_id...
python
def handle_heartbeat(queue_name): """Updates the heartbeat message for a task.""" task_id = request.form.get('task_id', type=str) message = request.form.get('message', type=str) index = request.form.get('index', type=int) try: work_queue.heartbeat( queue_name, task_id...
Updates the heartbeat message for a task.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L84-L102
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
handle_finish
def handle_finish(queue_name): """Marks a task on a queue as finished.""" task_id = request.form.get('task_id', type=str) owner = request.form.get('owner', request.remote_addr, type=str) error = request.form.get('error', type=str) is not None try: work_queue.finish(queue_name, task_id, owner...
python
def handle_finish(queue_name): """Marks a task on a queue as finished.""" task_id = request.form.get('task_id', type=str) owner = request.form.get('owner', request.remote_addr, type=str) error = request.form.get('error', type=str) is not None try: work_queue.finish(queue_name, task_id, owner...
Marks a task on a queue as finished.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L108-L121
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
view_all_work_queues
def view_all_work_queues(): """Page for viewing the index of all active work queues.""" count_list = list( db.session.query( work_queue.WorkQueue.queue_name, work_queue.WorkQueue.status, func.count(work_queue.WorkQueue.task_id)) .group_by(work_queue.WorkQueue....
python
def view_all_work_queues(): """Page for viewing the index of all active work queues.""" count_list = list( db.session.query( work_queue.WorkQueue.queue_name, work_queue.WorkQueue.status, func.count(work_queue.WorkQueue.task_id)) .group_by(work_queue.WorkQueue....
Page for viewing the index of all active work queues.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L126-L169
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
manage_work_queue
def manage_work_queue(queue_name): """Page for viewing the contents of a work queue.""" modify_form = forms.ModifyWorkQueueTaskForm() if modify_form.validate_on_submit(): primary_key = (modify_form.task_id.data, queue_name) task = work_queue.WorkQueue.query.get(primary_key) if task: ...
python
def manage_work_queue(queue_name): """Page for viewing the contents of a work queue.""" modify_form = forms.ModifyWorkQueueTaskForm() if modify_form.validate_on_submit(): primary_key = (modify_form.task_id.data, queue_name) task = work_queue.WorkQueue.query.get(primary_key) if task: ...
Page for viewing the contents of a work queue.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L174-L220
bslatkin/dpxdt
dpxdt/server/utils.py
retryable_transaction
def retryable_transaction(attempts=3, exceptions=(OperationalError,)): """Decorator retries a function when expected exceptions are raised.""" assert len(exceptions) > 0 assert attempts > 0 def wrapper(f): @functools.wraps(f) def wrapped(*args, **kwargs): for i in xrange(att...
python
def retryable_transaction(attempts=3, exceptions=(OperationalError,)): """Decorator retries a function when expected exceptions are raised.""" assert len(exceptions) > 0 assert attempts > 0 def wrapper(f): @functools.wraps(f) def wrapped(*args, **kwargs): for i in xrange(att...
Decorator retries a function when expected exceptions are raised.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L37-L58
bslatkin/dpxdt
dpxdt/server/utils.py
jsonify_assert
def jsonify_assert(asserted, message, status_code=400): """Asserts something is true, aborts the request if not.""" if asserted: return try: raise AssertionError(message) except AssertionError, e: stack = traceback.extract_stack() stack.pop() logging.error('Assert...
python
def jsonify_assert(asserted, message, status_code=400): """Asserts something is true, aborts the request if not.""" if asserted: return try: raise AssertionError(message) except AssertionError, e: stack = traceback.extract_stack() stack.pop() logging.error('Assert...
Asserts something is true, aborts the request if not.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L61-L72
bslatkin/dpxdt
dpxdt/server/utils.py
jsonify_error
def jsonify_error(message_or_exception, status_code=400): """Returns a JSON payload that indicates the request had an error.""" if isinstance(message_or_exception, Exception): message = '%s: %s' % ( message_or_exception.__class__.__name__, message_or_exception) else: message = me...
python
def jsonify_error(message_or_exception, status_code=400): """Returns a JSON payload that indicates the request had an error.""" if isinstance(message_or_exception, Exception): message = '%s: %s' % ( message_or_exception.__class__.__name__, message_or_exception) else: message = me...
Returns a JSON payload that indicates the request had an error.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L75-L87
bslatkin/dpxdt
dpxdt/server/utils.py
ignore_exceptions
def ignore_exceptions(f): """Decorator catches and ignores any exceptions raised by this function.""" @functools.wraps(f) def wrapped(*args, **kwargs): try: return f(*args, **kwargs) except: logging.exception("Ignoring exception in %r", f) return wrapped
python
def ignore_exceptions(f): """Decorator catches and ignores any exceptions raised by this function.""" @functools.wraps(f) def wrapped(*args, **kwargs): try: return f(*args, **kwargs) except: logging.exception("Ignoring exception in %r", f) return wrapped
Decorator catches and ignores any exceptions raised by this function.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L90-L98
bslatkin/dpxdt
dpxdt/server/utils.py
timesince
def timesince(when): """Returns string representing "time since" or "time until". Examples: 3 days ago, 5 hours ago, 3 minutes from now, 5 hours from now, now. """ if not when: return '' now = datetime.datetime.utcnow() if now > when: diff = now - when suffix = ...
python
def timesince(when): """Returns string representing "time since" or "time until". Examples: 3 days ago, 5 hours ago, 3 minutes from now, 5 hours from now, now. """ if not when: return '' now = datetime.datetime.utcnow() if now > when: diff = now - when suffix = ...
Returns string representing "time since" or "time until". Examples: 3 days ago, 5 hours ago, 3 minutes from now, 5 hours from now, now.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L103-L137
bslatkin/dpxdt
dpxdt/server/utils.py
human_uuid
def human_uuid(): """Returns a good UUID for using as a human readable string.""" return base64.b32encode( hashlib.sha1(uuid.uuid4().bytes).digest()).lower().strip('=')
python
def human_uuid(): """Returns a good UUID for using as a human readable string.""" return base64.b32encode( hashlib.sha1(uuid.uuid4().bytes).digest()).lower().strip('=')
Returns a good UUID for using as a human readable string.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L140-L143
bslatkin/dpxdt
dpxdt/server/utils.py
get_deployment_timestamp
def get_deployment_timestamp(): """Returns a unique string represeting the current deployment. Used for busting caches. """ # TODO: Support other deployment situations. if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'): version_id = os.environ.get('CURRENT_VERSION_ID'...
python
def get_deployment_timestamp(): """Returns a unique string represeting the current deployment. Used for busting caches. """ # TODO: Support other deployment situations. if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'): version_id = os.environ.get('CURRENT_VERSION_ID'...
Returns a unique string represeting the current deployment. Used for busting caches.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L163-L173
bslatkin/dpxdt
dpxdt/client/capture_worker.py
register
def register(coordinator): """Registers this module as a worker with the given coordinator.""" if FLAGS.phantomjs_script: utils.verify_binary('phantomjs_binary', ['--version']) assert os.path.exists(FLAGS.phantomjs_script) else: utils.verify_binary('capture_binary', ['--version']) ...
python
def register(coordinator): """Registers this module as a worker with the given coordinator.""" if FLAGS.phantomjs_script: utils.verify_binary('phantomjs_binary', ['--version']) assert os.path.exists(FLAGS.phantomjs_script) else: utils.verify_binary('capture_binary', ['--version']) ...
Registers this module as a worker with the given coordinator.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/capture_worker.py#L207-L227
bslatkin/dpxdt
dpxdt/tools/url_pair_diff.py
real_main
def real_main(new_url=None, baseline_url=None, upload_build_id=None, upload_release_name=None): """Runs the ur_pair_diff.""" coordinator = workers.get_coordinator() fetch_worker.register(coordinator) coordinator.start() item = UrlPairDiff( new_url, ...
python
def real_main(new_url=None, baseline_url=None, upload_build_id=None, upload_release_name=None): """Runs the ur_pair_diff.""" coordinator = workers.get_coordinator() fetch_worker.register(coordinator) coordinator.start() item = UrlPairDiff( new_url, ...
Runs the ur_pair_diff.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/url_pair_diff.py#L132-L152
bslatkin/dpxdt
dpxdt/client/fetch_worker.py
fetch_internal
def fetch_internal(item, request): """Fetches the given request by using the local Flask context.""" # Break client dependence on Flask if internal fetches aren't being used. from flask import make_response from werkzeug.test import EnvironBuilder # Break circular dependencies. from dpxdt.server...
python
def fetch_internal(item, request): """Fetches the given request by using the local Flask context.""" # Break client dependence on Flask if internal fetches aren't being used. from flask import make_response from werkzeug.test import EnvironBuilder # Break circular dependencies. from dpxdt.server...
Fetches the given request by using the local Flask context.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L118-L160
bslatkin/dpxdt
dpxdt/client/fetch_worker.py
fetch_normal
def fetch_normal(item, request): """Fetches the given request over HTTP.""" try: conn = urllib2.urlopen(request, timeout=item.timeout_seconds) except urllib2.HTTPError, e: conn = e except (urllib2.URLError, ssl.SSLError), e: # TODO: Make this status more clear item.status...
python
def fetch_normal(item, request): """Fetches the given request over HTTP.""" try: conn = urllib2.urlopen(request, timeout=item.timeout_seconds) except urllib2.HTTPError, e: conn = e except (urllib2.URLError, ssl.SSLError), e: # TODO: Make this status more clear item.status...
Fetches the given request over HTTP.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L163-L189
bslatkin/dpxdt
dpxdt/client/fetch_worker.py
register
def register(coordinator): """Registers this module as a worker with the given coordinator.""" fetch_queue = Queue.Queue() coordinator.register(FetchItem, fetch_queue) for i in xrange(FLAGS.fetch_threads): coordinator.worker_threads.append( FetchThread(fetch_queue, coordinator.input_...
python
def register(coordinator): """Registers this module as a worker with the given coordinator.""" fetch_queue = Queue.Queue() coordinator.register(FetchItem, fetch_queue) for i in xrange(FLAGS.fetch_threads): coordinator.worker_threads.append( FetchThread(fetch_queue, coordinator.input_...
Registers this module as a worker with the given coordinator.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L249-L255
bslatkin/dpxdt
dpxdt/client/fetch_worker.py
FetchItem.json
def json(self): """Returns de-JSONed data or None if it's a different content type.""" if self._data_json: return self._data_json if not self.data or self.content_type != 'application/json': return None self._data_json = json.loads(self.data) return self...
python
def json(self): """Returns de-JSONed data or None if it's a different content type.""" if self._data_json: return self._data_json if not self.data or self.content_type != 'application/json': return None self._data_json = json.loads(self.data) return self...
Returns de-JSONed data or None if it's a different content type.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L106-L115
bslatkin/dpxdt
dpxdt/tools/local_pdiff.py
CaptureAndDiffWorkflowItem.maybe_imgur
def maybe_imgur(self, path): '''Uploads a file to imgur if requested via command line flags. Returns either "path" or "path url" depending on the course of action. ''' if not FLAGS.imgur_client_id: return path im = pyimgur.Imgur(FLAGS.imgur_client_id) upload...
python
def maybe_imgur(self, path): '''Uploads a file to imgur if requested via command line flags. Returns either "path" or "path url" depending on the course of action. ''' if not FLAGS.imgur_client_id: return path im = pyimgur.Imgur(FLAGS.imgur_client_id) upload...
Uploads a file to imgur if requested via command line flags. Returns either "path" or "path url" depending on the course of action.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/local_pdiff.py#L254-L264
bslatkin/dpxdt
dpxdt/tools/diff_my_images.py
real_main
def real_main(release_url=None, tests_json_path=None, upload_build_id=None, upload_release_name=None): """Runs diff_my_images.""" coordinator = workers.get_coordinator() fetch_worker.register(coordinator) coordinator.start() data = open(FLAGS.tests_json_pat...
python
def real_main(release_url=None, tests_json_path=None, upload_build_id=None, upload_release_name=None): """Runs diff_my_images.""" coordinator = workers.get_coordinator() fetch_worker.register(coordinator) coordinator.start() data = open(FLAGS.tests_json_pat...
Runs diff_my_images.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/diff_my_images.py#L175-L198
bslatkin/dpxdt
dpxdt/tools/site_diff.py
clean_url
def clean_url(url, force_scheme=None): """Cleans the given URL.""" # URL should be ASCII according to RFC 3986 url = str(url) # Collapse ../../ and related url_parts = urlparse.urlparse(url) path_parts = [] for part in url_parts.path.split('/'): if part == '.': continue ...
python
def clean_url(url, force_scheme=None): """Cleans the given URL.""" # URL should be ASCII according to RFC 3986 url = str(url) # Collapse ../../ and related url_parts = urlparse.urlparse(url) path_parts = [] for part in url_parts.path.split('/'): if part == '.': continue ...
Cleans the given URL.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L105-L135
bslatkin/dpxdt
dpxdt/tools/site_diff.py
extract_urls
def extract_urls(url, data, unescape=HTMLParser.HTMLParser().unescape): """Extracts the URLs from an HTML document.""" parts = urlparse.urlparse(url) prefix = '%s://%s' % (parts.scheme, parts.netloc) accessed_dir = os.path.dirname(parts.path) if not accessed_dir.endswith('/'): accessed_dir ...
python
def extract_urls(url, data, unescape=HTMLParser.HTMLParser().unescape): """Extracts the URLs from an HTML document.""" parts = urlparse.urlparse(url) prefix = '%s://%s' % (parts.scheme, parts.netloc) accessed_dir = os.path.dirname(parts.path) if not accessed_dir.endswith('/'): accessed_dir ...
Extracts the URLs from an HTML document.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L138-L162
bslatkin/dpxdt
dpxdt/tools/site_diff.py
prune_urls
def prune_urls(url_set, start_url, allowed_list, ignored_list): """Prunes URLs that should be ignored.""" result = set() for url in url_set: allowed = False for allow_url in allowed_list: if url.startswith(allow_url): allowed = True break ...
python
def prune_urls(url_set, start_url, allowed_list, ignored_list): """Prunes URLs that should be ignored.""" result = set() for url in url_set: allowed = False for allow_url in allowed_list: if url.startswith(allow_url): allowed = True break ...
Prunes URLs that should be ignored.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L169-L198
bslatkin/dpxdt
dpxdt/tools/site_diff.py
real_main
def real_main(start_url=None, ignore_prefixes=None, upload_build_id=None, upload_release_name=None): """Runs the site_diff.""" coordinator = workers.get_coordinator() fetch_worker.register(coordinator) coordinator.start() item = SiteDiff( start_url=...
python
def real_main(start_url=None, ignore_prefixes=None, upload_build_id=None, upload_release_name=None): """Runs the site_diff.""" coordinator = workers.get_coordinator() fetch_worker.register(coordinator) coordinator.start() item = SiteDiff( start_url=...
Runs the site_diff.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L328-L348
bslatkin/dpxdt
dpxdt/server/emails.py
render_or_send
def render_or_send(func, message): """Renders an email message for debugging or actually sends it.""" if request.endpoint != func.func_name: mail.send(message) if (current_user.is_authenticated() and current_user.superuser): return render_template('debug_email.html', message=message)
python
def render_or_send(func, message): """Renders an email message for debugging or actually sends it.""" if request.endpoint != func.func_name: mail.send(message) if (current_user.is_authenticated() and current_user.superuser): return render_template('debug_email.html', message=message)
Renders an email message for debugging or actually sends it.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/emails.py#L33-L39
bslatkin/dpxdt
dpxdt/server/emails.py
send_ready_for_review
def send_ready_for_review(build_id, release_name, release_number): """Sends an email indicating that the release is ready for review.""" build = models.Build.query.get(build_id) if not build.send_email: logging.debug( 'Not sending ready for review email because build does not have ' ...
python
def send_ready_for_review(build_id, release_name, release_number): """Sends an email indicating that the release is ready for review.""" build = models.Build.query.get(build_id) if not build.send_email: logging.debug( 'Not sending ready for review email because build does not have ' ...
Sends an email indicating that the release is ready for review.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/emails.py#L45-L96
bslatkin/dpxdt
dpxdt/server/frontend.py
homepage
def homepage(): """Renders the homepage.""" if current_user.is_authenticated(): if not login_fresh(): logging.debug('User needs a fresh token') abort(login.needs_refresh()) auth.claim_invitations(current_user) build_list = operations.UserOps(current_user.get_id()).g...
python
def homepage(): """Renders the homepage.""" if current_user.is_authenticated(): if not login_fresh(): logging.debug('User needs a fresh token') abort(login.needs_refresh()) auth.claim_invitations(current_user) build_list = operations.UserOps(current_user.get_id()).g...
Renders the homepage.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L55-L68
bslatkin/dpxdt
dpxdt/server/frontend.py
new_build
def new_build(): """Page for crediting or editing a build.""" form = forms.BuildForm() if form.validate_on_submit(): build = models.Build() form.populate_obj(build) build.owners.append(current_user) db.session.add(build) db.session.flush() auth.save_admin_lo...
python
def new_build(): """Page for crediting or editing a build.""" form = forms.BuildForm() if form.validate_on_submit(): build = models.Build() form.populate_obj(build) build.owners.append(current_user) db.session.add(build) db.session.flush() auth.save_admin_lo...
Page for crediting or editing a build.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L73-L96
bslatkin/dpxdt
dpxdt/server/frontend.py
view_build
def view_build(): """Page for viewing all releases in a build.""" build = g.build page_size = min(request.args.get('page_size', 10, type=int), 50) offset = request.args.get('offset', 0, type=int) ops = operations.BuildOps(build.id) has_next_page, candidate_list, stats_counts = ops.get_candidate...
python
def view_build(): """Page for viewing all releases in a build.""" build = g.build page_size = min(request.args.get('page_size', 10, type=int), 50) offset = request.args.get('offset', 0, type=int) ops = operations.BuildOps(build.id) has_next_page, candidate_list, stats_counts = ops.get_candidate...
Page for viewing all releases in a build.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L101-L154
bslatkin/dpxdt
dpxdt/server/frontend.py
view_release
def view_release(): """Page for viewing all tests runs in a release.""" build = g.build if request.method == 'POST': form = forms.ReleaseForm(request.form) else: form = forms.ReleaseForm(request.args) form.validate() ops = operations.BuildOps(build.id) release, run_list, st...
python
def view_release(): """Page for viewing all tests runs in a release.""" build = g.build if request.method == 'POST': form = forms.ReleaseForm(request.form) else: form = forms.ReleaseForm(request.args) form.validate() ops = operations.BuildOps(build.id) release, run_list, st...
Page for viewing all tests runs in a release.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L159-L221
bslatkin/dpxdt
dpxdt/server/frontend.py
_get_artifact_context
def _get_artifact_context(run, file_type): """Gets the artifact details for the given run and file_type.""" sha1sum = None image_file = False log_file = False config_file = False if request.path == '/image': image_file = True if file_type == 'before': sha1sum = run.r...
python
def _get_artifact_context(run, file_type): """Gets the artifact details for the given run and file_type.""" sha1sum = None image_file = False log_file = False config_file = False if request.path == '/image': image_file = True if file_type == 'before': sha1sum = run.r...
Gets the artifact details for the given run and file_type.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L224-L260
bslatkin/dpxdt
dpxdt/server/frontend.py
view_run
def view_run(): """Page for viewing before/after for a specific test run.""" build = g.build if request.method == 'POST': form = forms.RunForm(request.form) else: form = forms.RunForm(request.args) form.validate() ops = operations.BuildOps(build.id) run, next_run, previous_...
python
def view_run(): """Page for viewing before/after for a specific test run.""" build = g.build if request.method == 'POST': form = forms.RunForm(request.form) else: form = forms.RunForm(request.args) form.validate() ops = operations.BuildOps(build.id) run, next_run, previous_...
Page for viewing before/after for a specific test run.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L268-L337
bslatkin/dpxdt
dpxdt/client/timer_worker.py
register
def register(coordinator): """Registers this module as a worker with the given coordinator.""" timer_queue = Queue.Queue() coordinator.register(TimerItem, timer_queue) coordinator.worker_threads.append( TimerThread(timer_queue, coordinator.input_queue))
python
def register(coordinator): """Registers this module as a worker with the given coordinator.""" timer_queue = Queue.Queue() coordinator.register(TimerItem, timer_queue) coordinator.worker_threads.append( TimerThread(timer_queue, coordinator.input_queue))
Registers this module as a worker with the given coordinator.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/timer_worker.py#L70-L75
bslatkin/dpxdt
dpxdt/client/workers.py
get_coordinator
def get_coordinator(): """Creates a coordinator and returns it.""" workflow_queue = Queue.Queue() complete_queue = Queue.Queue() coordinator = WorkflowThread(workflow_queue, complete_queue) coordinator.register(WorkflowItem, workflow_queue) return coordinator
python
def get_coordinator(): """Creates a coordinator and returns it.""" workflow_queue = Queue.Queue() complete_queue = Queue.Queue() coordinator = WorkflowThread(workflow_queue, complete_queue) coordinator.register(WorkflowItem, workflow_queue) return coordinator
Creates a coordinator and returns it.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L553-L559
bslatkin/dpxdt
dpxdt/client/workers.py
WorkItem._print_repr
def _print_repr(self, depth): """Print this WorkItem to the given stack depth. The depth parameter ensures that we can print WorkItems in arbitrarily long chains without hitting the max stack depth. This can happen with WaitForUrlWorkflowItems, which create long chains of small ...
python
def _print_repr(self, depth): """Print this WorkItem to the given stack depth. The depth parameter ensures that we can print WorkItems in arbitrarily long chains without hitting the max stack depth. This can happen with WaitForUrlWorkflowItems, which create long chains of small ...
Print this WorkItem to the given stack depth. The depth parameter ensures that we can print WorkItems in arbitrarily long chains without hitting the max stack depth. This can happen with WaitForUrlWorkflowItems, which create long chains of small waits.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L74-L92
bslatkin/dpxdt
dpxdt/client/workers.py
ResultList.error
def error(self): """Returns the error for this barrier and all work items, if any.""" # Copy the error from any failed item to be the error for the whole # barrier. The first error seen "wins". Also handles the case where # the WorkItems passed into the barrier have already completed and...
python
def error(self): """Returns the error for this barrier and all work items, if any.""" # Copy the error from any failed item to be the error for the whole # barrier. The first error seen "wins". Also handles the case where # the WorkItems passed into the barrier have already completed and...
Returns the error for this barrier and all work items, if any.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L227-L236
bslatkin/dpxdt
dpxdt/client/workers.py
Barrier.outstanding
def outstanding(self): """Returns whether or not this barrier has pending work.""" # Allow the same WorkItem to be yielded multiple times but not # count towards blocking the barrier. done_count = 0 for item in self: if not self.wait_any and item.fire_and_forget: ...
python
def outstanding(self): """Returns whether or not this barrier has pending work.""" # Allow the same WorkItem to be yielded multiple times but not # count towards blocking the barrier. done_count = 0 for item in self: if not self.wait_any and item.fire_and_forget: ...
Returns whether or not this barrier has pending work.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L274-L295
bslatkin/dpxdt
dpxdt/client/workers.py
Barrier.get_item
def get_item(self): """Returns the item to send back into the workflow generator.""" if self.was_list: result = ResultList() for item in self: if isinstance(item, WorkflowItem): if item.done and not item.error: result.ap...
python
def get_item(self): """Returns the item to send back into the workflow generator.""" if self.was_list: result = ResultList() for item in self: if isinstance(item, WorkflowItem): if item.done and not item.error: result.ap...
Returns the item to send back into the workflow generator.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L297-L314
bslatkin/dpxdt
dpxdt/client/workers.py
WorkflowThread.start
def start(self): """Starts the coordinator thread and all related worker threads.""" assert not self.interrupted for thread in self.worker_threads: thread.start() WorkerThread.start(self)
python
def start(self): """Starts the coordinator thread and all related worker threads.""" assert not self.interrupted for thread in self.worker_threads: thread.start() WorkerThread.start(self)
Starts the coordinator thread and all related worker threads.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L429-L434
bslatkin/dpxdt
dpxdt/client/workers.py
WorkflowThread.stop
def stop(self): """Stops the coordinator thread and all related threads.""" if self.interrupted: return for thread in self.worker_threads: thread.interrupted = True self.interrupted = True
python
def stop(self): """Stops the coordinator thread and all related threads.""" if self.interrupted: return for thread in self.worker_threads: thread.interrupted = True self.interrupted = True
Stops the coordinator thread and all related threads.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L436-L442
bslatkin/dpxdt
dpxdt/client/workers.py
WorkflowThread.join
def join(self): """Joins the coordinator thread and all worker threads.""" for thread in self.worker_threads: thread.join() WorkerThread.join(self)
python
def join(self): """Joins the coordinator thread and all worker threads.""" for thread in self.worker_threads: thread.join() WorkerThread.join(self)
Joins the coordinator thread and all worker threads.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L444-L448
bslatkin/dpxdt
dpxdt/client/workers.py
WorkflowThread.wait_one
def wait_one(self): """Waits until this worker has finished one work item or died.""" while True: try: item = self.output_queue.get(True, self.polltime) except Queue.Empty: continue except KeyboardInterrupt: LOGGER.debug...
python
def wait_one(self): """Waits until this worker has finished one work item or died.""" while True: try: item = self.output_queue.get(True, self.polltime) except Queue.Empty: continue except KeyboardInterrupt: LOGGER.debug...
Waits until this worker has finished one work item or died.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L450-L462
bslatkin/dpxdt
dpxdt/server/auth.py
superuser_required
def superuser_required(f): """Requires the requestor to be a super user.""" @functools.wraps(f) @login_required def wrapped(*args, **kwargs): if not (current_user.is_authenticated() and current_user.superuser): abort(403) return f(*args, **kwargs) return wrapped
python
def superuser_required(f): """Requires the requestor to be a super user.""" @functools.wraps(f) @login_required def wrapped(*args, **kwargs): if not (current_user.is_authenticated() and current_user.superuser): abort(403) return f(*args, **kwargs) return wrapped
Requires the requestor to be a super user.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L174-L182
bslatkin/dpxdt
dpxdt/server/auth.py
can_user_access_build
def can_user_access_build(param_name): """Determines if the current user can access the build ID in the request. Args: param_name: Parameter name to use for getting the build ID from the request. Will fetch from GET or POST requests. Returns: The build the user has access to. ...
python
def can_user_access_build(param_name): """Determines if the current user can access the build ID in the request. Args: param_name: Parameter name to use for getting the build ID from the request. Will fetch from GET or POST requests. Returns: The build the user has access to. ...
Determines if the current user can access the build ID in the request. Args: param_name: Parameter name to use for getting the build ID from the request. Will fetch from GET or POST requests. Returns: The build the user has access to.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L185-L236
bslatkin/dpxdt
dpxdt/server/auth.py
build_access_required
def build_access_required(function_or_param_name): """Decorator ensures user has access to the build ID in the request. May be used in two ways: @build_access_required def my_func(build): ... @build_access_required('custom_build_id_param') def my_func(build): ...
python
def build_access_required(function_or_param_name): """Decorator ensures user has access to the build ID in the request. May be used in two ways: @build_access_required def my_func(build): ... @build_access_required('custom_build_id_param') def my_func(build): ...
Decorator ensures user has access to the build ID in the request. May be used in two ways: @build_access_required def my_func(build): ... @build_access_required('custom_build_id_param') def my_func(build): ... Always calls the given function with the m...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L239-L268
bslatkin/dpxdt
dpxdt/server/auth.py
_get_api_key_ops
def _get_api_key_ops(): """Gets the operations.ApiKeyOps instance for the current request.""" auth_header = request.authorization if not auth_header: logging.debug('API request lacks authorization header') abort(flask.Response( 'API key required', 401, {'WWW-Authentic...
python
def _get_api_key_ops(): """Gets the operations.ApiKeyOps instance for the current request.""" auth_header = request.authorization if not auth_header: logging.debug('API request lacks authorization header') abort(flask.Response( 'API key required', 401, {'WWW-Authentic...
Gets the operations.ApiKeyOps instance for the current request.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L271-L280
bslatkin/dpxdt
dpxdt/server/auth.py
current_api_key
def current_api_key(): """Determines the API key for the current request. Returns: The ApiKey instance. """ if app.config.get('IGNORE_AUTH'): return models.ApiKey( id='anonymous_superuser', secret='', superuser=True) ops = _get_api_key_ops() ...
python
def current_api_key(): """Determines the API key for the current request. Returns: The ApiKey instance. """ if app.config.get('IGNORE_AUTH'): return models.ApiKey( id='anonymous_superuser', secret='', superuser=True) ops = _get_api_key_ops() ...
Determines the API key for the current request. Returns: The ApiKey instance.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L283-L299
bslatkin/dpxdt
dpxdt/server/auth.py
can_api_key_access_build
def can_api_key_access_build(param_name): """Determines if the current API key can access the build in the request. Args: param_name: Parameter name to use for getting the build ID from the request. Will fetch from GET or POST requests. Returns: (api_key, build) The API Key and...
python
def can_api_key_access_build(param_name): """Determines if the current API key can access the build in the request. Args: param_name: Parameter name to use for getting the build ID from the request. Will fetch from GET or POST requests. Returns: (api_key, build) The API Key and...
Determines if the current API key can access the build in the request. Args: param_name: Parameter name to use for getting the build ID from the request. Will fetch from GET or POST requests. Returns: (api_key, build) The API Key and the Build it has access to.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L302-L329
bslatkin/dpxdt
dpxdt/server/auth.py
build_api_access_required
def build_api_access_required(f): """Decorator ensures API key has access to the build ID in the request. Always calls the given function with the models.Build entity as the first positional argument. """ @functools.wraps(f) def wrapped(*args, **kwargs): g.api_key, g.build = can_api_key...
python
def build_api_access_required(f): """Decorator ensures API key has access to the build ID in the request. Always calls the given function with the models.Build entity as the first positional argument. """ @functools.wraps(f) def wrapped(*args, **kwargs): g.api_key, g.build = can_api_key...
Decorator ensures API key has access to the build ID in the request. Always calls the given function with the models.Build entity as the first positional argument.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L332-L342
bslatkin/dpxdt
dpxdt/server/auth.py
superuser_api_key_required
def superuser_api_key_required(f): """Decorator ensures only superuser API keys can request this function.""" @functools.wraps(f) def wrapped(*args, **kwargs): api_key = current_api_key() g.api_key = api_key utils.jsonify_assert( api_key.superuser, 'API key=%...
python
def superuser_api_key_required(f): """Decorator ensures only superuser API keys can request this function.""" @functools.wraps(f) def wrapped(*args, **kwargs): api_key = current_api_key() g.api_key = api_key utils.jsonify_assert( api_key.superuser, 'API key=%...
Decorator ensures only superuser API keys can request this function.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L345-L359
bslatkin/dpxdt
dpxdt/server/auth.py
manage_api_keys
def manage_api_keys(): """Page for viewing and creating API keys.""" build = g.build create_form = forms.CreateApiKeyForm() if create_form.validate_on_submit(): api_key = models.ApiKey() create_form.populate_obj(api_key) api_key.id = utils.human_uuid() api_key.secret = ut...
python
def manage_api_keys(): """Page for viewing and creating API keys.""" build = g.build create_form = forms.CreateApiKeyForm() if create_form.validate_on_submit(): api_key = models.ApiKey() create_form.populate_obj(api_key) api_key.id = utils.human_uuid() api_key.secret = ut...
Page for viewing and creating API keys.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L365-L404
bslatkin/dpxdt
dpxdt/server/auth.py
revoke_api_key
def revoke_api_key(): """Form submission handler for revoking API keys.""" build = g.build form = forms.RevokeApiKeyForm() if form.validate_on_submit(): api_key = models.ApiKey.query.get(form.id.data) if api_key.build_id != build.id: logging.debug('User does not have access t...
python
def revoke_api_key(): """Form submission handler for revoking API keys.""" build = g.build form = forms.RevokeApiKeyForm() if form.validate_on_submit(): api_key = models.ApiKey.query.get(form.id.data) if api_key.build_id != build.id: logging.debug('User does not have access t...
Form submission handler for revoking API keys.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L410-L430
bslatkin/dpxdt
dpxdt/server/auth.py
claim_invitations
def claim_invitations(user): """Claims any pending invitations for the given user's email address.""" # See if there are any build invitations present for the user with this # email address. If so, replace all those invitations with the real user. invitation_user_id = '%s:%s' % ( models.User.EMA...
python
def claim_invitations(user): """Claims any pending invitations for the given user's email address.""" # See if there are any build invitations present for the user with this # email address. If so, replace all those invitations with the real user. invitation_user_id = '%s:%s' % ( models.User.EMA...
Claims any pending invitations for the given user's email address.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L433-L463
bslatkin/dpxdt
dpxdt/server/auth.py
manage_admins
def manage_admins(): """Page for viewing and managing build admins.""" build = g.build # Do not show cached data db.session.add(build) db.session.refresh(build) add_form = forms.AddAdminForm() if add_form.validate_on_submit(): invitation_user_id = '%s:%s' % ( models.Us...
python
def manage_admins(): """Page for viewing and managing build admins.""" build = g.build # Do not show cached data db.session.add(build) db.session.refresh(build) add_form = forms.AddAdminForm() if add_form.validate_on_submit(): invitation_user_id = '%s:%s' % ( models.Us...
Page for viewing and managing build admins.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L469-L518
bslatkin/dpxdt
dpxdt/server/auth.py
revoke_admin
def revoke_admin(): """Form submission handler for revoking admin access to a build.""" build = g.build form = forms.RemoveAdminForm() if form.validate_on_submit(): user = models.User.query.get(form.user_id.data) if not user: logging.debug('User being revoked admin access doe...
python
def revoke_admin(): """Form submission handler for revoking admin access to a build.""" build = g.build form = forms.RemoveAdminForm() if form.validate_on_submit(): user = models.User.query.get(form.user_id.data) if not user: logging.debug('User being revoked admin access doe...
Form submission handler for revoking admin access to a build.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L524-L558
bslatkin/dpxdt
dpxdt/server/auth.py
save_admin_log
def save_admin_log(build, **kwargs): """Saves an action to the admin log.""" message = kwargs.pop('message', None) release = kwargs.pop('release', None) run = kwargs.pop('run', None) if not len(kwargs) == 1: raise TypeError('Must specify a LOG_TYPE argument') log_enum = kwargs.keys()[0...
python
def save_admin_log(build, **kwargs): """Saves an action to the admin log.""" message = kwargs.pop('message', None) release = kwargs.pop('release', None) run = kwargs.pop('run', None) if not len(kwargs) == 1: raise TypeError('Must specify a LOG_TYPE argument') log_enum = kwargs.keys()[0...
Saves an action to the admin log.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L561-L593
bslatkin/dpxdt
dpxdt/server/auth.py
view_admin_log
def view_admin_log(): """Page for viewing the log of admin activity.""" build = g.build # TODO: Add paging log_list = ( models.AdminLog.query .filter_by(build_id=build.id) .order_by(models.AdminLog.created.desc()) .all()) return render_template( 'view_admin...
python
def view_admin_log(): """Page for viewing the log of admin activity.""" build = g.build # TODO: Add paging log_list = ( models.AdminLog.query .filter_by(build_id=build.id) .order_by(models.AdminLog.created.desc()) .all()) return render_template( 'view_admin...
Page for viewing the log of admin activity.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L599-L614
bslatkin/dpxdt
dpxdt/client/utils.py
verify_binary
def verify_binary(flag_name, process_args=None): """Exits the program if the binary from the given flag doesn't run. Args: flag_name: Name of the flag that should be the path to the binary. process_args: Args to pass to the binary to do nothing but verify that it's working correctly...
python
def verify_binary(flag_name, process_args=None): """Exits the program if the binary from the given flag doesn't run. Args: flag_name: Name of the flag that should be the path to the binary. process_args: Args to pass to the binary to do nothing but verify that it's working correctly...
Exits the program if the binary from the given flag doesn't run. Args: flag_name: Name of the flag that should be the path to the binary. process_args: Args to pass to the binary to do nothing but verify that it's working correctly (something like "--version") is good. Optio...
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/utils.py#L28-L57
bslatkin/dpxdt
dpxdt/server/api.py
create_release
def create_release(): """Creates a new release candidate for a build.""" build = g.build release_name = request.form.get('release_name') utils.jsonify_assert(release_name, 'release_name required') url = request.form.get('url') utils.jsonify_assert(release_name, 'url required') release = mod...
python
def create_release(): """Creates a new release candidate for a build.""" build = g.build release_name = request.form.get('release_name') utils.jsonify_assert(release_name, 'release_name required') url = request.form.get('url') utils.jsonify_assert(release_name, 'url required') release = mod...
Creates a new release candidate for a build.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L109-L154
bslatkin/dpxdt
dpxdt/server/api.py
_check_release_done_processing
def _check_release_done_processing(release): """Moves a release candidate to reviewing if all runs are done.""" if release.status != models.Release.PROCESSING: # NOTE: This statement also guards for situations where the user has # prematurely specified that the release is good or bad. Once the u...
python
def _check_release_done_processing(release): """Moves a release candidate to reviewing if all runs are done.""" if release.status != models.Release.PROCESSING: # NOTE: This statement also guards for situations where the user has # prematurely specified that the release is good or bad. Once the u...
Moves a release candidate to reviewing if all runs are done.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L157-L197
bslatkin/dpxdt
dpxdt/server/api.py
_get_release_params
def _get_release_params(): """Gets the release params from the current request.""" release_name = request.form.get('release_name') utils.jsonify_assert(release_name, 'release_name required') release_number = request.form.get('release_number', type=int) utils.jsonify_assert(release_number is not None...
python
def _get_release_params(): """Gets the release params from the current request.""" release_name = request.form.get('release_name') utils.jsonify_assert(release_name, 'release_name required') release_number = request.form.get('release_number', type=int) utils.jsonify_assert(release_number is not None...
Gets the release params from the current request.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L200-L206
bslatkin/dpxdt
dpxdt/server/api.py
_find_last_good_run
def _find_last_good_run(build): """Finds the last good release and run for a build.""" run_name = request.form.get('run_name', type=str) utils.jsonify_assert(run_name, 'run_name required') last_good_release = ( models.Release.query .filter_by( build_id=build.id, ...
python
def _find_last_good_run(build): """Finds the last good release and run for a build.""" run_name = request.form.get('run_name', type=str) utils.jsonify_assert(run_name, 'run_name required') last_good_release = ( models.Release.query .filter_by( build_id=build.id, ...
Finds the last good release and run for a build.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L209-L240
bslatkin/dpxdt
dpxdt/server/api.py
find_run
def find_run(): """Finds the last good run of the given name for a release.""" build = g.build last_good_release, last_good_run = _find_last_good_run(build) if last_good_run: return flask.jsonify( success=True, build_id=build.id, release_name=last_good_releas...
python
def find_run(): """Finds the last good run of the given name for a release.""" build = g.build last_good_release, last_good_run = _find_last_good_run(build) if last_good_run: return flask.jsonify( success=True, build_id=build.id, release_name=last_good_releas...
Finds the last good run of the given name for a release.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L245-L262
bslatkin/dpxdt
dpxdt/server/api.py
_get_or_create_run
def _get_or_create_run(build): """Gets a run for a build or creates it if it does not exist.""" release_name, release_number = _get_release_params() run_name = request.form.get('run_name', type=str) utils.jsonify_assert(run_name, 'run_name required') release = ( models.Release.query ...
python
def _get_or_create_run(build): """Gets a run for a build or creates it if it does not exist.""" release_name, release_number = _get_release_params() run_name = request.form.get('run_name', type=str) utils.jsonify_assert(run_name, 'run_name required') release = ( models.Release.query ...
Gets a run for a build or creates it if it does not exist.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L265-L293
bslatkin/dpxdt
dpxdt/server/api.py
_enqueue_capture
def _enqueue_capture(build, release, run, url, config_data, baseline=False): """Enqueues a task to run a capture process.""" # Validate the JSON config parses. try: config_dict = json.loads(config_data) except Exception, e: abort(utils.jsonify_error(e)) # Rewrite the config JSON to ...
python
def _enqueue_capture(build, release, run, url, config_data, baseline=False): """Enqueues a task to run a capture process.""" # Validate the JSON config parses. try: config_dict = json.loads(config_data) except Exception, e: abort(utils.jsonify_error(e)) # Rewrite the config JSON to ...
Enqueues a task to run a capture process.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L296-L344
bslatkin/dpxdt
dpxdt/server/api.py
request_run
def request_run(): """Requests a new run for a release candidate.""" build = g.build current_release, current_run = _get_or_create_run(build) current_url = request.form.get('url', type=str) config_data = request.form.get('config', default='{}', type=str) utils.jsonify_assert(current_url, 'url t...
python
def request_run(): """Requests a new run for a release candidate.""" build = g.build current_release, current_run = _get_or_create_run(build) current_url = request.form.get('url', type=str) config_data = request.form.get('config', default='{}', type=str) utils.jsonify_assert(current_url, 'url t...
Requests a new run for a release candidate.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L350-L396
bslatkin/dpxdt
dpxdt/server/api.py
report_run
def report_run(): """Reports data for a run for a release candidate.""" build = g.build release, run = _get_or_create_run(build) db.session.refresh(run, lockmode='update') current_url = request.form.get('url', type=str) current_image = request.form.get('image', type=str) current_log = requ...
python
def report_run(): """Reports data for a run for a release candidate.""" build = g.build release, run = _get_or_create_run(build) db.session.refresh(run, lockmode='update') current_url = request.form.get('url', type=str) current_image = request.form.get('image', type=str) current_log = requ...
Reports data for a run for a release candidate.
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L402-L525