function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_incompatible_higher_rank_inputs_raises(self, use_edges, use_receiver_nodes, use_sender_nodes, use_globals, ...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_incompatible_higher_rank_inputs_no_raise(self, use_edges, use_receiver_nodes, use_sender_nodes, use_glo...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_unused_field_can_be_none( self, use_edges, use_nodes, use_globals, none_field): """Checks that computation can handle non-necessary fields left None.""" input_graph = self._get_input_graph([none_field]) edge_block = blocks.EdgeBlock( edge_model_fn=self._edge_model_fn, use_edge...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def setUp(self): super(NodeBlockTest, self).setUp() self._scale = 10. self._node_model_fn = lambda: lambda features: features * self._scale
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_output_values( self, use_received_edges, use_sent_edges, use_nodes, use_globals, received_edges_reducer, sent_edges_reducer): """Compares the output of a NodeBlock to an explicit computation.""" input_graph = self._get_input_graph() node_block = blocks.NodeBlock( node_model_fn=s...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_created_variables(self, use_received_edges, use_sent_edges, use_nodes, use_globals, expected_first_dim_w): """Verifies the variable names and shapes created by a NodeBlock.""" output_size = 10 expected_var_shapes_dict = { "node_block...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_missing_field_raises_exception( self, use_received_edges, use_sent_edges, use_nodes, use_globals, none_fields): """Checks that missing a required field raises an exception.""" input_graph = self._get_input_graph(none_fields) node_block = blocks.NodeBlock( node_model_fn=self._nod...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_missing_aggregation_raises_exception( self, use_received_edges, use_sent_edges, received_edges_reducer, sent_edges_reducer): """Checks that missing a required aggregation argument raises an error.""" with self.assertRaisesRegexp(ValueError, "should not be None"): blocks.NodeBlock( ...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_incompatible_higher_rank_inputs_raises(self, use_received_edges, use_sent_edges, use_nodes, use_globals, ...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_incompatible_higher_rank_inputs_no_raise(self, use_received_edges, use_sent_edges, use_nodes, use_globa...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_unused_field_can_be_none( self, use_edges, use_nodes, use_globals, none_field): """Checks that computation can handle non-necessary fields left None.""" input_graph = self._get_input_graph([none_field]) node_block = blocks.NodeBlock( node_model_fn=self._node_model_fn, use_rece...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def setUp(self): super(GlobalBlockTest, self).setUp() self._scale = 10. self._global_model_fn = lambda: lambda features: features * self._scale
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_output_values( self, use_edges, use_nodes, use_globals, edges_reducer, nodes_reducer): """Compares the output of a GlobalBlock to an explicit computation.""" input_graph = self._get_input_graph() global_block = blocks.GlobalBlock( global_model_fn=self._global_model_fn, use_edg...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_created_variables(self, use_edges, use_nodes, use_globals, expected_first_dim_w): """Verifies the variable names and shapes created by a GlobalBlock.""" output_size = 10 expected_var_shapes_dict = { "global_block/mlp/linear_0/b:0": [output_size], "global...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_missing_field_raises_exception( self, use_edges, use_nodes, use_globals, none_field): """Checks that missing a required field raises an exception.""" input_graph = self._get_input_graph([none_field]) global_block = blocks.GlobalBlock( global_model_fn=self._global_model_fn, use...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_unused_field_can_be_none( self, use_edges, use_nodes, use_globals, none_field): """Checks that computation can handle non-necessary fields left None.""" input_graph = self._get_input_graph([none_field]) global_block = blocks.GlobalBlock( global_model_fn=self._global_model_fn, ...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_incompatible_higher_rank_inputs_raises(self, use_edges, use_nodes, use_globals, field): """A exception shou...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_incompatible_higher_rank_inputs_no_raise(self, use_edges, use_nodes, use_globals, field): """No exc...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_missing_aggregation_raises_exception( self, use_edges, use_nodes, edges_reducer, nodes_reducer): """Checks that missing a required aggregation argument raises an error.""" with self.assertRaisesRegexp(ValueError, "should not be None"): blocks.GlobalBlock( global_model_fn=sel...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_dynamic_batch_sizes(self, block_constructor): """Checks that all batch sizes are as expected through a GraphNetwork.""" input_graph = self._get_input_graph() placeholders = input_graph.map(_mask_leading_dimension, graphs.ALL_FIELDS) model = block_constructor( functools.partial(snt.nets....
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def test_dtypes(self, data_dtype, indices_dtype, block_constructor): """Checks that all the output types are as expected for blocks.""" input_graph = self._get_input_graph() input_graph = input_graph.map(lambda v: tf.cast(v, data_dtype), ["nodes", "edges", "globals"]) i...
deepmind/graph_nets
[ 5225, 778, 5225, 5, 1535703568 ]
def read_projects_to_test(workflows_path): with open(os.path.join(workflows_path, "projects_to_test.txt"), "r") as f: file_content = f.read() projects = file_content.splitlines() return projects
google/CFU-Playground
[ 357, 91, 357, 130, 1615325898 ]
def read_proj_excluded_targets(projects_path, proj_name): proj_path = os.path.join(projects_path, proj_name) try: with open(os.path.join(proj_path, "ci", "ci_exclude_targets.txt"), "r") as f: file_content = f.read() excluded_targets = file_content.splitlines() except IOError:...
google/CFU-Playground
[ 357, 91, 357, 130, 1615325898 ]
def get_proj_supported_targets(all_targets, excluded_targets): proj_targets = [x for x in all_targets if x not in excluded_targets] return proj_targets
google/CFU-Playground
[ 357, 91, 357, 130, 1615325898 ]
def list_to_json_str(final_list): json_str = json.dumps(final_list) return json_str
google/CFU-Playground
[ 357, 91, 357, 130, 1615325898 ]
def main(config="../../config.yaml", namespace=""): # obtain config if isinstance(config, str): config = load_job_config(config) parties = config.parties guest = parties.guest[0] host = parties.host[0] guest_train_data = {"name": "breast_hetero_guest", "namespace": f"experiment{namespac...
FederatedAI/FATE
[ 4887, 1449, 4887, 637, 1548325963 ]
def test_info_all(self): request = "statistics" nodes_info = self.as_connection.info_all(request) assert nodes_info is not None assert type(nodes_info) == dict
aerospike/aerospike-client-python
[ 122, 108, 122, 67, 1405113896 ]
def test_info_all_with_None_policy(self): request = "statistics" nodes_info = self.as_connection.info_all(request, None) assert nodes_info is not None assert type(nodes_info) == dict
aerospike/aerospike-client-python
[ 122, 108, 122, 67, 1405113896 ]
def test_positive_info_all(self, container_type, container_name): """ Test to see whether a namespace, set, and bin exist after a key is added """ key = ('test', 'demo', 'list_key') rec = {'names': ['John', 'Marlen', 'Steve']} self.as_connection.put(key, rec) ...
aerospike/aerospike-client-python
[ 122, 108, 122, 67, 1405113896 ]
def test_info_all_for_invalid_request(self): request = "fake_request_string_not_real" hosts = [host for host in self.connection_config['hosts']] nodes_info = self.as_connection.info_all(request) assert isinstance(nodes_info, dict) assert nodes_info.values() is not None
aerospike/aerospike-client-python
[ 122, 108, 122, 67, 1405113896 ]
def test_info_all_without_parameters(self): with pytest.raises(TypeError) as err_info: self.as_connection.info_all()
aerospike/aerospike-client-python
[ 122, 108, 122, 67, 1405113896 ]
def __init__(self): super(MidonetPluginV2, self).__init__() # Instantiate MidoNet API client conf = cfg.CONF.MIDONET neutron_extensions.append_api_extensions_path(extensions.__path__) self.api_cli = client.MidonetClient(conf.midonet_uri, conf.username, ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def repair_quotas_table(self): query = ("CREATE TABLE `quotas` ( `id` varchar(36) NOT NULL, " "`tenant_id` varchar(255) DEFAULT NULL, " "`resource` varchar(255) DEFAULT NULL, " "`limit` int(11) DEFAULT NULL, " "PRIMARY KEY (`id`) ) ENGINE=InnoD...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_network(self, context, network): """Create Neutron network. Create a new Neutron network and its corresponding MidoNet bridge. """ LOG.info(_('MidonetPluginV2.create_network called: network=%r'), network) net = self._process_create_network(context, n...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_network(self, context, id, network): """Update Neutron network. Update an existing Neutron network and its corresponding MidoNet bridge. """ LOG.info(_("MidonetPluginV2.update_network called: id=%(id)r, " "network=%(network)r"), {'id': id, 'network'...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_network(self, context, id): """Delete a network and its corresponding MidoNet bridge.""" LOG.info(_("MidonetPluginV2.delete_network called: id=%r"), id) with context.session.begin(subtransactions=True): self._process_l3_delete(context, id) super(MidonetPluginV...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_subnet(self, context, subnet): """Create Neutron subnet. Creates a Neutron subnet and a DHCP entry in MidoNet bridge. """ LOG.info(_("MidonetPluginV2.create_subnet called: subnet=%r"), subnet) sn_entry = super(MidonetPluginV2, self).create_subnet(context, subnet) ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_subnet(self, context, id): """Delete Neutron subnet. Delete neutron network and its corresponding MidoNet bridge. """ LOG.info(_("MidonetPluginV2.delete_subnet called: id=%s"), id) with context.session.begin(subtransactions=True): super(MidonetPluginV2, s...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_subnet(self, context, id, subnet): """Update the subnet with new info. """ LOG.info(_("MidonetPluginV2.update_subnet called: id=%s"), id) with context.session.begin(subtransactions=True): s = super(MidonetPluginV2, self).update_subnet(context, id, subnet) ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_port(self, context, port): """Create a L2 port in Neutron/MidoNet.""" LOG.info(_("MidonetPluginV2.create_port called: port=%r"), port) new_port = self._process_create_port(context, port) try: self.api_cli.create_port(new_port) except Exception as ex: ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_port(self, context, id, l3_port_check=True): """Delete a neutron port and corresponding MidoNet bridge port.""" LOG.info(_("MidonetPluginV2.delete_port called: id=%(id)s " "l3_port_check=%(l3_port_check)r"), {'id': id, 'l3_port_check': l3_port_check}) ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_port(self, context, id, port): """Handle port update, including security groups and fixed IPs.""" LOG.info(_("MidonetPluginV2.update_port called: id=%(id)s " "port=%(port)r"), {'id': id, 'port': port}) with context.session.begin(subtransactions=True): #...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_router(self, context, router): """Handle router creation. When a new Neutron router is created, its corresponding MidoNet router is also created. In MidoNet, this router is initialized with chains for inbound and outbound traffic, which will be used to hold other cha...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_router(self, context, id, router): """Handle router updates.""" LOG.info(_("MidonetPluginV2.update_router called: id=%(id)s " "router=%(router)r"), {"id": id, "router": router}) with context.session.begin(subtransactions=True): r = super(MidonetPluginV2...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_router(self, context, id): """Handler for router deletion. Deleting a router on Neutron simply means deleting its corresponding router in MidoNet. :param id: router ID to remove """ LOG.info(_("MidonetPluginV2.delete_router called: id=%s"), id) with ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def add_router_interface(self, context, router_id, interface_info): """Handle router linking with network.""" LOG.info(_("MidonetPluginV2.add_router_interface called: " "router_id=%(router_id)s " "interface_info=%(interface_info)r"), {'router_id': r...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def remove_router_interface(self, context, router_id, interface_info): """Handle router un-linking with network.""" LOG.info(_("MidonetPluginV2.remove_router_interface called: " "router_id=%(router_id)s " "interface_info=%(interface_info)r"), {'rout...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_floatingip(self, context, floatingip): """Handle floating IP creation.""" LOG.info(_("MidonetPluginV2.create_floatingip called: ip=%r"), floatingip) fip = super(MidonetPluginV2, self).create_floatingip(context, ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_floatingip(self, context, id): """Handle floating IP deletion.""" LOG.info(_("MidonetPluginV2.delete_floatingip called: id=%s"), id) with context.session.begin(subtransactions=True): super(MidonetPluginV2, self).delete_floatingip(context, id) self.api_cli.dele...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_floatingip(self, context, id, floatingip): """Handle floating IP association and disassociation.""" LOG.info(_("MidonetPluginV2.update_floatingip called: id=%(id)s " "floatingip=%(floatingip)s "), {'id': id, 'floatingip': floatingip}) with context....
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_security_group(self, context, security_group, default_sg=False): """Create security group. Create a new security group, including the default security group. In MidoNet, this means creating a pair of chains, inbound and outbound, as well as a new port group. """ ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_security_group(self, context, id): """Delete chains for Neutron security group.""" LOG.info(_("MidonetPluginV2.delete_security_group called: id=%s"), id) sg = super(MidonetPluginV2, self).get_security_group(context, id) if not sg: raise ext_sg.SecurityGroupNotFoun...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_security_group_rule(self, context, security_group_rule): """Create a security group rule Create a security group rule in the Neutron DB and corresponding MidoNet resources in its data store. """ LOG.info(_("MidonetPluginV2.create_security_group_rule called: " ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_security_group_rule_bulk(self, context, security_group_rules): """Create multiple security group rules Create multiple security group rules in the Neutron DB and corresponding MidoNet resources in its data store. """ LOG.info(_("MidonetPluginV2.create_security_group_r...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_security_group_rule(self, context, sg_rule_id): """Delete a security group rule Delete a security group rule from the Neutron DB and corresponding MidoNet resources from its data store. """ LOG.info(_("MidonetPluginV2.delete_security_group_rule called: " ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_vip(self, context, vip): LOG.debug("MidonetPluginV2.create_vip called: %(vip)r", {'vip': vip}) with context.session.begin(subtransactions=True): v = super(MidonetPluginV2, self).create_vip(context, vip) self.api_cli.create_vip(v) v['statu...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_vip(self, context, id): LOG.debug("MidonetPluginV2.delete_vip called: id=%(id)r", {'id': id}) with context.session.begin(subtransactions=True): super(MidonetPluginV2, self).delete_vip(context, id) self.api_cli.delete_vip(id) LOG.debug("Midon...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_vip(self, context, id, vip): LOG.debug("MidonetPluginV2.update_vip called: id=%(id)r, " "vip=%(vip)r", {'id': id, 'vip': vip}) with context.session.begin(subtransactions=True): v = super(MidonetPluginV2, self).update_vip(context, id, vip) self.api_cl...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_pool(self, context, pool): LOG.debug("MidonetPluginV2.create_pool called: %(pool)r", {'pool': pool}) router_id = pool['pool'].get(rsi.ROUTER_ID) if not router_id: msg = _("router_id is required for pool") raise n_exc.BadRequest(resource='rout...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_pool(self, context, id, pool): LOG.debug("MidonetPluginV2.update_pool called: id=%(id)r, " "pool=%(pool)r", {'id': id, 'pool': pool}) with context.session.begin(subtransactions=True): p = super(MidonetPluginV2, self).update_pool(context, id, pool) se...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_pool(self, context, id): LOG.debug("MidonetPluginV2.delete_pool called: %(id)r", {'id': id}) with context.session.begin(subtransactions=True): self._delete_resource_router_id_binding(context, id, loadbalancer_db.Pool) ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_member(self, context, member): LOG.debug("MidonetPluginV2.create_member called: %(member)r", {'member': member}) with context.session.begin(subtransactions=True): m = super(MidonetPluginV2, self).create_member(context, member) self.api_cli.create_mem...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_member(self, context, id, member): LOG.debug("MidonetPluginV2.update_member called: id=%(id)r, " "member=%(member)r", {'id': id, 'member': member}) with context.session.begin(subtransactions=True): m = super(MidonetPluginV2, self).update_member(context, id, memb...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_member(self, context, id): LOG.debug("MidonetPluginV2.delete_member called: %(id)r", {'id': id}) with context.session.begin(subtransactions=True): super(MidonetPluginV2, self).delete_member(context, id) self.api_cli.delete_member(id) LOG.deb...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_health_monitor(self, context, health_monitor): LOG.debug("MidonetPluginV2.create_health_monitor called: " " %(health_monitor)r", {'health_monitor': health_monitor}) with context.session.begin(subtransactions=True): hm = super(MidonetPluginV2, self).create_health...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def update_health_monitor(self, context, id, health_monitor): LOG.debug("MidonetPluginV2.update_health_monitor called: id=%(id)r, " "health_monitor=%(health_monitor)r", {'id': id, 'health_monitor': health_monitor}) with context.session.begin(subtransactions=True): ...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def delete_health_monitor(self, context, id): LOG.debug("MidonetPluginV2.delete_health_monitor called: %(id)r", {'id': id}) with context.session.begin(subtransactions=True): super(MidonetPluginV2, self).delete_health_monitor(context, id) self.api_cli.delete_hea...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def create_pool_health_monitor(self, context, health_monitor, pool_id): LOG.debug("MidonetPluginV2.create_pool_health_monitor called: " "hm=%(health_monitor)r, pool_id=%(pool_id)r", {'health_monitor': health_monitor, 'pool_id': pool_id}) pool = self.get_pool(context,...
midokura/python-neutron-plugin-midonet
[ 2, 3, 2, 1, 1408526215 ]
def _mobilenet_v2(net, depth_multiplier, output_stride, reuse=None, scope=None, final_endpoint=None): """Auxiliary function to add support for 'reuse' to mobilenet_v2. Args: net: Input tensor of shape [batch_size, height,...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def _preprocess_subtract_imagenet_mean(inputs): """Subtract Imagenet mean RGB value.""" mean_rgb = tf.reshape(_MEAN_RGB, [1, 1, 1, 3]) return inputs - mean_rgb
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def mean_pixel(model_variant=None): """Gets mean pixel value. This function returns different mean pixel value, depending on the input model_variant which adopts different preprocessing functions. We currently handle the following preprocessing functions: (1) _preprocess_subtract_imagenet_mean. We simply ret...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __virtual__(): """ Confirm this module is on a Debian-based system """ # If your minion is running an OS which is Debian-based but does not have # an "os_family" grain of Debian, then the proper fix is NOT to check for # the minion's "os_family" grain here in the __virtual__. The correct fix...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def __init__(self, line, file=None): self.invalid = False self.comps = [] self.disabled = False self.comment = "" self.dist = "" self.type = "" self.uri = "" self.line = line self.architectures = [] s...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _parse_sources(self, line): """ Parse lines from sources files """ self.disabled = False repo_line = self.line.strip().split() if not repo_line: self.invalid = True return False if repo_line[0].starts...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def __init__(self): self.list = [] self.files = [ pathlib.Path(os.sep, "etc", "apt", "sources.list"), pathlib.Path(os.sep, "etc", "apt", "sources.list.d"), ] for file in self.files: if file.is_dir(): for ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def add_file(self, file): """ Add the lines of a file to self.list """ if file.is_file(): with salt.utils.files.fopen(file) as source: for line in source: self.list.append(SourceEntry(line, file=str(file))) ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def remove(self, source): """ remove a source from the list of sources """ self.list.remove(source)
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _get_ppa_info_from_launchpad(owner_name, ppa_name): """ Idea from softwareproperties.ppa. Uses urllib2 which sacrifices server cert verification. This is used as fall-back code or for secure PPAs :param owner_name: :param ppa_name: :return: """ lp_url = "https://launchpad.net/...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _call_apt(args, scope=True, **kwargs): """ Call apt* utilities. """ cmd = [] if ( scope and salt.utils.systemd.has_scope(__context__) and __salt__["config.get"]("systemd.scope", True) ): cmd.extend(["systemd-run", "--scope", "--description", '"{}"'.format(__na...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def normalize_name(name): """ Strips the architecture from the specified package name, if necessary. CLI Example: .. code-block:: bash salt '*' pkg.normalize_name zsh:amd64 """ try: pkgname, pkgarch = name.rsplit(PKG_ARCH_SEPARATOR, 1) except ValueError: pkgname = ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def latest_version(*names, **kwargs): """ Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of name/version pairs is returned. If the latest version of a given package is already installed, an empty string wi...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def version(*names, **kwargs): """ Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned. CLI Example: .. code-block:: bash salt '*' pkg.version <package name> ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def install( name=None, refresh=False, fromrepo=None, skip_verify=False, debconf=None, pkgs=None, sources=None, reinstall=False, downloadonly=False, ignore_epoch=False, **kwargs
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _uninstall(action="remove", name=None, pkgs=None, **kwargs): """ remove and purge do identical things but with different apt-get commands, this function performs the common logic. """ try: pkg_params = __salt__["pkg_resource.parse_targets"](name, pkgs)[0] except MinionError as exc: ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def remove(name=None, pkgs=None, **kwargs): """ .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. This is done to keep system...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def upgrade(refresh=True, dist_upgrade=False, **kwargs): """ .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. This is done t...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def unhold(name=None, pkgs=None, sources=None, **kwargs): # pylint: disable=W0613 """ .. versionadded:: 2014.7.0 Set package current in 'hold' state to install state, meaning it will be upgraded. name The name of the package, e.g., 'tmux' CLI Example: .. code-block:: bas...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def list_pkgs( versions_as_list=False, removed=False, purge_desired=False, **kwargs
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _get_upgradable(dist_upgrade=True, **kwargs): """ Utility function to get upgradable packages Sample return data: { 'pkgname': '1.2.3-45', ... } """ cmd = ["apt-get", "--just-print"] if dist_upgrade: cmd.append("dist-upgrade") else: cmd.append("upgrade") try: ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def upgrade_available(name, **kwargs): """ Check whether or not an upgrade is available for a given package CLI Example: .. code-block:: bash salt '*' pkg.upgrade_available <package name> """ return latest_version(name) != ""
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _split_repo_str(repo): """ Return APT source entry as a tuple. """ split = SourceEntry(repo) return split.type, split.architectures, split.uri, split.dist, split.comps
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def list_repo_pkgs(*args, **kwargs): # pylint: disable=unused-import """ .. versionadded:: 2017.7.0 Returns all available packages. Optionally, package names (and name globs) can be passed and the results will be filtered to packages matching those names. This function can be helpful in disco...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def list_repos(**kwargs): """ Lists all repos in the sources.list (and sources.lists.d) files CLI Example: .. code-block:: bash salt '*' pkg.list_repos salt '*' pkg.list_repos disabled=True """ repos = {} sources = SourcesList() for source in sources.list: if _sk...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def del_repo(repo, **kwargs): """ Delete a repo from the sources.list / sources.list.d If the .list file is in the sources.list.d directory and the file that the repo exists in does not contain any other repo configuration, the file itself will be deleted. The repo passed in must be a fully fo...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def get_repo_keys(): """ .. versionadded:: 2017.7.0 List known repo key details. :return: A dictionary containing the repo keys. :rtype: dict CLI Examples: .. code-block:: bash salt '*' pkg.get_repo_keys """ ret = dict() repo_keys = list() # The double usage of ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def del_repo_key(name=None, **kwargs): """ .. versionadded:: 2015.8.0 Remove a repo key using ``apt-key del`` name Repo from which to remove the key. Unnecessary if ``keyid`` is passed. keyid The KeyID of the GPG key to remove keyid_ppa : False If set to ``True``, the...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def file_list(*packages, **kwargs): """ List the files that belong to a package. Not specifying any packages will return a list of _every_ file on the system's package database (not generally recommended). CLI Examples: .. code-block:: bash salt '*' pkg.file_list httpd salt '*...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def expand_repo_def(**kwargs): """ Take a repository definition and expand it to the full pkg repository dict that can be used for comparison. This is a helper function to make the Debian/Ubuntu apt sources sane for comparison in the pkgrepo states. This is designed to be called from pkgrepo state...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def get_selections(pattern=None, state=None): """ View package state from the dpkg database. Returns a dict of dicts containing the state, and package names: .. code-block:: python {'<host>': {'<state>': ['pkg1', ... ] }...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def set_selections(path=None, selection=None, clear=False, saltenv="base"): """ Change package state in the dpkg database. The state can be any one of, documented in ``dpkg(1)``: - install - hold - deinstall - purge This command is commonly used to mark specific packages to be held fr...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]