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
gusutabopb/aioinflux
aioinflux/client.py
InfluxDBClient.create_session
async def create_session(self, **kwargs): """Creates an :class:`aiohttp.ClientSession` Override this or call it with ``kwargs`` to use other :mod:`aiohttp` functionality not covered by :class:`~.InfluxDBClient.__init__` """ self.opts.update(kwargs) self._session = aiohtt...
python
async def create_session(self, **kwargs): """Creates an :class:`aiohttp.ClientSession` Override this or call it with ``kwargs`` to use other :mod:`aiohttp` functionality not covered by :class:`~.InfluxDBClient.__init__` """ self.opts.update(kwargs) self._session = aiohtt...
Creates an :class:`aiohttp.ClientSession` Override this or call it with ``kwargs`` to use other :mod:`aiohttp` functionality not covered by :class:`~.InfluxDBClient.__init__`
https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/client.py#L146-L159
gusutabopb/aioinflux
aioinflux/client.py
InfluxDBClient.ping
async def ping(self) -> dict: """Pings InfluxDB Returns a dictionary containing the headers of the response from ``influxd``. """ if not self._session: await self.create_session() async with self._session.get(self.url.format(endpoint='ping')) as resp: l...
python
async def ping(self) -> dict: """Pings InfluxDB Returns a dictionary containing the headers of the response from ``influxd``. """ if not self._session: await self.create_session() async with self._session.get(self.url.format(endpoint='ping')) as resp: l...
Pings InfluxDB Returns a dictionary containing the headers of the response from ``influxd``.
https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/client.py#L228-L237
gusutabopb/aioinflux
aioinflux/client.py
InfluxDBClient.write
async def write( self, data: Union[PointType, Iterable[PointType]], measurement: Optional[str] = None, db: Optional[str] = None, precision: Optional[str] = None, rp: Optional[str] = None, tag_columns: Optional[Iterable] = None, **extra_tags, ) -> bool:...
python
async def write( self, data: Union[PointType, Iterable[PointType]], measurement: Optional[str] = None, db: Optional[str] = None, precision: Optional[str] = None, rp: Optional[str] = None, tag_columns: Optional[Iterable] = None, **extra_tags, ) -> bool:...
Writes data to InfluxDB. Input can be: 1. A mapping (e.g. ``dict``) containing the keys: ``measurement``, ``time``, ``tags``, ``fields`` 2. A Pandas :class:`~pandas.DataFrame` with a :class:`~pandas.DatetimeIndex` 3. A user defined class decorated w/ :func:`~aioin...
https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/client.py#L240-L295
gusutabopb/aioinflux
aioinflux/client.py
InfluxDBClient.query
async def query( self, q: AnyStr, *, epoch: str = 'ns', chunked: bool = False, chunk_size: Optional[int] = None, db: Optional[str] = None, use_cache: bool = False, ) -> Union[AsyncGenerator[ResultType, None], ResultType]: """Sends a query to In...
python
async def query( self, q: AnyStr, *, epoch: str = 'ns', chunked: bool = False, chunk_size: Optional[int] = None, db: Optional[str] = None, use_cache: bool = False, ) -> Union[AsyncGenerator[ResultType, None], ResultType]: """Sends a query to In...
Sends a query to InfluxDB. Please refer to the InfluxDB documentation for all the possible queries: https://docs.influxdata.com/influxdb/latest/query_language/ :param q: Raw query string :param db: Database to be queried. Defaults to `self.db`. :param epoch: Precision level of r...
https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/client.py#L298-L381
gusutabopb/aioinflux
aioinflux/client.py
InfluxDBClient._check_error
def _check_error(response): """Checks for JSON error messages and raises Python exception""" if 'error' in response: raise InfluxDBError(response['error']) elif 'results' in response: for statement in response['results']: if 'error' in statement: ...
python
def _check_error(response): """Checks for JSON error messages and raises Python exception""" if 'error' in response: raise InfluxDBError(response['error']) elif 'results' in response: for statement in response['results']: if 'error' in statement: ...
Checks for JSON error messages and raises Python exception
https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/client.py#L384-L392
remcohaszing/pywakeonlan
wakeonlan.py
create_magic_packet
def create_magic_packet(macaddress): """ Create a magic packet. A magic packet is a packet that can be used with the for wake on lan protocol to wake up a computer. The packet is constructed from the mac address given as a parameter. Args: macaddress (str): the mac address that should ...
python
def create_magic_packet(macaddress): """ Create a magic packet. A magic packet is a packet that can be used with the for wake on lan protocol to wake up a computer. The packet is constructed from the mac address given as a parameter. Args: macaddress (str): the mac address that should ...
Create a magic packet. A magic packet is a packet that can be used with the for wake on lan protocol to wake up a computer. The packet is constructed from the mac address given as a parameter. Args: macaddress (str): the mac address that should be parsed into a magic packet.
https://github.com/remcohaszing/pywakeonlan/blob/d30b66172c483c4baadb426f493c3de30fecc19b/wakeonlan.py#L19-L47
remcohaszing/pywakeonlan
wakeonlan.py
send_magic_packet
def send_magic_packet(*macs, **kwargs): """ Wake up computers having any of the given mac addresses. Wake on lan must be enabled on the host device. Args: macs (str): One or more macaddresses of machines to wake. Keyword Args: ip_address (str): the ip address of the host to send t...
python
def send_magic_packet(*macs, **kwargs): """ Wake up computers having any of the given mac addresses. Wake on lan must be enabled on the host device. Args: macs (str): One or more macaddresses of machines to wake. Keyword Args: ip_address (str): the ip address of the host to send t...
Wake up computers having any of the given mac addresses. Wake on lan must be enabled on the host device. Args: macs (str): One or more macaddresses of machines to wake. Keyword Args: ip_address (str): the ip address of the host to send the magic packet to (default "25...
https://github.com/remcohaszing/pywakeonlan/blob/d30b66172c483c4baadb426f493c3de30fecc19b/wakeonlan.py#L50-L82
remcohaszing/pywakeonlan
wakeonlan.py
main
def main(argv=None): """ Run wake on lan as a CLI application. """ parser = argparse.ArgumentParser( description='Wake one or more computers using the wake on lan' ' protocol.') parser.add_argument( 'macs', metavar='mac address', nargs='+', ...
python
def main(argv=None): """ Run wake on lan as a CLI application. """ parser = argparse.ArgumentParser( description='Wake one or more computers using the wake on lan' ' protocol.') parser.add_argument( 'macs', metavar='mac address', nargs='+', ...
Run wake on lan as a CLI application.
https://github.com/remcohaszing/pywakeonlan/blob/d30b66172c483c4baadb426f493c3de30fecc19b/wakeonlan.py#L85-L111
liminspace/django-mjml
mjml/templatetags/mjml.py
mjml
def mjml(parser, token): """ Compile MJML template after render django template. Usage: {% mjml %} .. MJML template code .. {% endmjml %} """ nodelist = parser.parse(('endmjml',)) parser.delete_first_token() tokens = token.split_contents() if len(tokens) != 1...
python
def mjml(parser, token): """ Compile MJML template after render django template. Usage: {% mjml %} .. MJML template code .. {% endmjml %} """ nodelist = parser.parse(('endmjml',)) parser.delete_first_token() tokens = token.split_contents() if len(tokens) != 1...
Compile MJML template after render django template. Usage: {% mjml %} .. MJML template code .. {% endmjml %}
https://github.com/liminspace/django-mjml/blob/6f3e5959ccd35d1b2bcebc6f892a9400294736fb/mjml/templatetags/mjml.py#L18-L32
moonso/vcf_parser
vcf_parser/utils/build_models.py
build_models_dict
def build_models_dict(annotated_models): """ Take a list with annotated genetic inheritance patterns for each family and returns a dictionary with family_id as key and a list of genetic models as value. Args: annotated_models : A list on the form ['1:AD','2:AR_comp|AD_dn'] R...
python
def build_models_dict(annotated_models): """ Take a list with annotated genetic inheritance patterns for each family and returns a dictionary with family_id as key and a list of genetic models as value. Args: annotated_models : A list on the form ['1:AD','2:AR_comp|AD_dn'] R...
Take a list with annotated genetic inheritance patterns for each family and returns a dictionary with family_id as key and a list of genetic models as value. Args: annotated_models : A list on the form ['1:AD','2:AR_comp|AD_dn'] Returns: parsed_models : A dictionary on...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_models.py#L3-L31
moonso/vcf_parser
vcf_parser/utils/split_variants.py
split_variants
def split_variants(variant_dict, header_parser, allele_symbol='0'): """ Checks if there are multiple alternative alleles and splitts the variant. If there are multiple alternatives the info fields, vep annotations and genotype calls will be splitted in the correct way Args: varian...
python
def split_variants(variant_dict, header_parser, allele_symbol='0'): """ Checks if there are multiple alternative alleles and splitts the variant. If there are multiple alternatives the info fields, vep annotations and genotype calls will be splitted in the correct way Args: varian...
Checks if there are multiple alternative alleles and splitts the variant. If there are multiple alternatives the info fields, vep annotations and genotype calls will be splitted in the correct way Args: variant_dict: a dictionary with the variant information Yields: varia...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/split_variants.py#L13-L120
moonso/vcf_parser
vcf_parser/utils/rank_scores.py
build_rank_score_dict
def build_rank_score_dict(rank_scores): """ Take a list with annotated rank scores for each family and returns a dictionary with family_id as key and a list of genetic models as value. Args: rank_scores : A list on the form ['1:12','2:20'] Returns: scores : A dict...
python
def build_rank_score_dict(rank_scores): """ Take a list with annotated rank scores for each family and returns a dictionary with family_id as key and a list of genetic models as value. Args: rank_scores : A list on the form ['1:12','2:20'] Returns: scores : A dict...
Take a list with annotated rank scores for each family and returns a dictionary with family_id as key and a list of genetic models as value. Args: rank_scores : A list on the form ['1:12','2:20'] Returns: scores : A dictionary with family id:s as key and scores as value ...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/rank_scores.py#L3-L34
moonso/vcf_parser
vcf_parser/utils/check_info.py
check_info_annotation
def check_info_annotation(annotation, info, extra_info, alternatives, individuals=[]): """ Check if the info annotation corresponds to the metadata specification Arguments: annotation (list): The annotation from the vcf file info (str): Name of the info field extra_info (dict): ...
python
def check_info_annotation(annotation, info, extra_info, alternatives, individuals=[]): """ Check if the info annotation corresponds to the metadata specification Arguments: annotation (list): The annotation from the vcf file info (str): Name of the info field extra_info (dict): ...
Check if the info annotation corresponds to the metadata specification Arguments: annotation (list): The annotation from the vcf file info (str): Name of the info field extra_info (dict): The metadata specification alternatives (list): A list with the alternative variants ...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/check_info.py#L18-L72
moonso/vcf_parser
vcf_parser/utils/format_variant.py
format_variant
def format_variant(line, header_parser, check_info=False): """ Yield the variant in the right format. If the variants should be splitted on alternative alles one variant for each alternative will be yielded. Arguments: line (str): A string that represents a variant line in the vc...
python
def format_variant(line, header_parser, check_info=False): """ Yield the variant in the right format. If the variants should be splitted on alternative alles one variant for each alternative will be yielded. Arguments: line (str): A string that represents a variant line in the vc...
Yield the variant in the right format. If the variants should be splitted on alternative alles one variant for each alternative will be yielded. Arguments: line (str): A string that represents a variant line in the vcf format header_parser (HeaderParser): A HeaderParser object ...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/format_variant.py#L10-L137
moonso/vcf_parser
vcf_parser/utils/build_info.py
build_info_string
def build_info_string(info): """ Build a new vcf INFO string based on the information in the info_dict. The info is a dictionary with vcf info keys as keys and lists of vcf values as values. If there is no value False is value in info Args: info (dict): A dictionary with informatio...
python
def build_info_string(info): """ Build a new vcf INFO string based on the information in the info_dict. The info is a dictionary with vcf info keys as keys and lists of vcf values as values. If there is no value False is value in info Args: info (dict): A dictionary with informatio...
Build a new vcf INFO string based on the information in the info_dict. The info is a dictionary with vcf info keys as keys and lists of vcf values as values. If there is no value False is value in info Args: info (dict): A dictionary with information from the vcf file Returns: ...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_info.py#L10-L33
moonso/vcf_parser
vcf_parser/utils/build_info.py
build_info_dict
def build_info_dict(vcf_info): """ Build a dictionary from the info of a vcf line The dictionary will have the info keys as keys and info values as values. Values will allways be lists that are splitted on ',' Arguments: vcf_info (str): A string with vcf info Returns: ...
python
def build_info_dict(vcf_info): """ Build a dictionary from the info of a vcf line The dictionary will have the info keys as keys and info values as values. Values will allways be lists that are splitted on ',' Arguments: vcf_info (str): A string with vcf info Returns: ...
Build a dictionary from the info of a vcf line The dictionary will have the info keys as keys and info values as values. Values will allways be lists that are splitted on ',' Arguments: vcf_info (str): A string with vcf info Returns: info_dict (OrderedDict): A ordered dict...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_info.py#L35-L62
moonso/vcf_parser
vcf_parser/utils/split_genotype.py
split_genotype
def split_genotype(genotype, gt_format, alternative_number, allele_symbol = '0'): """ Take a genotype call and make a new one that is working for the new splitted variant Arguments: genotype (str): The original genotype call gt_format (str): The format of the gt call alterna...
python
def split_genotype(genotype, gt_format, alternative_number, allele_symbol = '0'): """ Take a genotype call and make a new one that is working for the new splitted variant Arguments: genotype (str): The original genotype call gt_format (str): The format of the gt call alterna...
Take a genotype call and make a new one that is working for the new splitted variant Arguments: genotype (str): The original genotype call gt_format (str): The format of the gt call alternative_number (int): What genotype call should we return allele_symbol (str): How should...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/split_genotype.py#L3-L92
moonso/vcf_parser
vcf_parser/header_parser.py
HeaderParser.parse_header_line
def parse_header_line(self, line): """docstring for parse_header_line""" self.header = line[1:].rstrip().split('\t') if len(self.header) < 9: self.header = line[1:].rstrip().split() self.individuals = self.header[9:]
python
def parse_header_line(self, line): """docstring for parse_header_line""" self.header = line[1:].rstrip().split('\t') if len(self.header) < 9: self.header = line[1:].rstrip().split() self.individuals = self.header[9:]
docstring for parse_header_line
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/header_parser.py#L178-L183
moonso/vcf_parser
vcf_parser/header_parser.py
HeaderParser.print_header
def print_header(self): """Returns a list with the header lines if proper format""" lines_to_print = [] lines_to_print.append('##fileformat='+self.fileformat) if self.filedate: lines_to_print.append('##fileformat='+self.fileformat) for filt in self.filter...
python
def print_header(self): """Returns a list with the header lines if proper format""" lines_to_print = [] lines_to_print.append('##fileformat='+self.fileformat) if self.filedate: lines_to_print.append('##fileformat='+self.fileformat) for filt in self.filter...
Returns a list with the header lines if proper format
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/header_parser.py#L185-L205
moonso/vcf_parser
vcf_parser/header_parser.py
HeaderParser.add_info
def add_info(self, info_id, number, entry_type, description): """ Add an info line to the header. Arguments: info_id (str): The id of the info line number (str): Integer or any of [A,R,G,.] entry_type (str): Any of [Integer,Float,Flag,Character,String...
python
def add_info(self, info_id, number, entry_type, description): """ Add an info line to the header. Arguments: info_id (str): The id of the info line number (str): Integer or any of [A,R,G,.] entry_type (str): Any of [Integer,Float,Flag,Character,String...
Add an info line to the header. Arguments: info_id (str): The id of the info line number (str): Integer or any of [A,R,G,.] entry_type (str): Any of [Integer,Float,Flag,Character,String] description (str): A description of the info line
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/header_parser.py#L238-L254
moonso/vcf_parser
vcf_parser/header_parser.py
HeaderParser.add_version_tracking
def add_version_tracking(self, info_id, version, date, command_line=''): """ Add a line with information about which software that was run and when to the header. Arguments: info_id (str): The id of the info line version (str): The version of the softwar...
python
def add_version_tracking(self, info_id, version, date, command_line=''): """ Add a line with information about which software that was run and when to the header. Arguments: info_id (str): The id of the info line version (str): The version of the softwar...
Add a line with information about which software that was run and when to the header. Arguments: info_id (str): The id of the info line version (str): The version of the software used date (str): Date when software was run command_line (str): The...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/header_parser.py#L338-L353
moonso/vcf_parser
vcf_parser/utils/build_compounds.py
build_compounds_dict
def build_compounds_dict(compounds): """ Take a list with annotated compound variants for each family and returns a dictionary with family_id as key and a list of dictionarys that holds the information about the compounds. Args: compounds : A list that can be either on the form ...
python
def build_compounds_dict(compounds): """ Take a list with annotated compound variants for each family and returns a dictionary with family_id as key and a list of dictionarys that holds the information about the compounds. Args: compounds : A list that can be either on the form ...
Take a list with annotated compound variants for each family and returns a dictionary with family_id as key and a list of dictionarys that holds the information about the compounds. Args: compounds : A list that can be either on the form [ ...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_compounds.py#L3-L66
moonso/vcf_parser
vcf_parser/cli/command_line.py
cli
def cli(variant_file, vep, split, outfile, verbose, silent, check_info, allele_symbol, logfile, loglevel): """ Tool for parsing vcf files. Prints the vcf file to output. If --split/-s is used all multiallelic calls will be splitted and printed as single variant calls. For more inf...
python
def cli(variant_file, vep, split, outfile, verbose, silent, check_info, allele_symbol, logfile, loglevel): """ Tool for parsing vcf files. Prints the vcf file to output. If --split/-s is used all multiallelic calls will be splitted and printed as single variant calls. For more inf...
Tool for parsing vcf files. Prints the vcf file to output. If --split/-s is used all multiallelic calls will be splitted and printed as single variant calls. For more information, please see github.com/moonso/vcf_parser.
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/cli/command_line.py#L93-L163
moonso/vcf_parser
vcf_parser/parser.py
cli
def cli(variant_file, vep, split): """Parses a vcf file.\n \n Usage:\n parser infile.vcf\n If pipe:\n parser - """ from datetime import datetime from pprint import pprint as pp if variant_file == '-': my_parser = VCFParser(fsock=sys.stdin, spl...
python
def cli(variant_file, vep, split): """Parses a vcf file.\n \n Usage:\n parser infile.vcf\n If pipe:\n parser - """ from datetime import datetime from pprint import pprint as pp if variant_file == '-': my_parser = VCFParser(fsock=sys.stdin, spl...
Parses a vcf file.\n \n Usage:\n parser infile.vcf\n If pipe:\n parser -
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/parser.py#L284-L305
moonso/vcf_parser
vcf_parser/parser.py
VCFParser.add_variant
def add_variant(self, chrom, pos, rs_id, ref, alt, qual, filt, info, form=None, genotypes=[]): """ Add a variant to the parser. This function is for building a vcf. It takes the relevant parameters and make a vcf variant in the proper format. """ variant_info = ...
python
def add_variant(self, chrom, pos, rs_id, ref, alt, qual, filt, info, form=None, genotypes=[]): """ Add a variant to the parser. This function is for building a vcf. It takes the relevant parameters and make a vcf variant in the proper format. """ variant_info = ...
Add a variant to the parser. This function is for building a vcf. It takes the relevant parameters and make a vcf variant in the proper format.
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/parser.py#L173-L202
moonso/vcf_parser
vcf_parser/utils/build_vep.py
build_vep_string
def build_vep_string(vep_info, vep_columns): """ Build a vep string formatted string. Take a list with vep annotations and build a new vep string Args: vep_info (list): A list with vep annotation dictionaries vep_columns (list): A list with the vep column names found in the ...
python
def build_vep_string(vep_info, vep_columns): """ Build a vep string formatted string. Take a list with vep annotations and build a new vep string Args: vep_info (list): A list with vep annotation dictionaries vep_columns (list): A list with the vep column names found in the ...
Build a vep string formatted string. Take a list with vep annotations and build a new vep string Args: vep_info (list): A list with vep annotation dictionaries vep_columns (list): A list with the vep column names found in the header of the vcf Returns: string: ...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_vep.py#L3-L31
moonso/vcf_parser
vcf_parser/utils/build_vep.py
build_vep_annotation
def build_vep_annotation(csq_info, reference, alternatives, vep_columns): """ Build a dictionary with the vep information from the vep annotation. Indels are handled different by vep depending on the number of alternative alleles there is for a variant. If only one alternative: ...
python
def build_vep_annotation(csq_info, reference, alternatives, vep_columns): """ Build a dictionary with the vep information from the vep annotation. Indels are handled different by vep depending on the number of alternative alleles there is for a variant. If only one alternative: ...
Build a dictionary with the vep information from the vep annotation. Indels are handled different by vep depending on the number of alternative alleles there is for a variant. If only one alternative: Insertion: vep represents the alternative by removing the first base f...
https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_vep.py#L33-L134
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.user_login
def user_login(self, email=None, password=None): """Login with email, password and get back a session cookie :type email: str :param email: The email used for authentication :type password: str :param password: The password used for authentication """ email = s...
python
def user_login(self, email=None, password=None): """Login with email, password and get back a session cookie :type email: str :param email: The email used for authentication :type password: str :param password: The password used for authentication """ email = s...
Login with email, password and get back a session cookie :type email: str :param email: The email used for authentication :type password: str :param password: The password used for authentication
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L36-L60
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.demo_login
def demo_login(self, auth=None, url=None): """Authenticate with a "Share Your Class" URL using a demo user. You may provide either the entire ``url`` or simply the ``auth`` parameter. :param url: Example - "https://piazza.com/demo_login?nid=hbj11a1gcvl1s6&auth=06c111b" :param a...
python
def demo_login(self, auth=None, url=None): """Authenticate with a "Share Your Class" URL using a demo user. You may provide either the entire ``url`` or simply the ``auth`` parameter. :param url: Example - "https://piazza.com/demo_login?nid=hbj11a1gcvl1s6&auth=06c111b" :param a...
Authenticate with a "Share Your Class" URL using a demo user. You may provide either the entire ``url`` or simply the ``auth`` parameter. :param url: Example - "https://piazza.com/demo_login?nid=hbj11a1gcvl1s6&auth=06c111b" :param auth: Example - "06c111b"
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L62-L80
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.content_get
def content_get(self, cid, nid=None): """Get data from post `cid` in network `nid` :type nid: str :param nid: This is the ID of the network (or class) from which to query posts. This is optional and only to override the existing `network_id` entered when created the cla...
python
def content_get(self, cid, nid=None): """Get data from post `cid` in network `nid` :type nid: str :param nid: This is the ID of the network (or class) from which to query posts. This is optional and only to override the existing `network_id` entered when created the cla...
Get data from post `cid` in network `nid` :type nid: str :param nid: This is the ID of the network (or class) from which to query posts. This is optional and only to override the existing `network_id` entered when created the class :type cid: str|int :param cid...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L82-L98
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.content_create
def content_create(self, params): """Create a post or followup. :type params: dict :param params: A dict of options to pass to the endpoint. Depends on the specific type of content being created. :returns: Python object containing returned data """ r = self....
python
def content_create(self, params): """Create a post or followup. :type params: dict :param params: A dict of options to pass to the endpoint. Depends on the specific type of content being created. :returns: Python object containing returned data """ r = self....
Create a post or followup. :type params: dict :param params: A dict of options to pass to the endpoint. Depends on the specific type of content being created. :returns: Python object containing returned data
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L100-L115
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.add_students
def add_students(self, student_emails, nid=None): """Enroll students in a network `nid`. Piazza will email these students with instructions to activate their account. :type student_emails: list of str :param student_emails: A listing of email addresses to enroll in...
python
def add_students(self, student_emails, nid=None): """Enroll students in a network `nid`. Piazza will email these students with instructions to activate their account. :type student_emails: list of str :param student_emails: A listing of email addresses to enroll in...
Enroll students in a network `nid`. Piazza will email these students with instructions to activate their account. :type student_emails: list of str :param student_emails: A listing of email addresses to enroll in the network (or class). This can be a list of length one. ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L185-L211
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.get_all_users
def get_all_users(self, nid=None): """Get a listing of data for each user in a network `nid` :type nid: str :param nid: This is the ID of the network to get users from. This is optional and only to override the existing `network_id` entered when created the class ...
python
def get_all_users(self, nid=None): """Get a listing of data for each user in a network `nid` :type nid: str :param nid: This is the ID of the network to get users from. This is optional and only to override the existing `network_id` entered when created the class ...
Get a listing of data for each user in a network `nid` :type nid: str :param nid: This is the ID of the network to get users from. This is optional and only to override the existing `network_id` entered when created the class :returns: Python object containing returned ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L213-L227
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.get_users
def get_users(self, user_ids, nid=None): """Get a listing of data for specific users `user_ids` in a network `nid` :type user_ids: list of str :param user_ids: a list of user ids. These are the same ids that are returned by get_all_users. :type nid: str :pa...
python
def get_users(self, user_ids, nid=None): """Get a listing of data for specific users `user_ids` in a network `nid` :type user_ids: list of str :param user_ids: a list of user ids. These are the same ids that are returned by get_all_users. :type nid: str :pa...
Get a listing of data for specific users `user_ids` in a network `nid` :type user_ids: list of str :param user_ids: a list of user ids. These are the same ids that are returned by get_all_users. :type nid: str :param nid: This is the ID of the network to get studen...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L229-L248
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.remove_users
def remove_users(self, user_ids, nid=None): """Remove users from a network `nid` :type user_ids: list of str :param user_ids: a list of user ids. These are the same ids that are returned by get_all_users. :type nid: str :param nid: This is the ID of the network to ...
python
def remove_users(self, user_ids, nid=None): """Remove users from a network `nid` :type user_ids: list of str :param user_ids: a list of user ids. These are the same ids that are returned by get_all_users. :type nid: str :param nid: This is the ID of the network to ...
Remove users from a network `nid` :type user_ids: list of str :param user_ids: a list of user ids. These are the same ids that are returned by get_all_users. :type nid: str :param nid: This is the ID of the network to remove students from. This is optional and ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L250-L270
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.get_my_feed
def get_my_feed(self, limit=150, offset=20, sort="updated", nid=None): """Get my feed :type limit: int :param limit: Number of posts from feed to get, starting from ``offset`` :type offset: int :param offset: Offset starting from bottom of feed :type sort: str :p...
python
def get_my_feed(self, limit=150, offset=20, sort="updated", nid=None): """Get my feed :type limit: int :param limit: Number of posts from feed to get, starting from ``offset`` :type offset: int :param offset: Offset starting from bottom of feed :type sort: str :p...
Get my feed :type limit: int :param limit: Number of posts from feed to get, starting from ``offset`` :type offset: int :param offset: Offset starting from bottom of feed :type sort: str :param sort: How to sort feed that will be retrieved; only current known...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L272-L296
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.filter_feed
def filter_feed(self, updated=False, following=False, folder=False, filter_folder="", sort="updated", nid=None): """Get filtered feed Only one filter type (updated, following, folder) is possible. :type nid: str :param nid: This is the ID of the network to get the ...
python
def filter_feed(self, updated=False, following=False, folder=False, filter_folder="", sort="updated", nid=None): """Get filtered feed Only one filter type (updated, following, folder) is possible. :type nid: str :param nid: This is the ID of the network to get the ...
Get filtered feed Only one filter type (updated, following, folder) is possible. :type nid: str :param nid: This is the ID of the network to get the feed from. This is optional and only to override the existing `network_id` entered when created the class :type ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L298-L343
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.search
def search(self, query, nid=None): """Search for posts with ``query`` :type nid: str :param nid: This is the ID of the network to get the feed from. This is optional and only to override the existing `network_id` entered when created the class :type query: str ...
python
def search(self, query, nid=None): """Search for posts with ``query`` :type nid: str :param nid: This is the ID of the network to get the feed from. This is optional and only to override the existing `network_id` entered when created the class :type query: str ...
Search for posts with ``query`` :type nid: str :param nid: This is the ID of the network to get the feed from. This is optional and only to override the existing `network_id` entered when created the class :type query: str :param query: The search query; should ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L345-L362
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.get_stats
def get_stats(self, nid=None): """Get statistics for class :type nid: str :param nid: This is the ID of the network to get stats from. This is optional and only to override the existing `network_id` entered when created the class """ r = self.request( ...
python
def get_stats(self, nid=None): """Get statistics for class :type nid: str :param nid: This is the ID of the network to get stats from. This is optional and only to override the existing `network_id` entered when created the class """ r = self.request( ...
Get statistics for class :type nid: str :param nid: This is the ID of the network to get stats from. This is optional and only to override the existing `network_id` entered when created the class
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L364-L377
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC.request
def request(self, method, data=None, nid=None, nid_key='nid', api_type="logic", return_response=False): """Get data from arbitrary Piazza API endpoint `method` in network `nid` :type method: str :param method: An internal Piazza API method name like `content.get` or...
python
def request(self, method, data=None, nid=None, nid_key='nid', api_type="logic", return_response=False): """Get data from arbitrary Piazza API endpoint `method` in network `nid` :type method: str :param method: An internal Piazza API method name like `content.get` or...
Get data from arbitrary Piazza API endpoint `method` in network `nid` :type method: str :param method: An internal Piazza API method name like `content.get` or `network.get_users` :type data: dict :param data: Key-value data to pass to Piazza in the request :type ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L392-L439
hfaran/piazza-api
piazza_api/rpc.py
PiazzaRPC._handle_error
def _handle_error(self, result, err_msg): """Check result for error :type result: dict :param result: response body :type err_msg: str :param err_msg: The message given to the :class:`RequestError` instance raised :returns: Actual result from result :...
python
def _handle_error(self, result, err_msg): """Check result for error :type result: dict :param result: response body :type err_msg: str :param err_msg: The message given to the :class:`RequestError` instance raised :returns: Actual result from result :...
Check result for error :type result: dict :param result: response body :type err_msg: str :param err_msg: The message given to the :class:`RequestError` instance raised :returns: Actual result from result :raises RequestError: If result has error
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/rpc.py#L454-L471
hfaran/piazza-api
piazza_api/piazza.py
Piazza.user_login
def user_login(self, email=None, password=None): """Login with email, password and get back a session cookie :type email: str :param email: The email used for authentication :type password: str :param password: The password used for authentication """ self._rpc...
python
def user_login(self, email=None, password=None): """Login with email, password and get back a session cookie :type email: str :param email: The email used for authentication :type password: str :param password: The password used for authentication """ self._rpc...
Login with email, password and get back a session cookie :type email: str :param email: The email used for authentication :type password: str :param password: The password used for authentication
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/piazza.py#L13-L22
hfaran/piazza-api
piazza_api/piazza.py
Piazza.demo_login
def demo_login(self, auth=None, url=None): """Authenticate with a "Share Your Class" URL using a demo user. You may provide either the entire ``url`` or simply the ``auth`` parameter. :param url: Example - "https://piazza.com/demo_login?nid=hbj11a1gcvl1s6&auth=06c111b" :param a...
python
def demo_login(self, auth=None, url=None): """Authenticate with a "Share Your Class" URL using a demo user. You may provide either the entire ``url`` or simply the ``auth`` parameter. :param url: Example - "https://piazza.com/demo_login?nid=hbj11a1gcvl1s6&auth=06c111b" :param a...
Authenticate with a "Share Your Class" URL using a demo user. You may provide either the entire ``url`` or simply the ``auth`` parameter. :param url: Example - "https://piazza.com/demo_login?nid=hbj11a1gcvl1s6&auth=06c111b" :param auth: Example - "06c111b"
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/piazza.py#L24-L34
hfaran/piazza-api
piazza_api/piazza.py
Piazza.network
def network(self, network_id): """Returns :class:`Network` instance for ``network_id`` :type network_id: str :param network_id: This is the ID of the network. This can be found by visiting your class page on Piazza's web UI and grabbing it from https://piazz...
python
def network(self, network_id): """Returns :class:`Network` instance for ``network_id`` :type network_id: str :param network_id: This is the ID of the network. This can be found by visiting your class page on Piazza's web UI and grabbing it from https://piazz...
Returns :class:`Network` instance for ``network_id`` :type network_id: str :param network_id: This is the ID of the network. This can be found by visiting your class page on Piazza's web UI and grabbing it from https://piazza.com/class/{network_id}
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/piazza.py#L36-L46
hfaran/piazza-api
piazza_api/piazza.py
Piazza.get_user_classes
def get_user_classes(self): """Get list of the current user's classes. This is a subset of the information returned by the call to ``get_user_status``. :returns: Classes of currently authenticated user :rtype: list """ # Previously getting classes from profile (such a li...
python
def get_user_classes(self): """Get list of the current user's classes. This is a subset of the information returned by the call to ``get_user_status``. :returns: Classes of currently authenticated user :rtype: list """ # Previously getting classes from profile (such a li...
Get list of the current user's classes. This is a subset of the information returned by the call to ``get_user_status``. :returns: Classes of currently authenticated user :rtype: list
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/piazza.py#L66-L89
hfaran/piazza-api
piazza_api/nonce.py
nonce
def nonce(): """ Returns a new nonce to be used with the Piazza API. """ nonce_part1 = _int2base(int(_time()*1000), 36) nonce_part2 = _int2base(round(_random()*1679616), 36) return "{}{}".format(nonce_part1, nonce_part2)
python
def nonce(): """ Returns a new nonce to be used with the Piazza API. """ nonce_part1 = _int2base(int(_time()*1000), 36) nonce_part2 = _int2base(round(_random()*1679616), 36) return "{}{}".format(nonce_part1, nonce_part2)
Returns a new nonce to be used with the Piazza API.
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/nonce.py#L7-L13
hfaran/piazza-api
piazza_api/nonce.py
_int2base
def _int2base(x, base): """ Converts an integer from base 10 to some arbitrary numerical base, and return a string representing the number in the new base (using letters to extend the numerical digits). :type x: int :param x: The integer to convert :type base: int :param base: T...
python
def _int2base(x, base): """ Converts an integer from base 10 to some arbitrary numerical base, and return a string representing the number in the new base (using letters to extend the numerical digits). :type x: int :param x: The integer to convert :type base: int :param base: T...
Converts an integer from base 10 to some arbitrary numerical base, and return a string representing the number in the new base (using letters to extend the numerical digits). :type x: int :param x: The integer to convert :type base: int :param base: The base to convert the integer to ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/nonce.py#L20-L60
hfaran/piazza-api
piazza_api/network.py
Network.iter_all_posts
def iter_all_posts(self, limit=None): """Get all posts visible to the current user This grabs you current feed and ids of all posts from it; each post is then individually fetched. This method does not go against a bulk endpoint; it retrieves each post individually, so a caution...
python
def iter_all_posts(self, limit=None): """Get all posts visible to the current user This grabs you current feed and ids of all posts from it; each post is then individually fetched. This method does not go against a bulk endpoint; it retrieves each post individually, so a caution...
Get all posts visible to the current user This grabs you current feed and ids of all posts from it; each post is then individually fetched. This method does not go against a bulk endpoint; it retrieves each post individually, so a caution to the user when using this. :type limi...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L85-L107
hfaran/piazza-api
piazza_api/network.py
Network.create_post
def create_post(self, post_type, post_folders, post_subject, post_content, is_announcement=0, bypass_email=0, anonymous=False): """Create a post It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accord...
python
def create_post(self, post_type, post_folders, post_subject, post_content, is_announcement=0, bypass_email=0, anonymous=False): """Create a post It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accord...
Create a post It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. :type post_type: str :param post_type: 'note', 'question' :type post_folders: str :param post_folde...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L109-L145
hfaran/piazza-api
piazza_api/network.py
Network.create_followup
def create_followup(self, post, content, anonymous=False): """Create a follow-up on a post `post`. It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. :type post: dict|str|int ...
python
def create_followup(self, post, content, anonymous=False): """Create a follow-up on a post `post`. It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. :type post: dict|str|int ...
Create a follow-up on a post `post`. It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. :type post: dict|str|int :param post: Either the post dict returned by another API method, ...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L147-L179
hfaran/piazza-api
piazza_api/network.py
Network.create_instructor_answer
def create_instructor_answer(self, post, content, revision, anonymous=False): """Create an instructor's answer to a post `post`. It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. ...
python
def create_instructor_answer(self, post, content, revision, anonymous=False): """Create an instructor's answer to a post `post`. It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. ...
Create an instructor's answer to a post `post`. It seems like if the post has `<p>` tags, then it's treated as HTML, but is treated as text otherwise. You'll want to provide `content` accordingly. :type post: dict|str|int :param post: Either the post dict returned by another A...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L181-L213
hfaran/piazza-api
piazza_api/network.py
Network.mark_as_duplicate
def mark_as_duplicate(self, duplicated_cid, master_cid, msg=''): """Mark the post at ``duplicated_cid`` as a duplicate of ``master_cid`` :type duplicated_cid: int :param duplicated_cid: The numeric id of the duplicated post :type master_cid: int :param master_cid: The numeric ...
python
def mark_as_duplicate(self, duplicated_cid, master_cid, msg=''): """Mark the post at ``duplicated_cid`` as a duplicate of ``master_cid`` :type duplicated_cid: int :param duplicated_cid: The numeric id of the duplicated post :type master_cid: int :param master_cid: The numeric ...
Mark the post at ``duplicated_cid`` as a duplicate of ``master_cid`` :type duplicated_cid: int :param duplicated_cid: The numeric id of the duplicated post :type master_cid: int :param master_cid: The numeric id of an older post. This will be the post that gets kept and ``...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L248-L268
hfaran/piazza-api
piazza_api/network.py
Network.resolve_post
def resolve_post(self, post): """Mark post as resolved :type post: dict|str|int :param post: Either the post dict returned by another API method, or the `cid` field of that post. :returns: True if it is successful. False otherwise """ try: cid = ...
python
def resolve_post(self, post): """Mark post as resolved :type post: dict|str|int :param post: Either the post dict returned by another API method, or the `cid` field of that post. :returns: True if it is successful. False otherwise """ try: cid = ...
Mark post as resolved :type post: dict|str|int :param post: Either the post dict returned by another API method, or the `cid` field of that post. :returns: True if it is successful. False otherwise
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L270-L288
hfaran/piazza-api
piazza_api/network.py
Network.pin_post
def pin_post(self, post): """Pin post :type post: dict|str|int :param post: Either the post dict returned by another API method, or the `cid` field of that post. :returns: True if it is successful. False otherwise """ try: cid = post['id'] ...
python
def pin_post(self, post): """Pin post :type post: dict|str|int :param post: Either the post dict returned by another API method, or the `cid` field of that post. :returns: True if it is successful. False otherwise """ try: cid = post['id'] ...
Pin post :type post: dict|str|int :param post: Either the post dict returned by another API method, or the `cid` field of that post. :returns: True if it is successful. False otherwise
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L290-L307
hfaran/piazza-api
piazza_api/network.py
Network.delete_post
def delete_post(self, post): """ Deletes post by cid :type post: dict|str|int :param post: Either the post dict returned by another API method, the post ID, or the `cid` field of that post. :rtype: dict :returns: Dictionary with information about the post cid. ...
python
def delete_post(self, post): """ Deletes post by cid :type post: dict|str|int :param post: Either the post dict returned by another API method, the post ID, or the `cid` field of that post. :rtype: dict :returns: Dictionary with information about the post cid. ...
Deletes post by cid :type post: dict|str|int :param post: Either the post dict returned by another API method, the post ID, or the `cid` field of that post. :rtype: dict :returns: Dictionary with information about the post cid.
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L378-L400
hfaran/piazza-api
piazza_api/network.py
Network.get_feed
def get_feed(self, limit=100, offset=0): """Get your feed for this network Pagination for this can be achieved by using the ``limit`` and ``offset`` params :type limit: int :param limit: Number of posts from feed to get, starting from ``offset`` :type offset: int ...
python
def get_feed(self, limit=100, offset=0): """Get your feed for this network Pagination for this can be achieved by using the ``limit`` and ``offset`` params :type limit: int :param limit: Number of posts from feed to get, starting from ``offset`` :type offset: int ...
Get your feed for this network Pagination for this can be achieved by using the ``limit`` and ``offset`` params :type limit: int :param limit: Number of posts from feed to get, starting from ``offset`` :type offset: int :param offset: Offset starting from bottom of feed...
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L406-L423
hfaran/piazza-api
piazza_api/network.py
Network.get_filtered_feed
def get_filtered_feed(self, feed_filter): """Get your feed containing only posts filtered by ``feed_filter`` :type feed_filter: FeedFilter :param feed_filter: Must be an instance of either: UnreadFilter, FollowingFilter, or FolderFilter :rtype: dict """ asser...
python
def get_filtered_feed(self, feed_filter): """Get your feed containing only posts filtered by ``feed_filter`` :type feed_filter: FeedFilter :param feed_filter: Must be an instance of either: UnreadFilter, FollowingFilter, or FolderFilter :rtype: dict """ asser...
Get your feed containing only posts filtered by ``feed_filter`` :type feed_filter: FeedFilter :param feed_filter: Must be an instance of either: UnreadFilter, FollowingFilter, or FolderFilter :rtype: dict
https://github.com/hfaran/piazza-api/blob/26201d06e26bada9a838f6765c1bccedad05bd39/piazza_api/network.py#L425-L435
lucaskjaero/PyCasia
pycasia/CASIA.py
CASIA.get_all_datasets
def get_all_datasets(self): """ Make sure the datasets are present. If not, downloads and extracts them. Attempts the download five times because the file hosting is unreliable. :return: True if successful, false otherwise """ success = True for dataset in tqdm(s...
python
def get_all_datasets(self): """ Make sure the datasets are present. If not, downloads and extracts them. Attempts the download five times because the file hosting is unreliable. :return: True if successful, false otherwise """ success = True for dataset in tqdm(s...
Make sure the datasets are present. If not, downloads and extracts them. Attempts the download five times because the file hosting is unreliable. :return: True if successful, false otherwise
https://github.com/lucaskjaero/PyCasia/blob/511ddb7809d788fc2c7bc7c1e8600db60bac8152/pycasia/CASIA.py#L57-L70
lucaskjaero/PyCasia
pycasia/CASIA.py
CASIA.get_dataset
def get_dataset(self, dataset): """ Checks to see if the dataset is present. If not, it downloads and unzips it. """ # If the dataset is present, no need to download anything. success = True dataset_path = self.base_dataset_path + dataset if not isdir(dataset_path...
python
def get_dataset(self, dataset): """ Checks to see if the dataset is present. If not, it downloads and unzips it. """ # If the dataset is present, no need to download anything. success = True dataset_path = self.base_dataset_path + dataset if not isdir(dataset_path...
Checks to see if the dataset is present. If not, it downloads and unzips it.
https://github.com/lucaskjaero/PyCasia/blob/511ddb7809d788fc2c7bc7c1e8600db60bac8152/pycasia/CASIA.py#L72-L121
lucaskjaero/PyCasia
pycasia/CASIA.py
CASIA.get_raw
def get_raw(self, verbose=True): """ Used to create easily introspectable image directories of all the data. :return: """ assert self.get_all_datasets() is True, "Datasets aren't properly downloaded, " \ "rerun to try again or downl...
python
def get_raw(self, verbose=True): """ Used to create easily introspectable image directories of all the data. :return: """ assert self.get_all_datasets() is True, "Datasets aren't properly downloaded, " \ "rerun to try again or downl...
Used to create easily introspectable image directories of all the data. :return:
https://github.com/lucaskjaero/PyCasia/blob/511ddb7809d788fc2c7bc7c1e8600db60bac8152/pycasia/CASIA.py#L123-L149
lucaskjaero/PyCasia
pycasia/CASIA.py
CASIA.load_character_images
def load_character_images(self, verbose=True): """ Generator to load all images in the dataset. Yields (image, character) pairs until all images have been loaded. :return: (Pillow.Image.Image, string) tuples """ for dataset in self.character_sets: assert self.get_data...
python
def load_character_images(self, verbose=True): """ Generator to load all images in the dataset. Yields (image, character) pairs until all images have been loaded. :return: (Pillow.Image.Image, string) tuples """ for dataset in self.character_sets: assert self.get_data...
Generator to load all images in the dataset. Yields (image, character) pairs until all images have been loaded. :return: (Pillow.Image.Image, string) tuples
https://github.com/lucaskjaero/PyCasia/blob/511ddb7809d788fc2c7bc7c1e8600db60bac8152/pycasia/CASIA.py#L151-L162
lucaskjaero/PyCasia
pycasia/CASIA.py
CASIA.load_dataset
def load_dataset(self, dataset, verbose=True): """ Load a directory of gnt files. Yields the image and label in tuples. :param dataset: The directory to load. :return: Yields (Pillow.Image.Image, label) pairs. """ assert self.get_dataset(dataset) is True, "Datasets aren'...
python
def load_dataset(self, dataset, verbose=True): """ Load a directory of gnt files. Yields the image and label in tuples. :param dataset: The directory to load. :return: Yields (Pillow.Image.Image, label) pairs. """ assert self.get_dataset(dataset) is True, "Datasets aren'...
Load a directory of gnt files. Yields the image and label in tuples. :param dataset: The directory to load. :return: Yields (Pillow.Image.Image, label) pairs.
https://github.com/lucaskjaero/PyCasia/blob/511ddb7809d788fc2c7bc7c1e8600db60bac8152/pycasia/CASIA.py#L164-L179
lucaskjaero/PyCasia
pycasia/CASIA.py
CASIA.load_gnt_file
def load_gnt_file(filename): """ Load characters and images from a given GNT file. :param filename: The file path to load. :return: (image: Pillow.Image.Image, character) tuples """ # Thanks to nhatch for the code to read the GNT file, available at https://github.com/nha...
python
def load_gnt_file(filename): """ Load characters and images from a given GNT file. :param filename: The file path to load. :return: (image: Pillow.Image.Image, character) tuples """ # Thanks to nhatch for the code to read the GNT file, available at https://github.com/nha...
Load characters and images from a given GNT file. :param filename: The file path to load. :return: (image: Pillow.Image.Image, character) tuples
https://github.com/lucaskjaero/PyCasia/blob/511ddb7809d788fc2c7bc7c1e8600db60bac8152/pycasia/CASIA.py#L182-L207
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.middleware
def middleware(self, *args, **kwargs): """Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware functi...
python
def middleware(self, *args, **kwargs): """Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware functi...
Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware function to use as the decorator :rtype: fn
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L37-L60
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.exception
def exception(self, *args, **kwargs): """Decorate and register an exception handler :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The exceptio...
python
def exception(self, *args, **kwargs): """Decorate and register an exception handler :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The exceptio...
Decorate and register an exception handler :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The exception function to use as the decorator :rtype...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L62-L83
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.listener
def listener(self, event, *args, **kwargs): """Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword argume...
python
def listener(self, event, *args, **kwargs): """Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword argume...
Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L85-L105
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.route
def route(self, uri, *args, **kwargs): """Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: capt...
python
def route(self, uri, *args, **kwargs): """Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: capt...
Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L107-L130
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.websocket
def websocket(self, uri, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :pa...
python
def websocket(self, uri, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :pa...
Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in ...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L132-L152
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.static
def static(self, uri, file_or_directory, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(...
python
def static(self, uri, file_or_directory, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(...
Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in ...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L154-L174
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.first_plugin_context
def first_plugin_context(self): """Returns the context is associated with the first app this plugin was registered on""" # Note, because registrations are stored in a set, its not _really_ # the first one, but whichever one it sees first in the set. first_spf_reg = next(iter(sel...
python
def first_plugin_context(self): """Returns the context is associated with the first app this plugin was registered on""" # Note, because registrations are stored in a set, its not _really_ # the first one, but whichever one it sees first in the set. first_spf_reg = next(iter(sel...
Returns the context is associated with the first app this plugin was registered on
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L191-L197
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.decorate
def decorate(cls, app, *args, run_middleware=False, with_context=False, **kwargs): """ This is a decorator that can be used to apply this plugin to a specific route/view on your app, rather than the whole app. :param app: :type app: Sanic | Blueprint :par...
python
def decorate(cls, app, *args, run_middleware=False, with_context=False, **kwargs): """ This is a decorator that can be used to apply this plugin to a specific route/view on your app, rather than the whole app. :param app: :type app: Sanic | Blueprint :par...
This is a decorator that can be used to apply this plugin to a specific route/view on your app, rather than the whole app. :param app: :type app: Sanic | Blueprint :param args: :type args: tuple(Any) :param run_middleware: :type run_middleware: bool :param...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L257-L368
ashleysommer/sanicpluginsframework
spf/plugin.py
SanicPlugin.route_wrapper
async def route_wrapper(self, route, request, context, request_args, request_kw, *decorator_args, with_context=None, **decorator_kw): """This is the function that is called when a route is decorated with your plugin decorator. Context will norma...
python
async def route_wrapper(self, route, request, context, request_args, request_kw, *decorator_args, with_context=None, **decorator_kw): """This is the function that is called when a route is decorated with your plugin decorator. Context will norma...
This is the function that is called when a route is decorated with your plugin decorator. Context will normally be None, but the user can pass use_context=True so the route will get the plugin context
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L370-L385
ashleysommer/sanicpluginsframework
spf/context.py
ContextDict.replace
def replace(self, key, value): """ If this ContextDict doesn't already have this key, it sets the value on a parent ContextDict if that parent has the key, otherwise sets the value on this ContextDict. :param key: :param value: :return: Nothing :rtype: Non...
python
def replace(self, key, value): """ If this ContextDict doesn't already have this key, it sets the value on a parent ContextDict if that parent has the key, otherwise sets the value on this ContextDict. :param key: :param value: :return: Nothing :rtype: Non...
If this ContextDict doesn't already have this key, it sets the value on a parent ContextDict if that parent has the key, otherwise sets the value on this ContextDict. :param key: :param value: :return: Nothing :rtype: None
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/context.py#L123-L149
ashleysommer/sanicpluginsframework
spf/context.py
ContextDict.update
def update(self, E=None, **F): """ Update ContextDict from dict/iterable E and F :return: Nothing :rtype: None """ if E is not None: if hasattr(E, 'keys'): for K in E: self.replace(K, E[K]) elif hasattr(E, 'items...
python
def update(self, E=None, **F): """ Update ContextDict from dict/iterable E and F :return: Nothing :rtype: None """ if E is not None: if hasattr(E, 'keys'): for K in E: self.replace(K, E[K]) elif hasattr(E, 'items...
Update ContextDict from dict/iterable E and F :return: Nothing :rtype: None
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/context.py#L152-L169
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
ContextualizeAssociated.middleware
def middleware(self, *args, **kwargs): """Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware functi...
python
def middleware(self, *args, **kwargs): """Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware functi...
Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware function to use as the decorator :rtype: fn
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L14-L38
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
ContextualizeAssociated.route
def route(self, uri, *args, **kwargs): """Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: capt...
python
def route(self, uri, *args, **kwargs): """Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: capt...
Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L40-L67
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
ContextualizeAssociated.listener
def listener(self, event, *args, **kwargs): """Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword argume...
python
def listener(self, event, *args, **kwargs): """Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword argume...
Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L69-L92
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
ContextualizeAssociated.websocket
def websocket(self, uri, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :pa...
python
def websocket(self, uri, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :pa...
Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in ...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L94-L119
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
Contextualize.middleware
def middleware(self, *args, **kwargs): """Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware functi...
python
def middleware(self, *args, **kwargs): """Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware functi...
Decorate and register middleware :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :return: The middleware function to use as the decorator :rtype: fn
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L173-L194
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
Contextualize.route
def route(self, uri, *args, **kwargs): """Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: capt...
python
def route(self, uri, *args, **kwargs): """Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: capt...
Create a plugin route from a decorated function. :param uri: endpoint at which the route will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L197-L222
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
Contextualize.listener
def listener(self, event, *args, **kwargs): """Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword argume...
python
def listener(self, event, *args, **kwargs): """Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword argume...
Create a listener from a decorated function. :param event: Event to listen to. :type event: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in :type kwargs: dict(Any) :...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L225-L245
ashleysommer/sanicpluginsframework
spf/plugins/contextualize.py
Contextualize.websocket
def websocket(self, uri, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :pa...
python
def websocket(self, uri, *args, **kwargs): """Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :pa...
Create a websocket route from a decorated function :param uri: endpoint at which the socket endpoint will be accessible. :type uri: str :param args: captures all of the positional arguments passed in :type args: tuple(Any) :param kwargs: captures the keyword arguments passed in ...
https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L247-L269
ionelmc/python-manhole
src/manhole/__init__.py
get_peercred
def get_peercred(sock): """Gets the (pid, uid, gid) for the client on the given *connected* socket.""" buf = sock.getsockopt(_PEERCRED_LEVEL, _PEERCRED_OPTION, struct.calcsize('3i')) return struct.unpack('3i', buf)
python
def get_peercred(sock): """Gets the (pid, uid, gid) for the client on the given *connected* socket.""" buf = sock.getsockopt(_PEERCRED_LEVEL, _PEERCRED_OPTION, struct.calcsize('3i')) return struct.unpack('3i', buf)
Gets the (pid, uid, gid) for the client on the given *connected* socket.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L108-L111
ionelmc/python-manhole
src/manhole/__init__.py
check_credentials
def check_credentials(client): """ Checks credentials for given socket. """ pid, uid, gid = get_peercred(client) euid = os.geteuid() client_name = "PID:%s UID:%s GID:%s" % (pid, uid, gid) if uid not in (0, euid): raise SuspiciousClient("Can't accept client with %s. It doesn't match ...
python
def check_credentials(client): """ Checks credentials for given socket. """ pid, uid, gid = get_peercred(client) euid = os.geteuid() client_name = "PID:%s UID:%s GID:%s" % (pid, uid, gid) if uid not in (0, euid): raise SuspiciousClient("Can't accept client with %s. It doesn't match ...
Checks credentials for given socket.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L242-L256
ionelmc/python-manhole
src/manhole/__init__.py
handle_connection_exec
def handle_connection_exec(client): """ Alternate connection handler. No output redirection. """ class ExitExecLoop(Exception): pass def exit(): raise ExitExecLoop() client.settimeout(None) fh = os.fdopen(client.detach() if hasattr(client, 'detach') else client.fileno()) ...
python
def handle_connection_exec(client): """ Alternate connection handler. No output redirection. """ class ExitExecLoop(Exception): pass def exit(): raise ExitExecLoop() client.settimeout(None) fh = os.fdopen(client.detach() if hasattr(client, 'detach') else client.fileno()) ...
Alternate connection handler. No output redirection.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L259-L281
ionelmc/python-manhole
src/manhole/__init__.py
handle_connection_repl
def handle_connection_repl(client): """ Handles connection. """ client.settimeout(None) # # disable this till we have evidence that it's needed # client.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 0) # # Note: setting SO_RCVBUF on UDS has no effect, see: http://man7.org/linux/man-pages/m...
python
def handle_connection_repl(client): """ Handles connection. """ client.settimeout(None) # # disable this till we have evidence that it's needed # client.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 0) # # Note: setting SO_RCVBUF on UDS has no effect, see: http://man7.org/linux/man-pages/m...
Handles connection.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L284-L335
ionelmc/python-manhole
src/manhole/__init__.py
handle_repl
def handle_repl(locals): """ Dumps stacktraces and runs an interactive prompt (REPL). """ dump_stacktraces() namespace = { 'dump_stacktraces': dump_stacktraces, 'sys': sys, 'os': os, 'socket': socket, 'traceback': traceback, } if locals: namesp...
python
def handle_repl(locals): """ Dumps stacktraces and runs an interactive prompt (REPL). """ dump_stacktraces() namespace = { 'dump_stacktraces': dump_stacktraces, 'sys': sys, 'os': os, 'socket': socket, 'traceback': traceback, } if locals: namesp...
Dumps stacktraces and runs an interactive prompt (REPL).
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L356-L370
ionelmc/python-manhole
src/manhole/__init__.py
install
def install(verbose=True, verbose_destination=sys.__stderr__.fileno() if hasattr(sys.__stderr__, 'fileno') else sys.__stderr__, strict=True, **kwargs): """ Installs the manhole. Args: verbose (bool): Set it to ``False`` to squelch the logging. verbose_des...
python
def install(verbose=True, verbose_destination=sys.__stderr__.fileno() if hasattr(sys.__stderr__, 'fileno') else sys.__stderr__, strict=True, **kwargs): """ Installs the manhole. Args: verbose (bool): Set it to ``False`` to squelch the logging. verbose_des...
Installs the manhole. Args: verbose (bool): Set it to ``False`` to squelch the logging. verbose_destination (file descriptor or handle): Destination for verbose messages. Default is unbuffered stderr (stderr ``2`` file descriptor). patch_fork (bool): Set it to ``False`` if you d...
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L569-L618
ionelmc/python-manhole
src/manhole/__init__.py
dump_stacktraces
def dump_stacktraces(): """ Dumps thread ids and tracebacks to stdout. """ lines = [] for thread_id, stack in sys._current_frames().items(): # pylint: disable=W0212 lines.append("\n######### ProcessID=%s, ThreadID=%s #########" % ( os.getpid(), thread_id )) for f...
python
def dump_stacktraces(): """ Dumps thread ids and tracebacks to stdout. """ lines = [] for thread_id, stack in sys._current_frames().items(): # pylint: disable=W0212 lines.append("\n######### ProcessID=%s, ThreadID=%s #########" % ( os.getpid(), thread_id )) for f...
Dumps thread ids and tracebacks to stdout.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L621-L636
ionelmc/python-manhole
src/manhole/__init__.py
ManholeThread.clone
def clone(self, **kwargs): """ Make a fresh thread with the same options. This is usually used on dead threads. """ return ManholeThread( self.get_socket, self.sigmask, self.start_timeout, connection_handler=self.connection_handler, daemon_connection=s...
python
def clone(self, **kwargs): """ Make a fresh thread with the same options. This is usually used on dead threads. """ return ManholeThread( self.get_socket, self.sigmask, self.start_timeout, connection_handler=self.connection_handler, daemon_connection=s...
Make a fresh thread with the same options. This is usually used on dead threads.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L167-L176
ionelmc/python-manhole
src/manhole/__init__.py
ManholeThread.run
def run(self): """ Runs the manhole loop. Only accepts one connection at a time because: * This thread is a daemon thread (exits when main thread exists). * The connection need exclusive access to stdin, stderr and stdout so it can redirect inputs and outputs. """ self.s...
python
def run(self): """ Runs the manhole loop. Only accepts one connection at a time because: * This thread is a daemon thread (exits when main thread exists). * The connection need exclusive access to stdin, stderr and stdout so it can redirect inputs and outputs. """ self.s...
Runs the manhole loop. Only accepts one connection at a time because: * This thread is a daemon thread (exits when main thread exists). * The connection need exclusive access to stdin, stderr and stdout so it can redirect inputs and outputs.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L184-L214
ionelmc/python-manhole
src/manhole/__init__.py
Manhole.reinstall
def reinstall(self): """ Reinstalls the manhole. Checks if the thread is running. If not, it starts it again. """ with _LOCK: if not (self.thread.is_alive() and self.thread in _ORIGINAL__ACTIVE): self.thread = self.thread.clone(bind_delay=self.reinstall_delay)...
python
def reinstall(self): """ Reinstalls the manhole. Checks if the thread is running. If not, it starts it again. """ with _LOCK: if not (self.thread.is_alive() and self.thread in _ORIGINAL__ACTIVE): self.thread = self.thread.clone(bind_delay=self.reinstall_delay)...
Reinstalls the manhole. Checks if the thread is running. If not, it starts it again.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L502-L510
ionelmc/python-manhole
src/manhole/__init__.py
Manhole.patched_fork
def patched_fork(self): """Fork a child process.""" pid = self.original_os_fork() if not pid: _LOG('Fork detected. Reinstalling Manhole.') self.reinstall() return pid
python
def patched_fork(self): """Fork a child process.""" pid = self.original_os_fork() if not pid: _LOG('Fork detected. Reinstalling Manhole.') self.reinstall() return pid
Fork a child process.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L538-L544
ionelmc/python-manhole
src/manhole/__init__.py
Manhole.patched_forkpty
def patched_forkpty(self): """Fork a new process with a new pseudo-terminal as controlling tty.""" pid, master_fd = self.original_os_forkpty() if not pid: _LOG('Fork detected. Reinstalling Manhole.') self.reinstall() return pid, master_fd
python
def patched_forkpty(self): """Fork a new process with a new pseudo-terminal as controlling tty.""" pid, master_fd = self.original_os_forkpty() if not pid: _LOG('Fork detected. Reinstalling Manhole.') self.reinstall() return pid, master_fd
Fork a new process with a new pseudo-terminal as controlling tty.
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L546-L552
ambitioninc/newrelic-api
newrelic_api/alert_conditions_nrql.py
AlertConditionsNRQL.update
def update( # noqa: C901 self, alert_condition_nrql_id, policy_id, name=None, threshold_type=None, query=None, since_value=None, terms=None, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True): """ Updates any of the option...
python
def update( # noqa: C901 self, alert_condition_nrql_id, policy_id, name=None, threshold_type=None, query=None, since_value=None, terms=None, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True): """ Updates any of the option...
Updates any of the optional parameters of the alert condition nrql :type alert_condition_nrql_id: int :param alert_condition_nrql_id: Alerts condition NRQL id to update :type policy_id: int :param policy_id: Alert policy id where target alert condition belongs to :type conditi...
https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/alert_conditions_nrql.py#L67-L224
ambitioninc/newrelic-api
newrelic_api/alert_conditions_nrql.py
AlertConditionsNRQL.create
def create( self, policy_id, name, threshold_type, query, since_value, terms, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True): """ Creates an alert condition nrql :type policy_id: int :param policy_id: A...
python
def create( self, policy_id, name, threshold_type, query, since_value, terms, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True): """ Creates an alert condition nrql :type policy_id: int :param policy_id: A...
Creates an alert condition nrql :type policy_id: int :param policy_id: Alert policy id where target alert condition nrql belongs to :type name: str :param name: The name of the alert :type threshold_type: str :param type: The threshold_type of the condition, can be sta...
https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/alert_conditions_nrql.py#L226-L350
ambitioninc/newrelic-api
newrelic_api/alert_conditions_nrql.py
AlertConditionsNRQL.delete
def delete(self, alert_condition_nrql_id): """ This API endpoint allows you to delete an alert condition nrql :type alert_condition_nrql_id: integer :param alert_condition_nrql_id: Alert Condition ID :rtype: dict :return: The JSON response of the API :: ...
python
def delete(self, alert_condition_nrql_id): """ This API endpoint allows you to delete an alert condition nrql :type alert_condition_nrql_id: integer :param alert_condition_nrql_id: Alert Condition ID :rtype: dict :return: The JSON response of the API :: ...
This API endpoint allows you to delete an alert condition nrql :type alert_condition_nrql_id: integer :param alert_condition_nrql_id: Alert Condition ID :rtype: dict :return: The JSON response of the API :: { "nrql_condition": { "type": "str...
https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/alert_conditions_nrql.py#L352-L394
ambitioninc/newrelic-api
newrelic_api/servers.py
Servers.list
def list(self, filter_name=None, filter_ids=None, filter_labels=None, page=None): """ This API endpoint returns a paginated list of the Servers associated with your New Relic account. Servers can be filtered by their name or by a list of server IDs. :type filter_name: str ...
python
def list(self, filter_name=None, filter_ids=None, filter_labels=None, page=None): """ This API endpoint returns a paginated list of the Servers associated with your New Relic account. Servers can be filtered by their name or by a list of server IDs. :type filter_name: str ...
This API endpoint returns a paginated list of the Servers associated with your New Relic account. Servers can be filtered by their name or by a list of server IDs. :type filter_name: str :param filter_name: Filter by server name :type filter_ids: list of ints :param fil...
https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/servers.py#L8-L82
ambitioninc/newrelic-api
newrelic_api/servers.py
Servers.update
def update(self, id, name=None): """ Updates any of the optional parameters of the server :type id: int :param id: Server ID :type name: str :param name: The name of the server :rtype: dict :return: The JSON response of the API :: ...
python
def update(self, id, name=None): """ Updates any of the optional parameters of the server :type id: int :param id: Server ID :type name: str :param name: The name of the server :rtype: dict :return: The JSON response of the API :: ...
Updates any of the optional parameters of the server :type id: int :param id: Server ID :type name: str :param name: The name of the server :rtype: dict :return: The JSON response of the API :: { "server": { "id...
https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/servers.py#L123-L172
ambitioninc/newrelic-api
newrelic_api/servers.py
Servers.metric_names
def metric_names(self, id, name=None, page=None): """ Return a list of known metrics and their value names for the given resource. :type id: int :param id: Server ID :type name: str :param name: Filter metrics by name :type page: int :param page: Pagina...
python
def metric_names(self, id, name=None, page=None): """ Return a list of known metrics and their value names for the given resource. :type id: int :param id: Server ID :type name: str :param name: Filter metrics by name :type page: int :param page: Pagina...
Return a list of known metrics and their value names for the given resource. :type id: int :param id: Server ID :type name: str :param name: Filter metrics by name :type page: int :param page: Pagination index :rtype: dict :return: The JSON response of...
https://github.com/ambitioninc/newrelic-api/blob/07b4430aa6ae61e4704e2928a6e7a24c76f0f424/newrelic_api/servers.py#L219-L269