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
singularityhub/singularity-cli
spython/main/apps.py
apps
def apps(self, image=None, full_path=False, root=''): ''' return list of SCIF apps in image. The Singularity software serves a scientific filesystem integration that will install apps to /scif/apps and associated data to /scif/data. For more information about SCIF, see https://sci-f.git...
python
def apps(self, image=None, full_path=False, root=''): ''' return list of SCIF apps in image. The Singularity software serves a scientific filesystem integration that will install apps to /scif/apps and associated data to /scif/data. For more information about SCIF, see https://sci-f.git...
return list of SCIF apps in image. The Singularity software serves a scientific filesystem integration that will install apps to /scif/apps and associated data to /scif/data. For more information about SCIF, see https://sci-f.github.io Parameters ========== full_path: if True...
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/apps.py#L11-L41
singularityhub/singularity-cli
spython/image/cmd/create.py
create
def create(self,image_path, size=1024, sudo=False): '''create will create a a new image Parameters ========== image_path: full path to image size: image sizein MiB, default is 1024MiB filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3 ''' f...
python
def create(self,image_path, size=1024, sudo=False): '''create will create a a new image Parameters ========== image_path: full path to image size: image sizein MiB, default is 1024MiB filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3 ''' f...
create will create a a new image Parameters ========== image_path: full path to image size: image sizein MiB, default is 1024MiB filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/image/cmd/create.py#L11-L34
singularityhub/singularity-cli
spython/utils/terminal.py
check_install
def check_install(software='singularity', quiet=True): '''check_install will attempt to run the singularity command, and return True if installed. The command line utils will not run without this check. ''' cmd = [software, '--version'] found = False try: version = run_comma...
python
def check_install(software='singularity', quiet=True): '''check_install will attempt to run the singularity command, and return True if installed. The command line utils will not run without this check. ''' cmd = [software, '--version'] found = False try: version = run_comma...
check_install will attempt to run the singularity command, and return True if installed. The command line utils will not run without this check.
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/utils/terminal.py#L25-L47
singularityhub/singularity-cli
spython/utils/terminal.py
get_singularity_version
def get_singularity_version(): '''get the singularity client version. Useful in the case that functionality has changed, etc. Can be "hacked" if needed by exporting SPYTHON_SINGULARITY_VERSION, which is checked before checking on the command line. ''' version = os.environ.get('SPYTHON_...
python
def get_singularity_version(): '''get the singularity client version. Useful in the case that functionality has changed, etc. Can be "hacked" if needed by exporting SPYTHON_SINGULARITY_VERSION, which is checked before checking on the command line. ''' version = os.environ.get('SPYTHON_...
get the singularity client version. Useful in the case that functionality has changed, etc. Can be "hacked" if needed by exporting SPYTHON_SINGULARITY_VERSION, which is checked before checking on the command line.
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/utils/terminal.py#L50-L67
singularityhub/singularity-cli
spython/utils/terminal.py
stream_command
def stream_command(cmd, no_newline_regexp="Progess", sudo=False): '''stream a command (yield) back to the user, as each line is available. # Example usage: results = [] for line in stream_command(cmd): print(line, end="") results.append(line) Parameters ===...
python
def stream_command(cmd, no_newline_regexp="Progess", sudo=False): '''stream a command (yield) back to the user, as each line is available. # Example usage: results = [] for line in stream_command(cmd): print(line, end="") results.append(line) Parameters ===...
stream a command (yield) back to the user, as each line is available. # Example usage: results = [] for line in stream_command(cmd): print(line, end="") results.append(line) Parameters ========== cmd: the command to send, should be a list for subprocess ...
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/utils/terminal.py#L75-L103
singularityhub/singularity-cli
spython/utils/terminal.py
run_command
def run_command(cmd, sudo=False, capture=True, no_newline_regexp="Progess", quiet=False): '''run_command uses subprocess to send a command to the terminal. If capture is True, we use the parent stdout, so the progress bar (and other com...
python
def run_command(cmd, sudo=False, capture=True, no_newline_regexp="Progess", quiet=False): '''run_command uses subprocess to send a command to the terminal. If capture is True, we use the parent stdout, so the progress bar (and other com...
run_command uses subprocess to send a command to the terminal. If capture is True, we use the parent stdout, so the progress bar (and other commands of interest) are piped to the user. This means we don't return the output to parse. Parameters ========== cmd: the command to s...
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/utils/terminal.py#L106-L160
singularityhub/singularity-cli
setup.py
get_requirements
def get_requirements(lookup=None): '''get_requirements reads in requirements and versions from the lookup obtained with get_lookup''' if lookup == None: lookup = get_lookup() install_requires = [] for module in lookup['INSTALL_REQUIRES']: module_name = module[0] module_meta...
python
def get_requirements(lookup=None): '''get_requirements reads in requirements and versions from the lookup obtained with get_lookup''' if lookup == None: lookup = get_lookup() install_requires = [] for module in lookup['INSTALL_REQUIRES']: module_name = module[0] module_meta...
get_requirements reads in requirements and versions from the lookup obtained with get_lookup
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/setup.py#L32-L51
singularityhub/singularity-cli
spython/main/base/sutils.py
load
def load(self, image=None): '''load an image, either an actual path on the filesystem or a uri. Parameters ========== image: the image path or uri to load (e.g., docker://ubuntu ''' from spython.image import Image from spython.instance import Instance self.simage = Image(ima...
python
def load(self, image=None): '''load an image, either an actual path on the filesystem or a uri. Parameters ========== image: the image path or uri to load (e.g., docker://ubuntu ''' from spython.image import Image from spython.instance import Instance self.simage = Image(ima...
load an image, either an actual path on the filesystem or a uri. Parameters ========== image: the image path or uri to load (e.g., docker://ubuntu
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/base/sutils.py#L16-L32
singularityhub/singularity-cli
spython/main/base/sutils.py
setenv
def setenv(self, variable, value): '''set an environment variable for Singularity Parameters ========== variable: the variable to set value: the value to set ''' os.environ[variable] = value os.putenv(variable, value) bot.debug('%s set to %s' % (variable, value))
python
def setenv(self, variable, value): '''set an environment variable for Singularity Parameters ========== variable: the variable to set value: the value to set ''' os.environ[variable] = value os.putenv(variable, value) bot.debug('%s set to %s' % (variable, value))
set an environment variable for Singularity Parameters ========== variable: the variable to set value: the value to set
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/base/sutils.py#L35-L45
singularityhub/singularity-cli
spython/main/base/sutils.py
get_uri
def get_uri(self): ''' check if the loaded image object (self.simage) has an associated uri return if yes, None if not. ''' if hasattr(self, 'simage'): if self.simage is not None: if self.simage.image not in ['', None]: # Concatenates the <uri>://<image> ...
python
def get_uri(self): ''' check if the loaded image object (self.simage) has an associated uri return if yes, None if not. ''' if hasattr(self, 'simage'): if self.simage is not None: if self.simage.image not in ['', None]: # Concatenates the <uri>://<image> ...
check if the loaded image object (self.simage) has an associated uri return if yes, None if not.
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/base/sutils.py#L61-L69
singularityhub/singularity-cli
spython/main/base/flags.py
parse_verbosity
def parse_verbosity(self, args): '''parse_verbosity will take an argument object, and return the args passed (from a dictionary) to a list Parameters ========== args: the argparse argument objects ''' flags = [] if args.silent is True: flags.append('--silent') ...
python
def parse_verbosity(self, args): '''parse_verbosity will take an argument object, and return the args passed (from a dictionary) to a list Parameters ========== args: the argparse argument objects ''' flags = [] if args.silent is True: flags.append('--silent') ...
parse_verbosity will take an argument object, and return the args passed (from a dictionary) to a list Parameters ========== args: the argparse argument objects
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/base/flags.py#L10-L31
singularityhub/singularity-cli
spython/oci/cmd/__init__.py
generate_oci_commands
def generate_oci_commands(): ''' The oci command group will allow interaction with an image using OCI commands. ''' from spython.oci import OciImage from spython.main.base.logger import println # run_command uses run_cmd, but wraps to catch error from spython.main.base.command import (...
python
def generate_oci_commands(): ''' The oci command group will allow interaction with an image using OCI commands. ''' from spython.oci import OciImage from spython.main.base.logger import println # run_command uses run_cmd, but wraps to catch error from spython.main.base.command import (...
The oci command group will allow interaction with an image using OCI commands.
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/oci/cmd/__init__.py#L9-L49
singularityhub/singularity-cli
spython/main/parse/converters.py
singularity2docker
def singularity2docker(self, runscript="/bin/bash", force=False): '''convert a Singularity recipe to a (best estimated) Dockerfile''' recipe = [ "FROM %s" %self.fromHeader ] # Comments go up front! recipe += self.comments # First add files, labels recipe += write_lines('ADD', self.files) ...
python
def singularity2docker(self, runscript="/bin/bash", force=False): '''convert a Singularity recipe to a (best estimated) Dockerfile''' recipe = [ "FROM %s" %self.fromHeader ] # Comments go up front! recipe += self.comments # First add files, labels recipe += write_lines('ADD', self.files) ...
convert a Singularity recipe to a (best estimated) Dockerfile
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L17-L41
singularityhub/singularity-cli
spython/main/parse/converters.py
write_lines
def write_lines(label, lines): '''write a list of lines with a header for a section. Parameters ========== lines: one or more lines to write, with header appended ''' result = [] continued = False for line in lines: if continued: result.append(line) ...
python
def write_lines(label, lines): '''write a list of lines with a header for a section. Parameters ========== lines: one or more lines to write, with header appended ''' result = [] continued = False for line in lines: if continued: result.append(line) ...
write a list of lines with a header for a section. Parameters ========== lines: one or more lines to write, with header appended
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L44-L63
singularityhub/singularity-cli
spython/main/parse/converters.py
create_runscript
def create_runscript(self, default="/bin/bash", force=False): '''create_entrypoint is intended to create a singularity runscript based on a Docker entrypoint or command. We first use the Docker ENTRYPOINT, if defined. If not, we use the CMD. If neither is found, we use function default. ...
python
def create_runscript(self, default="/bin/bash", force=False): '''create_entrypoint is intended to create a singularity runscript based on a Docker entrypoint or command. We first use the Docker ENTRYPOINT, if defined. If not, we use the CMD. If neither is found, we use function default. ...
create_entrypoint is intended to create a singularity runscript based on a Docker entrypoint or command. We first use the Docker ENTRYPOINT, if defined. If not, we use the CMD. If neither is found, we use function default. Parameters ========== default: set a default entrypoin...
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L69-L98
singularityhub/singularity-cli
spython/main/parse/converters.py
create_section
def create_section(self, attribute, name=None): '''create a section based on key, value recipe pairs, This is used for files or label Parameters ========== attribute: the name of the data section, either labels or files name: the name to write to the recipe file (e.g., %name). ...
python
def create_section(self, attribute, name=None): '''create a section based on key, value recipe pairs, This is used for files or label Parameters ========== attribute: the name of the data section, either labels or files name: the name to write to the recipe file (e.g., %name). ...
create a section based on key, value recipe pairs, This is used for files or label Parameters ========== attribute: the name of the data section, either labels or files name: the name to write to the recipe file (e.g., %name). if not defined, the attribute name is used.
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L101-L140
singularityhub/singularity-cli
spython/main/parse/converters.py
finish_section
def finish_section(section, name): '''finish_section will add the header to a section, to finish the recipe take a custom command or list and return a section. Parameters ========== section: the section content, without a header name: the name of the section for the header '...
python
def finish_section(section, name): '''finish_section will add the header to a section, to finish the recipe take a custom command or list and return a section. Parameters ========== section: the section content, without a header name: the name of the section for the header '...
finish_section will add the header to a section, to finish the recipe take a custom command or list and return a section. Parameters ========== section: the section content, without a header name: the name of the section for the header
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L143-L157
singularityhub/singularity-cli
spython/main/parse/converters.py
create_keyval_section
def create_keyval_section(pairs, name): '''create a section based on key, value recipe pairs, This is used for files or label Parameters ========== section: the list of values to return as a parsed list of lines name: the name of the section to write (e.g., files) ''' secti...
python
def create_keyval_section(pairs, name): '''create a section based on key, value recipe pairs, This is used for files or label Parameters ========== section: the list of values to return as a parsed list of lines name: the name of the section to write (e.g., files) ''' secti...
create a section based on key, value recipe pairs, This is used for files or label Parameters ========== section: the list of values to return as a parsed list of lines name: the name of the section to write (e.g., files)
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L160-L173
singularityhub/singularity-cli
spython/main/parse/converters.py
create_env_section
def create_env_section(pairs, name): '''environment key value pairs need to be joined by an equal, and exported at the end. Parameters ========== section: the list of values to return as a parsed list of lines name: the name of the section to write (e.g., files) ''' section...
python
def create_env_section(pairs, name): '''environment key value pairs need to be joined by an equal, and exported at the end. Parameters ========== section: the list of values to return as a parsed list of lines name: the name of the section to write (e.g., files) ''' section...
environment key value pairs need to be joined by an equal, and exported at the end. Parameters ========== section: the list of values to return as a parsed list of lines name: the name of the section to write (e.g., files)
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L176-L189
singularityhub/singularity-cli
spython/main/parse/converters.py
docker2singularity
def docker2singularity(self, runscript="/bin/bash", force=False): '''docker2singularity will return a Singularity build recipe based on a the loaded recipe object. It doesn't take any arguments as the recipe object contains the sections, and the calling function determines saving / output logi...
python
def docker2singularity(self, runscript="/bin/bash", force=False): '''docker2singularity will return a Singularity build recipe based on a the loaded recipe object. It doesn't take any arguments as the recipe object contains the sections, and the calling function determines saving / output logi...
docker2singularity will return a Singularity build recipe based on a the loaded recipe object. It doesn't take any arguments as the recipe object contains the sections, and the calling function determines saving / output logic.
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/converters.py#L192-L216
singularityhub/singularity-cli
spython/main/pull.py
pull
def pull(self, image=None, name=None, pull_folder='', ext="simg", force=False, capture=False, name_by_commit=False, name_by_hash=False, stream=False): '''pull will pull a singularity hub or Docker image Parameters ...
python
def pull(self, image=None, name=None, pull_folder='', ext="simg", force=False, capture=False, name_by_commit=False, name_by_hash=False, stream=False): '''pull will pull a singularity hub or Docker image Parameters ...
pull will pull a singularity hub or Docker image Parameters ========== image: the complete image uri. If not provided, the client loaded is used pull_folder: if not defined, pulls to $PWD (''). If defined, pulls to user specified location instead. Docker ...
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/pull.py#L17-L129
jlevy/strif
strif.py
new_timestamped_uid
def new_timestamped_uid(bits=32): """ A unique id that begins with an ISO timestamp followed by fractions of seconds and bits of randomness. The advantage of this is it sorts nicely by time, while still being unique. Example: 20150912T084555Z-378465-43vtwbx """ return "%s-%s" % (re.sub('[^\w.]', '', datetim...
python
def new_timestamped_uid(bits=32): """ A unique id that begins with an ISO timestamp followed by fractions of seconds and bits of randomness. The advantage of this is it sorts nicely by time, while still being unique. Example: 20150912T084555Z-378465-43vtwbx """ return "%s-%s" % (re.sub('[^\w.]', '', datetim...
A unique id that begins with an ISO timestamp followed by fractions of seconds and bits of randomness. The advantage of this is it sorts nicely by time, while still being unique. Example: 20150912T084555Z-378465-43vtwbx
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L76-L82
jlevy/strif
strif.py
abbreviate_str
def abbreviate_str(string, max_len=80, indicator="..."): """ Abbreviate a string, adding an indicator like an ellipsis if required. """ if not string or not max_len or len(string) <= max_len: return string elif max_len <= len(indicator): return string[0:max_len] else: return string[0:max_len - l...
python
def abbreviate_str(string, max_len=80, indicator="..."): """ Abbreviate a string, adding an indicator like an ellipsis if required. """ if not string or not max_len or len(string) <= max_len: return string elif max_len <= len(indicator): return string[0:max_len] else: return string[0:max_len - l...
Abbreviate a string, adding an indicator like an ellipsis if required.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L85-L94
jlevy/strif
strif.py
abbreviate_list
def abbreviate_list(items, max_items=10, item_max_len=40, joiner=", ", indicator="..."): """ Abbreviate a list, truncating each element and adding an indicator at the end if the whole list was truncated. Set item_max_len to None or 0 not to truncate items. """ if not items: return items else: shorte...
python
def abbreviate_list(items, max_items=10, item_max_len=40, joiner=", ", indicator="..."): """ Abbreviate a list, truncating each element and adding an indicator at the end if the whole list was truncated. Set item_max_len to None or 0 not to truncate items. """ if not items: return items else: shorte...
Abbreviate a list, truncating each element and adding an indicator at the end if the whole list was truncated. Set item_max_len to None or 0 not to truncate items.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L97-L108
jlevy/strif
strif.py
expand_variables
def expand_variables(template_str, value_map, transformer=None): """ Expand a template string like "blah blah $FOO blah" using given value mapping. """ if template_str is None: return None else: if transformer is None: transformer = lambda v: v try: # Don't bother iterating items for P...
python
def expand_variables(template_str, value_map, transformer=None): """ Expand a template string like "blah blah $FOO blah" using given value mapping. """ if template_str is None: return None else: if transformer is None: transformer = lambda v: v try: # Don't bother iterating items for P...
Expand a template string like "blah blah $FOO blah" using given value mapping.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L114-L128
jlevy/strif
strif.py
shell_expand_to_popen
def shell_expand_to_popen(template, values): """ Expand a template like "cp $SOURCE $TARGET/blah" into a list of popen arguments. """ return [expand_variables(item, values) for item in shlex.split(template)]
python
def shell_expand_to_popen(template, values): """ Expand a template like "cp $SOURCE $TARGET/blah" into a list of popen arguments. """ return [expand_variables(item, values) for item in shlex.split(template)]
Expand a template like "cp $SOURCE $TARGET/blah" into a list of popen arguments.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L139-L143
jlevy/strif
strif.py
move_to_backup
def move_to_backup(path, backup_suffix=BACKUP_SUFFIX): """ Move the given file or directory to the same name, with a backup suffix. If backup_suffix not supplied, move it to the extension ".bak". NB: If backup_suffix is supplied and is None, don't do anything. """ if backup_suffix and os.path.exists(path): ...
python
def move_to_backup(path, backup_suffix=BACKUP_SUFFIX): """ Move the given file or directory to the same name, with a backup suffix. If backup_suffix not supplied, move it to the extension ".bak". NB: If backup_suffix is supplied and is None, don't do anything. """ if backup_suffix and os.path.exists(path): ...
Move the given file or directory to the same name, with a backup suffix. If backup_suffix not supplied, move it to the extension ".bak". NB: If backup_suffix is supplied and is None, don't do anything.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L149-L164
jlevy/strif
strif.py
make_all_dirs
def make_all_dirs(path, mode=0o777): """ Ensure local dir, with all its parent dirs, are created. Unlike os.makedirs(), will not fail if the path already exists. """ # Avoid races inherent to doing this in two steps (check then create). # Python 3 has exist_ok but the approach below works for Python 2+3. ...
python
def make_all_dirs(path, mode=0o777): """ Ensure local dir, with all its parent dirs, are created. Unlike os.makedirs(), will not fail if the path already exists. """ # Avoid races inherent to doing this in two steps (check then create). # Python 3 has exist_ok but the approach below works for Python 2+3. ...
Ensure local dir, with all its parent dirs, are created. Unlike os.makedirs(), will not fail if the path already exists.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L167-L182
jlevy/strif
strif.py
make_parent_dirs
def make_parent_dirs(path, mode=0o777): """ Ensure parent directories of a file are created as needed. """ parent = os.path.dirname(path) if parent: make_all_dirs(parent, mode) return path
python
def make_parent_dirs(path, mode=0o777): """ Ensure parent directories of a file are created as needed. """ parent = os.path.dirname(path) if parent: make_all_dirs(parent, mode) return path
Ensure parent directories of a file are created as needed.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L185-L192
jlevy/strif
strif.py
atomic_output_file
def atomic_output_file(dest_path, make_parents=False, backup_suffix=None, suffix=".partial.%s"): """ A context manager for convenience in writing a file or directory in an atomic way. Set up a temporary name, then rename it after the operation is done, optionally making a backup of the previous file or director...
python
def atomic_output_file(dest_path, make_parents=False, backup_suffix=None, suffix=".partial.%s"): """ A context manager for convenience in writing a file or directory in an atomic way. Set up a temporary name, then rename it after the operation is done, optionally making a backup of the previous file or director...
A context manager for convenience in writing a file or directory in an atomic way. Set up a temporary name, then rename it after the operation is done, optionally making a backup of the previous file or directory, if present.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L196-L221
jlevy/strif
strif.py
temp_output_file
def temp_output_file(prefix="tmp", suffix="", dir=None, make_parents=False, always_clean=False): """ A context manager for convenience in creating a temporary file, which is deleted when exiting the context. Usage: with temp_output_file() as (fd, path): ... """ return _temp_output(False, prefix=p...
python
def temp_output_file(prefix="tmp", suffix="", dir=None, make_parents=False, always_clean=False): """ A context manager for convenience in creating a temporary file, which is deleted when exiting the context. Usage: with temp_output_file() as (fd, path): ... """ return _temp_output(False, prefix=p...
A context manager for convenience in creating a temporary file, which is deleted when exiting the context. Usage: with temp_output_file() as (fd, path): ...
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L224-L234
jlevy/strif
strif.py
temp_output_dir
def temp_output_dir(prefix="tmp", suffix="", dir=None, make_parents=False, always_clean=False): """ A context manager for convenience in creating a temporary directory, which is deleted when exiting the context. Usage: with temp_output_dir() as dirname: ... """ return _temp_output(True, prefix=pr...
python
def temp_output_dir(prefix="tmp", suffix="", dir=None, make_parents=False, always_clean=False): """ A context manager for convenience in creating a temporary directory, which is deleted when exiting the context. Usage: with temp_output_dir() as dirname: ... """ return _temp_output(True, prefix=pr...
A context manager for convenience in creating a temporary directory, which is deleted when exiting the context. Usage: with temp_output_dir() as dirname: ...
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L237-L247
jlevy/strif
strif.py
read_string_from_file
def read_string_from_file(path, encoding="utf8"): """ Read entire contents of file into a string. """ with codecs.open(path, "rb", encoding=encoding) as f: value = f.read() return value
python
def read_string_from_file(path, encoding="utf8"): """ Read entire contents of file into a string. """ with codecs.open(path, "rb", encoding=encoding) as f: value = f.read() return value
Read entire contents of file into a string.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L278-L284
jlevy/strif
strif.py
write_string_to_file
def write_string_to_file(path, string, make_parents=False, backup_suffix=BACKUP_SUFFIX, encoding="utf8"): """ Write entire file with given string contents, atomically. Keeps backup by default. """ with atomic_output_file(path, make_parents=make_parents, backup_suffix=backup_suffix) as tmp_path: with codecs....
python
def write_string_to_file(path, string, make_parents=False, backup_suffix=BACKUP_SUFFIX, encoding="utf8"): """ Write entire file with given string contents, atomically. Keeps backup by default. """ with atomic_output_file(path, make_parents=make_parents, backup_suffix=backup_suffix) as tmp_path: with codecs....
Write entire file with given string contents, atomically. Keeps backup by default.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L287-L293
jlevy/strif
strif.py
set_file_mtime
def set_file_mtime(path, mtime, atime=None): """Set access and modification times on a file.""" if not atime: atime = mtime f = open(path, 'a') try: os.utime(path, (atime, mtime)) finally: f.close()
python
def set_file_mtime(path, mtime, atime=None): """Set access and modification times on a file.""" if not atime: atime = mtime f = open(path, 'a') try: os.utime(path, (atime, mtime)) finally: f.close()
Set access and modification times on a file.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L296-L304
jlevy/strif
strif.py
copyfile_atomic
def copyfile_atomic(source_path, dest_path, make_parents=False, backup_suffix=None): """ Copy file on local filesystem in an atomic way, so partial copies never exist. Preserves timestamps. """ with atomic_output_file(dest_path, make_parents=make_parents, backup_suffix=backup_suffix) as tmp_path: shutil.cop...
python
def copyfile_atomic(source_path, dest_path, make_parents=False, backup_suffix=None): """ Copy file on local filesystem in an atomic way, so partial copies never exist. Preserves timestamps. """ with atomic_output_file(dest_path, make_parents=make_parents, backup_suffix=backup_suffix) as tmp_path: shutil.cop...
Copy file on local filesystem in an atomic way, so partial copies never exist. Preserves timestamps.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L307-L313
jlevy/strif
strif.py
copytree_atomic
def copytree_atomic(source_path, dest_path, make_parents=False, backup_suffix=None, symlinks=False): """ Copy a file or directory recursively, and atomically, reanaming file or top-level dir when done. Unlike shutil.copytree, this will not fail on a file. """ if os.path.isdir(source_path): with atomic_out...
python
def copytree_atomic(source_path, dest_path, make_parents=False, backup_suffix=None, symlinks=False): """ Copy a file or directory recursively, and atomically, reanaming file or top-level dir when done. Unlike shutil.copytree, this will not fail on a file. """ if os.path.isdir(source_path): with atomic_out...
Copy a file or directory recursively, and atomically, reanaming file or top-level dir when done. Unlike shutil.copytree, this will not fail on a file.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L316-L325
jlevy/strif
strif.py
movefile
def movefile(source_path, dest_path, make_parents=False, backup_suffix=None): """ Move file. With a few extra options. """ if make_parents: make_parent_dirs(dest_path) move_to_backup(dest_path, backup_suffix=backup_suffix) shutil.move(source_path, dest_path)
python
def movefile(source_path, dest_path, make_parents=False, backup_suffix=None): """ Move file. With a few extra options. """ if make_parents: make_parent_dirs(dest_path) move_to_backup(dest_path, backup_suffix=backup_suffix) shutil.move(source_path, dest_path)
Move file. With a few extra options.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L328-L335
jlevy/strif
strif.py
rmtree_or_file
def rmtree_or_file(path, ignore_errors=False, onerror=None): """ rmtree fails on files or symlinks. This removes the target, whatever it is. """ # TODO: Could add an rsync-based delete, as in # https://github.com/vivlabs/instaclone/blob/master/instaclone/instaclone.py#L127-L143 if ignore_errors and not os.p...
python
def rmtree_or_file(path, ignore_errors=False, onerror=None): """ rmtree fails on files or symlinks. This removes the target, whatever it is. """ # TODO: Could add an rsync-based delete, as in # https://github.com/vivlabs/instaclone/blob/master/instaclone/instaclone.py#L127-L143 if ignore_errors and not os.p...
rmtree fails on files or symlinks. This removes the target, whatever it is.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L338-L349
jlevy/strif
strif.py
chmod_native
def chmod_native(path, mode_expression, recursive=False): """ This is ugly and will only work on POSIX, but the built-in Python os.chmod support is very minimal, and neither supports fast recursive chmod nor "+X" type expressions, both of which are slow for large trees. So just shell out. """ popenargs = ["...
python
def chmod_native(path, mode_expression, recursive=False): """ This is ugly and will only work on POSIX, but the built-in Python os.chmod support is very minimal, and neither supports fast recursive chmod nor "+X" type expressions, both of which are slow for large trees. So just shell out. """ popenargs = ["...
This is ugly and will only work on POSIX, but the built-in Python os.chmod support is very minimal, and neither supports fast recursive chmod nor "+X" type expressions, both of which are slow for large trees. So just shell out.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L352-L363
jlevy/strif
strif.py
file_sha1
def file_sha1(path): """ Compute SHA1 hash of a file. """ sha1 = hashlib.sha1() with open(path, "rb") as f: while True: block = f.read(2 ** 10) if not block: break sha1.update(block) return sha1.hexdigest()
python
def file_sha1(path): """ Compute SHA1 hash of a file. """ sha1 = hashlib.sha1() with open(path, "rb") as f: while True: block = f.read(2 ** 10) if not block: break sha1.update(block) return sha1.hexdigest()
Compute SHA1 hash of a file.
https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L366-L377
pvizeli/ha-ffmpeg
haffmpeg/tools.py
ImageFrame.get_image
async def get_image( self, input_source: str, output_format: str = IMAGE_JPEG, extra_cmd: Optional[str] = None, timeout: int = 15, ) -> Optional[bytes]: """Open FFmpeg process as capture 1 frame.""" command = ["-an", "-frames:v", "1", "-c:v", output_format] ...
python
async def get_image( self, input_source: str, output_format: str = IMAGE_JPEG, extra_cmd: Optional[str] = None, timeout: int = 15, ) -> Optional[bytes]: """Open FFmpeg process as capture 1 frame.""" command = ["-an", "-frames:v", "1", "-c:v", output_format] ...
Open FFmpeg process as capture 1 frame.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/tools.py#L19-L51
pvizeli/ha-ffmpeg
haffmpeg/tools.py
FFVersion.get_version
async def get_version(self, timeout: int = 15) -> Optional[str]: """Execute FFmpeg process and parse the version information. Return full FFmpeg version string. Such as 3.4.2-tessus """ command = ["-version"] # open input for capture 1 frame is_open = await self.open(cm...
python
async def get_version(self, timeout: int = 15) -> Optional[str]: """Execute FFmpeg process and parse the version information. Return full FFmpeg version string. Such as 3.4.2-tessus """ command = ["-version"] # open input for capture 1 frame is_open = await self.open(cm...
Execute FFmpeg process and parse the version information. Return full FFmpeg version string. Such as 3.4.2-tessus
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/tools.py#L57-L85
pvizeli/ha-ffmpeg
haffmpeg/camera.py
CameraMjpeg.open_camera
def open_camera( self, input_source: str, extra_cmd: Optional[str] = None ) -> Coroutine: """Open FFmpeg process as mjpeg video stream. Return A coroutine. """ command = ["-an", "-c:v", "mjpeg"] return self.open( cmd=command, input_source=inp...
python
def open_camera( self, input_source: str, extra_cmd: Optional[str] = None ) -> Coroutine: """Open FFmpeg process as mjpeg video stream. Return A coroutine. """ command = ["-an", "-c:v", "mjpeg"] return self.open( cmd=command, input_source=inp...
Open FFmpeg process as mjpeg video stream. Return A coroutine.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/camera.py#L10-L24
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface._load_nvrtc_lib
def _load_nvrtc_lib(self, lib_path): """ Loads the NVRTC shared library, with an optional search path in lib_path. """ if sizeof(c_void_p) == 8: if system() == 'Windows': def_lib_name = 'nvrtc64_92.dll' elif system() == 'Darwin': ...
python
def _load_nvrtc_lib(self, lib_path): """ Loads the NVRTC shared library, with an optional search path in lib_path. """ if sizeof(c_void_p) == 8: if system() == 'Windows': def_lib_name = 'nvrtc64_92.dll' elif system() == 'Darwin': ...
Loads the NVRTC shared library, with an optional search path in lib_path.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L89-L179
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcCreateProgram
def nvrtcCreateProgram(self, src, name, headers, include_names): """ Creates and returns a new NVRTC program object. """ res = c_void_p() headers_array = (c_char_p * len(headers))() headers_array[:] = encode_str_list(headers) include_names_array = (c_char_p * len(...
python
def nvrtcCreateProgram(self, src, name, headers, include_names): """ Creates and returns a new NVRTC program object. """ res = c_void_p() headers_array = (c_char_p * len(headers))() headers_array[:] = encode_str_list(headers) include_names_array = (c_char_p * len(...
Creates and returns a new NVRTC program object.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L190-L204
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcDestroyProgram
def nvrtcDestroyProgram(self, prog): """ Destroys the given NVRTC program object. """ code = self._lib.nvrtcDestroyProgram(byref(prog)) self._throw_on_error(code) return
python
def nvrtcDestroyProgram(self, prog): """ Destroys the given NVRTC program object. """ code = self._lib.nvrtcDestroyProgram(byref(prog)) self._throw_on_error(code) return
Destroys the given NVRTC program object.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L206-L212
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcCompileProgram
def nvrtcCompileProgram(self, prog, options): """ Compiles the NVRTC program object into PTX, using the provided options array. See the NVRTC API documentation for accepted options. """ options_array = (c_char_p * len(options))() options_array[:] = encode_str_list(option...
python
def nvrtcCompileProgram(self, prog, options): """ Compiles the NVRTC program object into PTX, using the provided options array. See the NVRTC API documentation for accepted options. """ options_array = (c_char_p * len(options))() options_array[:] = encode_str_list(option...
Compiles the NVRTC program object into PTX, using the provided options array. See the NVRTC API documentation for accepted options.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L214-L223
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcGetPTX
def nvrtcGetPTX(self, prog): """ Returns the compiled PTX for the NVRTC program object. """ size = c_size_t() code = self._lib.nvrtcGetPTXSize(prog, byref(size)) self._throw_on_error(code) buf = create_string_buffer(size.value) code = self._lib.nvrtcGetPT...
python
def nvrtcGetPTX(self, prog): """ Returns the compiled PTX for the NVRTC program object. """ size = c_size_t() code = self._lib.nvrtcGetPTXSize(prog, byref(size)) self._throw_on_error(code) buf = create_string_buffer(size.value) code = self._lib.nvrtcGetPT...
Returns the compiled PTX for the NVRTC program object.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L225-L237
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcGetProgramLog
def nvrtcGetProgramLog(self, prog): """ Returns the log for the NVRTC program object. Only useful after calls to nvrtcCompileProgram or nvrtcVerifyProgram. """ size = c_size_t() code = self._lib.nvrtcGetProgramLogSize(prog, byref(size)) self._throw_on_error(code)...
python
def nvrtcGetProgramLog(self, prog): """ Returns the log for the NVRTC program object. Only useful after calls to nvrtcCompileProgram or nvrtcVerifyProgram. """ size = c_size_t() code = self._lib.nvrtcGetProgramLogSize(prog, byref(size)) self._throw_on_error(code)...
Returns the log for the NVRTC program object. Only useful after calls to nvrtcCompileProgram or nvrtcVerifyProgram.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L239-L253
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcAddNameExpression
def nvrtcAddNameExpression(self, prog, name_expression): """ Notes the given name expression denoting a __global__ function or function template instantiation. """ code = self._lib.nvrtcAddNameExpression(prog, c_char_p(encode_str(na...
python
def nvrtcAddNameExpression(self, prog, name_expression): """ Notes the given name expression denoting a __global__ function or function template instantiation. """ code = self._lib.nvrtcAddNameExpression(prog, c_char_p(encode_str(na...
Notes the given name expression denoting a __global__ function or function template instantiation.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L255-L263
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcGetLoweredName
def nvrtcGetLoweredName(self, prog, name_expression): """ Notes the given name expression denoting a __global__ function or function template instantiation. """ lowered_name = c_char_p() code = self._lib.nvrtcGetLoweredName(prog, ...
python
def nvrtcGetLoweredName(self, prog, name_expression): """ Notes the given name expression denoting a __global__ function or function template instantiation. """ lowered_name = c_char_p() code = self._lib.nvrtcGetLoweredName(prog, ...
Notes the given name expression denoting a __global__ function or function template instantiation.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L265-L275
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcGetErrorString
def nvrtcGetErrorString(self, code): """ Returns a text identifier for the given NVRTC status code. """ code_int = c_int(code) res = self._lib.nvrtcGetErrorString(code_int) return res.decode('utf-8')
python
def nvrtcGetErrorString(self, code): """ Returns a text identifier for the given NVRTC status code. """ code_int = c_int(code) res = self._lib.nvrtcGetErrorString(code_int) return res.decode('utf-8')
Returns a text identifier for the given NVRTC status code.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L277-L283
NVIDIA/pynvrtc
pynvrtc/interface.py
NVRTCInterface.nvrtcVersion
def nvrtcVersion(self): """ Returns the loaded NVRTC library version as a (major, minor) tuple. """ major = c_int() minor = c_int() code = self._lib.nvrtcVersion(byref(major), byref(minor)) self._throw_on_error(code) return (major.value, minor.value)
python
def nvrtcVersion(self): """ Returns the loaded NVRTC library version as a (major, minor) tuple. """ major = c_int() minor = c_int() code = self._lib.nvrtcVersion(byref(major), byref(minor)) self._throw_on_error(code) return (major.value, minor.value)
Returns the loaded NVRTC library version as a (major, minor) tuple.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/interface.py#L285-L293
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg.is_running
def is_running(self) -> bool: """Return True if ffmpeg is running.""" if self._proc is None or self._proc.returncode is not None: return False return True
python
def is_running(self) -> bool: """Return True if ffmpeg is running.""" if self._proc is None or self._proc.returncode is not None: return False return True
Return True if ffmpeg is running.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L35-L39
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg._generate_ffmpeg_cmd
def _generate_ffmpeg_cmd( self, cmd: List[str], input_source: Optional[str], output: Optional[str], extra_cmd: Optional[str] = None, ) -> None: """Generate ffmpeg command line.""" self._argv = [self._ffmpeg] # start command init if input_sourc...
python
def _generate_ffmpeg_cmd( self, cmd: List[str], input_source: Optional[str], output: Optional[str], extra_cmd: Optional[str] = None, ) -> None: """Generate ffmpeg command line.""" self._argv = [self._ffmpeg] # start command init if input_sourc...
Generate ffmpeg command line.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L41-L61
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg._put_input
def _put_input(self, input_source: str) -> None: """Put input string to ffmpeg command.""" input_cmd = shlex.split(str(input_source)) if len(input_cmd) > 1: self._argv.extend(input_cmd) else: self._argv.extend(["-i", input_source])
python
def _put_input(self, input_source: str) -> None: """Put input string to ffmpeg command.""" input_cmd = shlex.split(str(input_source)) if len(input_cmd) > 1: self._argv.extend(input_cmd) else: self._argv.extend(["-i", input_source])
Put input string to ffmpeg command.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L63-L69
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg._put_output
def _put_output(self, output: Optional[str]) -> None: """Put output string to ffmpeg command.""" if output is None: self._argv.extend(["-f", "null", "-"]) return output_cmd = shlex.split(str(output)) if len(output_cmd) > 1: self._argv.extend(output_cm...
python
def _put_output(self, output: Optional[str]) -> None: """Put output string to ffmpeg command.""" if output is None: self._argv.extend(["-f", "null", "-"]) return output_cmd = shlex.split(str(output)) if len(output_cmd) > 1: self._argv.extend(output_cm...
Put output string to ffmpeg command.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L71-L81
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg._merge_filters
def _merge_filters(self) -> None: """Merge all filter config in command line.""" for opts in (["-filter:a", "-af"], ["-filter:v", "-vf"]): filter_list = [] new_argv = [] cmd_iter = iter(self._argv) for element in cmd_iter: if element in opt...
python
def _merge_filters(self) -> None: """Merge all filter config in command line.""" for opts in (["-filter:a", "-af"], ["-filter:v", "-vf"]): filter_list = [] new_argv = [] cmd_iter = iter(self._argv) for element in cmd_iter: if element in opt...
Merge all filter config in command line.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L83-L98
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg.open
async def open( self, cmd: List[str], input_source: Optional[str], output: Optional[str] = "-", extra_cmd: Optional[str] = None, stdout_pipe: bool = True, stderr_pipe: bool = False, ) -> bool: """Start a ffmpeg instance and pipe output.""" stdo...
python
async def open( self, cmd: List[str], input_source: Optional[str], output: Optional[str] = "-", extra_cmd: Optional[str] = None, stdout_pipe: bool = True, stderr_pipe: bool = False, ) -> bool: """Start a ffmpeg instance and pipe output.""" stdo...
Start a ffmpeg instance and pipe output.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L105-L142
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg.close
async def close(self, timeout=5) -> None: """Stop a ffmpeg instance.""" if not self.is_running: _LOGGER.warning("FFmpeg isn't running!") return # Can't use communicate because we attach the output to a streamreader def _close(): """Close ffmpeg.""" ...
python
async def close(self, timeout=5) -> None: """Stop a ffmpeg instance.""" if not self.is_running: _LOGGER.warning("FFmpeg isn't running!") return # Can't use communicate because we attach the output to a streamreader def _close(): """Close ffmpeg.""" ...
Stop a ffmpeg instance.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L144-L166
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg.kill
def kill(self) -> None: """Kill ffmpeg job.""" self._proc.kill() self._loop.run_in_executor(None, self._proc.communicate)
python
def kill(self) -> None: """Kill ffmpeg job.""" self._proc.kill() self._loop.run_in_executor(None, self._proc.communicate)
Kill ffmpeg job.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L168-L171
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpeg.get_reader
async def get_reader(self, source=FFMPEG_STDOUT) -> asyncio.StreamReader: """Create and return streamreader.""" reader = asyncio.StreamReader(loop=self._loop) reader_protocol = asyncio.StreamReaderProtocol(reader) # Attach stream if source == FFMPEG_STDOUT: await sel...
python
async def get_reader(self, source=FFMPEG_STDOUT) -> asyncio.StreamReader: """Create and return streamreader.""" reader = asyncio.StreamReader(loop=self._loop) reader_protocol = asyncio.StreamReaderProtocol(reader) # Attach stream if source == FFMPEG_STDOUT: await sel...
Create and return streamreader.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L173-L189
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpegWorker.close
def close(self, timeout: int = 5) -> None: """Stop a ffmpeg instance. Return a coroutine """ if self._read_task is not None and not self._read_task.cancelled(): self._read_task.cancel() return super().close(timeout)
python
def close(self, timeout: int = 5) -> None: """Stop a ffmpeg instance. Return a coroutine """ if self._read_task is not None and not self._read_task.cancelled(): self._read_task.cancel() return super().close(timeout)
Stop a ffmpeg instance. Return a coroutine
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L203-L211
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpegWorker._process_lines
async def _process_lines(self, pattern: Optional[str] = None) -> None: """Read line from pipe they match with pattern.""" if pattern is not None: cmp = re.compile(pattern) _LOGGER.debug("Start working with pattern '%s'.", pattern) # read lines while self.is_running:...
python
async def _process_lines(self, pattern: Optional[str] = None) -> None: """Read line from pipe they match with pattern.""" if pattern is not None: cmp = re.compile(pattern) _LOGGER.debug("Start working with pattern '%s'.", pattern) # read lines while self.is_running:...
Read line from pipe they match with pattern.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L213-L239
pvizeli/ha-ffmpeg
haffmpeg/core.py
HAFFmpegWorker.start_worker
async def start_worker( self, cmd: List[str], input_source: str, output: Optional[str] = None, extra_cmd: Optional[str] = None, pattern: Optional[str] = None, reading: str = FFMPEG_STDERR, ) -> None: """Start ffmpeg do process data from output.""" ...
python
async def start_worker( self, cmd: List[str], input_source: str, output: Optional[str] = None, extra_cmd: Optional[str] = None, pattern: Optional[str] = None, reading: str = FFMPEG_STDERR, ) -> None: """Start ffmpeg do process data from output.""" ...
Start ffmpeg do process data from output.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/core.py#L245-L280
NVIDIA/pynvrtc
pynvrtc/compiler.py
Program.compile
def compile(self, options=[]): """ Compiles the program object to PTX using the compiler options specified in `options`. """ try: self._interface.nvrtcCompileProgram(self._program, options) ptx = self._interface.nvrtcGetPTX(self._program) retur...
python
def compile(self, options=[]): """ Compiles the program object to PTX using the compiler options specified in `options`. """ try: self._interface.nvrtcCompileProgram(self._program, options) ptx = self._interface.nvrtcGetPTX(self._program) retur...
Compiles the program object to PTX using the compiler options specified in `options`.
https://github.com/NVIDIA/pynvrtc/blob/fffa9f6f4a7ee1d452346cbdf68b84b5246ccffb/pynvrtc/compiler.py#L58-L69
pvizeli/ha-ffmpeg
haffmpeg/sensor.py
SensorNoise.set_options
def set_options( self, time_duration: int = 1, time_reset: int = 2, peak: int = -30 ) -> None: """Set option parameter for noise sensor.""" self._time_duration = time_duration self._time_reset = time_reset self._peak = peak
python
def set_options( self, time_duration: int = 1, time_reset: int = 2, peak: int = -30 ) -> None: """Set option parameter for noise sensor.""" self._time_duration = time_duration self._time_reset = time_reset self._peak = peak
Set option parameter for noise sensor.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/sensor.py#L34-L40
pvizeli/ha-ffmpeg
haffmpeg/sensor.py
SensorNoise.open_sensor
def open_sensor( self, input_source: str, output_dest: Optional[str] = None, extra_cmd: Optional[str] = None, ) -> Coroutine: """Open FFmpeg process for read autio stream. Return a coroutine. """ command = ["-vn", "-filter:a", "silencedetect=n={}dB:d=...
python
def open_sensor( self, input_source: str, output_dest: Optional[str] = None, extra_cmd: Optional[str] = None, ) -> Coroutine: """Open FFmpeg process for read autio stream. Return a coroutine. """ command = ["-vn", "-filter:a", "silencedetect=n={}dB:d=...
Open FFmpeg process for read autio stream. Return a coroutine.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/sensor.py#L42-L61
pvizeli/ha-ffmpeg
haffmpeg/sensor.py
SensorNoise._worker_process
async def _worker_process(self) -> None: """This function processing data.""" state = self.STATE_DETECT timeout = self._time_duration self._loop.call_soon(self._callback, False) re_start = re.compile("silence_start") re_end = re.compile("silence_end") # process...
python
async def _worker_process(self) -> None: """This function processing data.""" state = self.STATE_DETECT timeout = self._time_duration self._loop.call_soon(self._callback, False) re_start = re.compile("silence_start") re_end = re.compile("silence_end") # process...
This function processing data.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/sensor.py#L63-L119
pvizeli/ha-ffmpeg
haffmpeg/sensor.py
SensorMotion.set_options
def set_options( self, time_reset: int = 60, time_repeat: int = 0, repeat: int = 0, changes: int = 10, ) -> None: """Set option parameter for noise sensor.""" self._time_reset = time_reset self._time_repeat = time_repeat self._repeat = repeat ...
python
def set_options( self, time_reset: int = 60, time_repeat: int = 0, repeat: int = 0, changes: int = 10, ) -> None: """Set option parameter for noise sensor.""" self._time_reset = time_reset self._time_repeat = time_repeat self._repeat = repeat ...
Set option parameter for noise sensor.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/sensor.py#L143-L154
pvizeli/ha-ffmpeg
haffmpeg/sensor.py
SensorMotion.open_sensor
def open_sensor( self, input_source: str, extra_cmd: Optional[str] = None ) -> Coroutine: """Open FFmpeg process a video stream for motion detection. Return a coroutine. """ command = [ "-an", "-filter:v", "select=gt(scene\\,{0})".format(s...
python
def open_sensor( self, input_source: str, extra_cmd: Optional[str] = None ) -> Coroutine: """Open FFmpeg process a video stream for motion detection. Return a coroutine. """ command = [ "-an", "-filter:v", "select=gt(scene\\,{0})".format(s...
Open FFmpeg process a video stream for motion detection. Return a coroutine.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/sensor.py#L156-L177
pvizeli/ha-ffmpeg
haffmpeg/sensor.py
SensorMotion._worker_process
async def _worker_process(self) -> None: """This function processing data.""" state = self.STATE_NONE timeout = None self._loop.call_soon(self._callback, False) # for repeat feature re_frame = 0 re_time = 0 re_data = re.compile(self.MATCH) # pr...
python
async def _worker_process(self) -> None: """This function processing data.""" state = self.STATE_NONE timeout = None self._loop.call_soon(self._callback, False) # for repeat feature re_frame = 0 re_time = 0 re_data = re.compile(self.MATCH) # pr...
This function processing data.
https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/sensor.py#L179-L249
andreasnuesslein/JayDeBeApi3
src/jaydebeapi/__init__.py
connect
def connect(jclassname, driver_args, jars=None, libs=None): """Open a connection to a database using a JDBC driver and return a Connection instance. jclassname: Full qualified Java class name of the JDBC driver. driver_args: Argument or sequence of arguments to be passed to the Java DriverMa...
python
def connect(jclassname, driver_args, jars=None, libs=None): """Open a connection to a database using a JDBC driver and return a Connection instance. jclassname: Full qualified Java class name of the JDBC driver. driver_args: Argument or sequence of arguments to be passed to the Java DriverMa...
Open a connection to a database using a JDBC driver and return a Connection instance. jclassname: Full qualified Java class name of the JDBC driver. driver_args: Argument or sequence of arguments to be passed to the Java DriverManager.getConnection method. Usually the database URL. Se...
https://github.com/andreasnuesslein/JayDeBeApi3/blob/1f9c38c6cc0535f01ec64c4fbdb4f1c6ebc17086/src/jaydebeapi/__init__.py#L32-L75
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.add_resource_subscription
def add_resource_subscription(self, device_id, _resource_path, **kwargs): # noqa: E501 """Subscribe to a resource path # noqa: E501 The Device Management Connect eventing model consists of observable resources. This means that endpoints can deliver updated resource content, periodically or with a mo...
python
def add_resource_subscription(self, device_id, _resource_path, **kwargs): # noqa: E501 """Subscribe to a resource path # noqa: E501 The Device Management Connect eventing model consists of observable resources. This means that endpoints can deliver updated resource content, periodically or with a mo...
Subscribe to a resource path # noqa: E501 The Device Management Connect eventing model consists of observable resources. This means that endpoints can deliver updated resource content, periodically or with a more sophisticated solution-dependent logic. The OMA LwM2M resource model including objects, object i...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L36-L57
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.check_resource_subscription
def check_resource_subscription(self, device_id, _resource_path, **kwargs): # noqa: E501 """Read subscription status # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.check_resourc...
python
def check_resource_subscription(self, device_id, _resource_path, **kwargs): # noqa: E501 """Read subscription status # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.check_resourc...
Read subscription status # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.check_resource_subscription(device_id, _resource_path, asynchronous=True) >>> result = thread.get() ...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L139-L159
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.delete_endpoint_subscriptions
def delete_endpoint_subscriptions(self, device_id, **kwargs): # noqa: E501 """Delete subscriptions from an endpoint # noqa: E501 Deletes all resource subscriptions in a single endpoint. **Example usage:** curl -X DELETE \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \...
python
def delete_endpoint_subscriptions(self, device_id, **kwargs): # noqa: E501 """Delete subscriptions from an endpoint # noqa: E501 Deletes all resource subscriptions in a single endpoint. **Example usage:** curl -X DELETE \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \...
Delete subscriptions from an endpoint # noqa: E501 Deletes all resource subscriptions in a single endpoint. **Example usage:** curl -X DELETE \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \\ -H 'authorization: Bearer {api-key}' # noqa: E501 This method makes a...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L236-L256
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.delete_pre_subscriptions
def delete_pre_subscriptions(self, **kwargs): # noqa: E501 """Remove pre-subscriptions # noqa: E501 Removes pre-subscriptions. **Example usage:** curl -X DELETE https://api.us-east-1.mbedcloud.com/v2/subscriptions -H 'authorization: Bearer {api-key}' # noqa: E501 This method makes a s...
python
def delete_pre_subscriptions(self, **kwargs): # noqa: E501 """Remove pre-subscriptions # noqa: E501 Removes pre-subscriptions. **Example usage:** curl -X DELETE https://api.us-east-1.mbedcloud.com/v2/subscriptions -H 'authorization: Bearer {api-key}' # noqa: E501 This method makes a s...
Remove pre-subscriptions # noqa: E501 Removes pre-subscriptions. **Example usage:** curl -X DELETE https://api.us-east-1.mbedcloud.com/v2/subscriptions -H 'authorization: Bearer {api-key}' # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTT...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L327-L346
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.delete_resource_subscription
def delete_resource_subscription(self, device_id, _resource_path, **kwargs): # noqa: E501 """Remove a subscription # noqa: E501 To remove an existing subscription from a resource path. **Example usage:** curl -X DELETE \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id}/{r...
python
def delete_resource_subscription(self, device_id, _resource_path, **kwargs): # noqa: E501 """Remove a subscription # noqa: E501 To remove an existing subscription from a resource path. **Example usage:** curl -X DELETE \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id}/{r...
Remove a subscription # noqa: E501 To remove an existing subscription from a resource path. **Example usage:** curl -X DELETE \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id}/{resourcePath} \\ -H 'authorization: Bearer {api-key}' # noqa: E501 This method makes a ...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L410-L431
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.get_endpoint_subscriptions
def get_endpoint_subscriptions(self, device_id, **kwargs): # noqa: E501 """Read endpoints subscriptions # noqa: E501 Lists all subscribed resources from a single endpoint. **Example usage:** curl -X GET \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \\ -H 'autho...
python
def get_endpoint_subscriptions(self, device_id, **kwargs): # noqa: E501 """Read endpoints subscriptions # noqa: E501 Lists all subscribed resources from a single endpoint. **Example usage:** curl -X GET \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \\ -H 'autho...
Read endpoints subscriptions # noqa: E501 Lists all subscribed resources from a single endpoint. **Example usage:** curl -X GET \\ https://api.us-east-1.mbedcloud.com/v2/subscriptions/{device-id} \\ -H 'authorization: Bearer {api-key}' # noqa: E501 This method makes a synchronous H...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L509-L529
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.get_pre_subscriptions
def get_pre_subscriptions(self, **kwargs): # noqa: E501 """Get pre-subscriptions # noqa: E501 You can retrieve the pre-subscription data with the GET operation. The server returns with the same JSON structure as described above. If there are no pre-subscribed resources, it returns with an empty array...
python
def get_pre_subscriptions(self, **kwargs): # noqa: E501 """Get pre-subscriptions # noqa: E501 You can retrieve the pre-subscription data with the GET operation. The server returns with the same JSON structure as described above. If there are no pre-subscribed resources, it returns with an empty array...
Get pre-subscriptions # noqa: E501 You can retrieve the pre-subscription data with the GET operation. The server returns with the same JSON structure as described above. If there are no pre-subscribed resources, it returns with an empty array. **Example usage:** curl -X GET https://api.us-east-1.mbedclo...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L604-L623
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/mds/apis/subscriptions_api.py
SubscriptionsApi.update_pre_subscriptions
def update_pre_subscriptions(self, presubsription, **kwargs): # noqa: E501 """Set pre-subscriptions # noqa: E501 Pre-subscription is a set of rules and patterns put by the application. When an endpoint registers and its ID, type and registered resources match the pre-subscription data, Device Managem...
python
def update_pre_subscriptions(self, presubsription, **kwargs): # noqa: E501 """Set pre-subscriptions # noqa: E501 Pre-subscription is a set of rules and patterns put by the application. When an endpoint registers and its ID, type and registered resources match the pre-subscription data, Device Managem...
Set pre-subscriptions # noqa: E501 Pre-subscription is a set of rules and patterns put by the application. When an endpoint registers and its ID, type and registered resources match the pre-subscription data, Device Management Connect sends subscription requests to the device automatically. The pattern may in...
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/mds/apis/subscriptions_api.py#L691-L711
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/bootstrap/bootstrap.py
BootstrapAPI.add_psk
def add_psk(self, **kwargs): """Add""" api = self._get_api(bootstrap.PreSharedKeysApi) item = PreSharedKey._create_request_map(kwargs) item = models.PreSharedKey(**item) api.upload_pre_shared_key(item) return PreSharedKey(item)
python
def add_psk(self, **kwargs): """Add""" api = self._get_api(bootstrap.PreSharedKeysApi) item = PreSharedKey._create_request_map(kwargs) item = models.PreSharedKey(**item) api.upload_pre_shared_key(item) return PreSharedKey(item)
Add
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/bootstrap/bootstrap.py#L44-L50
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/bootstrap/bootstrap.py
BootstrapAPI.get_psk
def get_psk(self, endpoint_name, **kwargs): """Get""" api = self._get_api(bootstrap.PreSharedKeysApi) return PreSharedKey(api.get_pre_shared_key(endpoint_name=endpoint_name))
python
def get_psk(self, endpoint_name, **kwargs): """Get""" api = self._get_api(bootstrap.PreSharedKeysApi) return PreSharedKey(api.get_pre_shared_key(endpoint_name=endpoint_name))
Get
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/bootstrap/bootstrap.py#L53-L56
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/bootstrap/bootstrap.py
BootstrapAPI.list_psks
def list_psks(self, **kwargs): """List""" api = self._get_api(bootstrap.PreSharedKeysApi) return PaginatedResponse(api.list_pre_shared_keys, lwrap_type=PreSharedKey, **kwargs)
python
def list_psks(self, **kwargs): """List""" api = self._get_api(bootstrap.PreSharedKeysApi) return PaginatedResponse(api.list_pre_shared_keys, lwrap_type=PreSharedKey, **kwargs)
List
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/bootstrap/bootstrap.py#L59-L62
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/bootstrap/bootstrap.py
BootstrapAPI.delete_psk
def delete_psk(self, endpoint_name, **kwargs): """Delete""" api = self._get_api(bootstrap.PreSharedKeysApi) return api.delete_pre_shared_key(endpoint_name=endpoint_name)
python
def delete_psk(self, endpoint_name, **kwargs): """Delete""" api = self._get_api(bootstrap.PreSharedKeysApi) return api.delete_pre_shared_key(endpoint_name=endpoint_name)
Delete
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/bootstrap/bootstrap.py#L65-L68
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data.py
DeviceData.ca_id
def ca_id(self, ca_id): """ Sets the ca_id of this DeviceData. The certificate issuer's ID. :param ca_id: The ca_id of this DeviceData. :type: str """ if ca_id is not None and len(ca_id) > 500: raise ValueError("Invalid value for `ca_id`, length must ...
python
def ca_id(self, ca_id): """ Sets the ca_id of this DeviceData. The certificate issuer's ID. :param ca_id: The ca_id of this DeviceData. :type: str """ if ca_id is not None and len(ca_id) > 500: raise ValueError("Invalid value for `ca_id`, length must ...
Sets the ca_id of this DeviceData. The certificate issuer's ID. :param ca_id: The ca_id of this DeviceData. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data.py#L246-L257
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data.py
DeviceData.deployed_state
def deployed_state(self, deployed_state): """ Sets the deployed_state of this DeviceData. DEPRECATED: The state of the device's deployment. :param deployed_state: The deployed_state of this DeviceData. :type: str """ allowed_values = ["development", "production"]...
python
def deployed_state(self, deployed_state): """ Sets the deployed_state of this DeviceData. DEPRECATED: The state of the device's deployment. :param deployed_state: The deployed_state of this DeviceData. :type: str """ allowed_values = ["development", "production"]...
Sets the deployed_state of this DeviceData. DEPRECATED: The state of the device's deployment. :param deployed_state: The deployed_state of this DeviceData. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data.py#L340-L355
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data.py
DeviceData.device_class
def device_class(self, device_class): """ Sets the device_class of this DeviceData. An ID representing the model and hardware revision of the device. :param device_class: The device_class of this DeviceData. :type: str """ if device_class is not None and len(devi...
python
def device_class(self, device_class): """ Sets the device_class of this DeviceData. An ID representing the model and hardware revision of the device. :param device_class: The device_class of this DeviceData. :type: str """ if device_class is not None and len(devi...
Sets the device_class of this DeviceData. An ID representing the model and hardware revision of the device. :param device_class: The device_class of this DeviceData. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data.py#L417-L428
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data.py
DeviceData.device_key
def device_key(self, device_key): """ Sets the device_key of this DeviceData. The fingerprint of the device certificate. :param device_key: The device_key of this DeviceData. :type: str """ if device_key is not None and len(device_key) > 512: raise Va...
python
def device_key(self, device_key): """ Sets the device_key of this DeviceData. The fingerprint of the device certificate. :param device_key: The device_key of this DeviceData. :type: str """ if device_key is not None and len(device_key) > 512: raise Va...
Sets the device_key of this DeviceData. The fingerprint of the device certificate. :param device_key: The device_key of this DeviceData. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data.py#L465-L476
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data.py
DeviceData.endpoint_type
def endpoint_type(self, endpoint_type): """ Sets the endpoint_type of this DeviceData. The endpoint type of the device. For example, the device is a gateway. :param endpoint_type: The endpoint_type of this DeviceData. :type: str """ if endpoint_type is not None a...
python
def endpoint_type(self, endpoint_type): """ Sets the endpoint_type of this DeviceData. The endpoint type of the device. For example, the device is a gateway. :param endpoint_type: The endpoint_type of this DeviceData. :type: str """ if endpoint_type is not None a...
Sets the endpoint_type of this DeviceData. The endpoint type of the device. For example, the device is a gateway. :param endpoint_type: The endpoint_type of this DeviceData. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data.py#L513-L524
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/models/device_data.py
DeviceData.mechanism
def mechanism(self, mechanism): """ Sets the mechanism of this DeviceData. The ID of the channel used to communicate with the device. :param mechanism: The mechanism of this DeviceData. :type: str """ allowed_values = ["connector", "direct"] if mechanism ...
python
def mechanism(self, mechanism): """ Sets the mechanism of this DeviceData. The ID of the channel used to communicate with the device. :param mechanism: The mechanism of this DeviceData. :type: str """ allowed_values = ["connector", "direct"] if mechanism ...
Sets the mechanism of this DeviceData. The ID of the channel used to communicate with the device. :param mechanism: The mechanism of this DeviceData. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/models/device_data.py#L722-L737
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
BaseAPI._update_api_client
def _update_api_client(self, api_parent_class=None): """Updates the ApiClient object of specified parent api (or all of them)""" clients = ([self.api_clients[api_parent_class]] if api_parent_class else self.api_clients.values()) for api_client in clients: api_clie...
python
def _update_api_client(self, api_parent_class=None): """Updates the ApiClient object of specified parent api (or all of them)""" clients = ([self.api_clients[api_parent_class]] if api_parent_class else self.api_clients.values()) for api_client in clients: api_clie...
Updates the ApiClient object of specified parent api (or all of them)
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L75-L83
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
BaseAPI._verify_filters
def _verify_filters(self, kwargs, obj, encode=False): """Legacy entrypoint with 'encode' flag""" return (filters.legacy_filter_formatter if encode else filters.filter_formatter)( kwargs, obj._get_attributes_map() )
python
def _verify_filters(self, kwargs, obj, encode=False): """Legacy entrypoint with 'encode' flag""" return (filters.legacy_filter_formatter if encode else filters.filter_formatter)( kwargs, obj._get_attributes_map() )
Legacy entrypoint with 'encode' flag
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L99-L104
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
BaseAPI.get_last_api_metadata
def get_last_api_metadata(self): """Get meta data for the last Mbed Cloud API call. :returns: meta data of the last Mbed Cloud API call :rtype: ApiMetadata """ last_metadata = None for key, api in iteritems(self.apis): api_client = api.api_client ...
python
def get_last_api_metadata(self): """Get meta data for the last Mbed Cloud API call. :returns: meta data of the last Mbed Cloud API call :rtype: ApiMetadata """ last_metadata = None for key, api in iteritems(self.apis): api_client = api.api_client ...
Get meta data for the last Mbed Cloud API call. :returns: meta data of the last Mbed Cloud API call :rtype: ApiMetadata
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L106-L128
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
StubAPI.success
def success(self, **kwargs): """Returns all arguments received in init and this method call""" response = {'success': True} # check dates can be manipulated response.update(kwargs) response.update(self.kwargs) response['test_argument3'] = datetime.timedelta(days=1) + resp...
python
def success(self, **kwargs): """Returns all arguments received in init and this method call""" response = {'success': True} # check dates can be manipulated response.update(kwargs) response.update(self.kwargs) response['test_argument3'] = datetime.timedelta(days=1) + resp...
Returns all arguments received in init and this method call
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L144-L151
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
BaseObject.update_attributes
def update_attributes(self, updates): """Update attributes.""" if not isinstance(updates, dict): updates = updates.to_dict() for sdk_key, spec_key in self._get_attributes_map().items(): attr = '_%s' % sdk_key if spec_key in updates and not hasattr(self, attr):...
python
def update_attributes(self, updates): """Update attributes.""" if not isinstance(updates, dict): updates = updates.to_dict() for sdk_key, spec_key in self._get_attributes_map().items(): attr = '_%s' % sdk_key if spec_key in updates and not hasattr(self, attr):...
Update attributes.
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L161-L168
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
BaseObject._create_request_map
def _create_request_map(cls, input_map): """Create request map.""" field_map = cls._get_attributes_map() return {field_map[k]: v for k, v in input_map.items() if k in field_map}
python
def _create_request_map(cls, input_map): """Create request map.""" field_map = cls._get_attributes_map() return {field_map[k]: v for k, v in input_map.items() if k in field_map}
Create request map.
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L176-L179
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
ApiMetadata.to_dict
def to_dict(self): """Return dictionary of object.""" dictionary = {} for key, value in iteritems(self.__dict__): property_name = key[1:] if hasattr(self, property_name): dictionary.update({property_name: getattr(self, property_name, None)}) return...
python
def to_dict(self): """Return dictionary of object.""" dictionary = {} for key, value in iteritems(self.__dict__): property_name = key[1:] if hasattr(self, property_name): dictionary.update({property_name: getattr(self, property_name, None)}) return...
Return dictionary of object.
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L348-L355
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/enrollment/models/bulk_response.py
BulkResponse.etag
def etag(self, etag): """ Sets the etag of this BulkResponse. etag :param etag: The etag of this BulkResponse. :type: str """ if etag is None: raise ValueError("Invalid value for `etag`, must not be `None`") if etag is not None and not re.sear...
python
def etag(self, etag): """ Sets the etag of this BulkResponse. etag :param etag: The etag of this BulkResponse. :type: str """ if etag is None: raise ValueError("Invalid value for `etag`, must not be `None`") if etag is not None and not re.sear...
Sets the etag of this BulkResponse. etag :param etag: The etag of this BulkResponse. :type: str
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/enrollment/models/bulk_response.py#L213-L226