repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_dcnm_in_nwk
def delete_dcnm_in_nwk(self, tenant_id, fw_dict, is_fw_virt=False): """Delete the DCNM In Network and store the result in DB. """ tenant_name = fw_dict.get('tenant_name') ret = self._delete_service_nwk(tenant_id, tenant_name, 'in') if ret: res = fw_const.DCNM_IN_NETWORK_DEL_S...
python
def delete_dcnm_in_nwk(self, tenant_id, fw_dict, is_fw_virt=False): """Delete the DCNM In Network and store the result in DB. """ tenant_name = fw_dict.get('tenant_name') ret = self._delete_service_nwk(tenant_id, tenant_name, 'in') if ret: res = fw_const.DCNM_IN_NETWORK_DEL_S...
[ "def", "delete_dcnm_in_nwk", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "=", "self", ".", "_delete_service_nwk", "(", "tenant_id", ","...
Delete the DCNM In Network and store the result in DB.
[ "Delete", "the", "DCNM", "In", "Network", "and", "store", "the", "result", "in", "DB", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1304-L1317
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.update_dcnm_in_part
def update_dcnm_in_part(self, tenant_id, fw_dict, is_fw_virt=False): """Update DCNM's in partition information. Update the In partition service node IP address in DCNM and update the result """ res = fw_const.DCNM_IN_PART_UPDATE_SUCCESS tenant_name = fw_dict.get('tenant_...
python
def update_dcnm_in_part(self, tenant_id, fw_dict, is_fw_virt=False): """Update DCNM's in partition information. Update the In partition service node IP address in DCNM and update the result """ res = fw_const.DCNM_IN_PART_UPDATE_SUCCESS tenant_name = fw_dict.get('tenant_...
[ "def", "update_dcnm_in_part", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "res", "=", "fw_const", ".", "DCNM_IN_PART_UPDATE_SUCCESS", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "="...
Update DCNM's in partition information. Update the In partition service node IP address in DCNM and update the result
[ "Update", "DCNM", "s", "in", "partition", "information", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1319-L1338
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.clear_dcnm_in_part
def clear_dcnm_in_part(self, tenant_id, fw_dict, is_fw_virt=False): """Clear the DCNM in partition service information. Clear the In partition service node IP address in DCNM and update the result. """ res = fw_const.DCNM_IN_PART_UPDDEL_SUCCESS tenant_name = fw_dict.get(...
python
def clear_dcnm_in_part(self, tenant_id, fw_dict, is_fw_virt=False): """Clear the DCNM in partition service information. Clear the In partition service node IP address in DCNM and update the result. """ res = fw_const.DCNM_IN_PART_UPDDEL_SUCCESS tenant_name = fw_dict.get(...
[ "def", "clear_dcnm_in_part", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "res", "=", "fw_const", ".", "DCNM_IN_PART_UPDDEL_SUCCESS", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "=",...
Clear the DCNM in partition service information. Clear the In partition service node IP address in DCNM and update the result.
[ "Clear", "the", "DCNM", "in", "partition", "service", "information", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1340-L1359
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.create_dcnm_out_part
def create_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Create the DCNM OUT partition and update the result. """ res = fw_const.DCNM_OUT_PART_CREATE_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: self._create_out_partition(tenant_id,...
python
def create_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Create the DCNM OUT partition and update the result. """ res = fw_const.DCNM_OUT_PART_CREATE_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: self._create_out_partition(tenant_id,...
[ "def", "create_dcnm_out_part", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "res", "=", "fw_const", ".", "DCNM_OUT_PART_CREATE_SUCCESS", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "...
Create the DCNM OUT partition and update the result.
[ "Create", "the", "DCNM", "OUT", "partition", "and", "update", "the", "result", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1361-L1376
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_dcnm_out_part
def delete_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Delete the DCNM OUT partition and update the result. """ res = fw_const.DCNM_OUT_PART_DEL_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: self._delete_partition(tenant_id, tenant...
python
def delete_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Delete the DCNM OUT partition and update the result. """ res = fw_const.DCNM_OUT_PART_DEL_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: self._delete_partition(tenant_id, tenant...
[ "def", "delete_dcnm_out_part", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "res", "=", "fw_const", ".", "DCNM_OUT_PART_DEL_SUCCESS", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "=",...
Delete the DCNM OUT partition and update the result.
[ "Delete", "the", "DCNM", "OUT", "partition", "and", "update", "the", "result", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1378-L1393
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.create_dcnm_out_nwk
def create_dcnm_out_nwk(self, tenant_id, fw_dict, is_fw_virt=False): """Create the DCNM OUT Network and update the result. """ tenant_name = fw_dict.get('tenant_name') ret = self._create_service_nwk(tenant_id, tenant_name, 'out') if ret: res = fw_const.DCNM_OUT_NETWORK_CREATE...
python
def create_dcnm_out_nwk(self, tenant_id, fw_dict, is_fw_virt=False): """Create the DCNM OUT Network and update the result. """ tenant_name = fw_dict.get('tenant_name') ret = self._create_service_nwk(tenant_id, tenant_name, 'out') if ret: res = fw_const.DCNM_OUT_NETWORK_CREATE...
[ "def", "create_dcnm_out_nwk", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "=", "self", ".", "_create_service_nwk", "(", "tenant_id", ",...
Create the DCNM OUT Network and update the result.
[ "Create", "the", "DCNM", "OUT", "Network", "and", "update", "the", "result", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1395-L1408
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_dcnm_out_nwk
def delete_dcnm_out_nwk(self, tenant_id, fw_dict, is_fw_virt=False): """Delete the DCNM OUT network and update the result. """ tenant_name = fw_dict.get('tenant_name') ret = self._delete_service_nwk(tenant_id, tenant_name, 'out') if ret: res = fw_const.DCNM_OUT_NETWORK_DEL_SU...
python
def delete_dcnm_out_nwk(self, tenant_id, fw_dict, is_fw_virt=False): """Delete the DCNM OUT network and update the result. """ tenant_name = fw_dict.get('tenant_name') ret = self._delete_service_nwk(tenant_id, tenant_name, 'out') if ret: res = fw_const.DCNM_OUT_NETWORK_DEL_SU...
[ "def", "delete_dcnm_out_nwk", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "=", "self", ".", "_delete_service_nwk", "(", "tenant_id", ",...
Delete the DCNM OUT network and update the result.
[ "Delete", "the", "DCNM", "OUT", "network", "and", "update", "the", "result", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1410-L1423
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.update_dcnm_out_part
def update_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Update DCNM OUT partition service node IP address and result. """ res = fw_const.DCNM_OUT_PART_UPDATE_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: ret = self._update_partition...
python
def update_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Update DCNM OUT partition service node IP address and result. """ res = fw_const.DCNM_OUT_PART_UPDATE_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: ret = self._update_partition...
[ "def", "update_dcnm_out_part", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "res", "=", "fw_const", ".", "DCNM_OUT_PART_UPDATE_SUCCESS", "tenant_name", "=", "fw_dict", ".", "get", "(", "'tenant_name'", ")", "ret", "...
Update DCNM OUT partition service node IP address and result.
[ "Update", "DCNM", "OUT", "partition", "service", "node", "IP", "address", "and", "result", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1425-L1442
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.clear_dcnm_out_part
def clear_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Clear DCNM out partition information. Clear the DCNM OUT partition service node IP address and update the result """ res = fw_const.DCNM_OUT_PART_UPDDEL_SUCCESS self.update_fw_db_result(tenant_id, dc...
python
def clear_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): """Clear DCNM out partition information. Clear the DCNM OUT partition service node IP address and update the result """ res = fw_const.DCNM_OUT_PART_UPDDEL_SUCCESS self.update_fw_db_result(tenant_id, dc...
[ "def", "clear_dcnm_out_part", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", "=", "False", ")", ":", "res", "=", "fw_const", ".", "DCNM_OUT_PART_UPDDEL_SUCCESS", "self", ".", "update_fw_db_result", "(", "tenant_id", ",", "dcnm_status", "=", "r...
Clear DCNM out partition information. Clear the DCNM OUT partition service node IP address and update the result
[ "Clear", "DCNM", "out", "partition", "information", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1444-L1453
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.get_next_create_state
def get_next_create_state(self, state, ret): """Return the next create state from previous state. """ if ret: if state == fw_const.FABRIC_PREPARE_DONE_STATE: return state else: return state + 1 else: return state
python
def get_next_create_state(self, state, ret): """Return the next create state from previous state. """ if ret: if state == fw_const.FABRIC_PREPARE_DONE_STATE: return state else: return state + 1 else: return state
[ "def", "get_next_create_state", "(", "self", ",", "state", ",", "ret", ")", ":", "if", "ret", ":", "if", "state", "==", "fw_const", ".", "FABRIC_PREPARE_DONE_STATE", ":", "return", "state", "else", ":", "return", "state", "+", "1", "else", ":", "return", ...
Return the next create state from previous state.
[ "Return", "the", "next", "create", "state", "from", "previous", "state", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1463-L1471
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.get_next_del_state
def get_next_del_state(self, state, ret): """Return the next delete state from previous state. """ if ret: if state == fw_const.INIT_STATE: return state else: return state - 1 else: return state
python
def get_next_del_state(self, state, ret): """Return the next delete state from previous state. """ if ret: if state == fw_const.INIT_STATE: return state else: return state - 1 else: return state
[ "def", "get_next_del_state", "(", "self", ",", "state", ",", "ret", ")", ":", "if", "ret", ":", "if", "state", "==", "fw_const", ".", "INIT_STATE", ":", "return", "state", "else", ":", "return", "state", "-", "1", "else", ":", "return", "state" ]
Return the next delete state from previous state.
[ "Return", "the", "next", "delete", "state", "from", "previous", "state", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1473-L1481
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.get_next_state
def get_next_state(self, state, ret, oper): """Returns the next state for a create or delete operation. """ if oper == fw_const.FW_CR_OP: return self.get_next_create_state(state, ret) else: return self.get_next_del_state(state, ret)
python
def get_next_state(self, state, ret, oper): """Returns the next state for a create or delete operation. """ if oper == fw_const.FW_CR_OP: return self.get_next_create_state(state, ret) else: return self.get_next_del_state(state, ret)
[ "def", "get_next_state", "(", "self", ",", "state", ",", "ret", ",", "oper", ")", ":", "if", "oper", "==", "fw_const", ".", "FW_CR_OP", ":", "return", "self", ".", "get_next_create_state", "(", "state", ",", "ret", ")", "else", ":", "return", "self", "...
Returns the next state for a create or delete operation.
[ "Returns", "the", "next", "state", "for", "a", "create", "or", "delete", "operation", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1483-L1488
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.run_create_sm
def run_create_sm(self, tenant_id, fw_dict, is_fw_virt): """Runs the create State Machine. Goes through every state function until the end or when one state returns failure. """ ret = True serv_obj = self.get_service_obj(tenant_id) state = serv_obj.get_state() ...
python
def run_create_sm(self, tenant_id, fw_dict, is_fw_virt): """Runs the create State Machine. Goes through every state function until the end or when one state returns failure. """ ret = True serv_obj = self.get_service_obj(tenant_id) state = serv_obj.get_state() ...
[ "def", "run_create_sm", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ")", ":", "ret", "=", "True", "serv_obj", "=", "self", ".", "get_service_obj", "(", "tenant_id", ")", "state", "=", "serv_obj", ".", "get_state", "(", ")", "new_state...
Runs the create State Machine. Goes through every state function until the end or when one state returns failure.
[ "Runs", "the", "create", "State", "Machine", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1490-L1523
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.run_delete_sm
def run_delete_sm(self, tenant_id, fw_dict, is_fw_virt): """Runs the delete State Machine. Goes through every state function until the end or when one state returns failure. """ # Read the current state from the DB ret = True serv_obj = self.get_service_obj(tenan...
python
def run_delete_sm(self, tenant_id, fw_dict, is_fw_virt): """Runs the delete State Machine. Goes through every state function until the end or when one state returns failure. """ # Read the current state from the DB ret = True serv_obj = self.get_service_obj(tenan...
[ "def", "run_delete_sm", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ")", ":", "ret", "=", "True", "serv_obj", "=", "self", ".", "get_service_obj", "(", "tenant_id", ")", "state", "=", "serv_obj", ".", "get_state", "(", ")", "new_state...
Runs the delete State Machine. Goes through every state function until the end or when one state returns failure.
[ "Runs", "the", "delete", "State", "Machine", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1525-L1557
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.get_key_state
def get_key_state(self, status, state_dict): """Returns the key associated with the dict. """ for key, val in state_dict.items(): if val == status: return key
python
def get_key_state(self, status, state_dict): """Returns the key associated with the dict. """ for key, val in state_dict.items(): if val == status: return key
[ "def", "get_key_state", "(", "self", ",", "status", ",", "state_dict", ")", ":", "for", "key", ",", "val", "in", "state_dict", ".", "items", "(", ")", ":", "if", "val", "==", "status", ":", "return", "key" ]
Returns the key associated with the dict.
[ "Returns", "the", "key", "associated", "with", "the", "dict", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1559-L1563
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.pop_fw_state
def pop_fw_state(self, compl_result, os_status, dcnm_status): """Populate the state information in the cache. Check if state information is embedded in result If not: a. It's still in Init state and no SM is called yet b. The SM has completely run c. Delete has started a...
python
def pop_fw_state(self, compl_result, os_status, dcnm_status): """Populate the state information in the cache. Check if state information is embedded in result If not: a. It's still in Init state and no SM is called yet b. The SM has completely run c. Delete has started a...
[ "def", "pop_fw_state", "(", "self", ",", "compl_result", ",", "os_status", ",", "dcnm_status", ")", ":", "res_list", "=", "compl_result", ".", "split", "(", "'('", ")", "state_num", "=", "None", "if", "len", "(", "res_list", ")", ">", "1", ":", "state_nu...
Populate the state information in the cache. Check if state information is embedded in result If not: a. It's still in Init state and no SM is called yet b. The SM has completely run c. Delete has started and before any SM is run, it restarted.
[ "Populate", "the", "state", "information", "in", "the", "cache", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1565-L1588
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.pop_fw_local
def pop_fw_local(self, tenant_id, net_id, direc, node_ip): """Populate the local cache. Read the Network DB and populate the local cache. Read the subnet from the Subnet DB, given the net_id and populate the cache. """ net = self.get_network(net_id) serv_obj = se...
python
def pop_fw_local(self, tenant_id, net_id, direc, node_ip): """Populate the local cache. Read the Network DB and populate the local cache. Read the subnet from the Subnet DB, given the net_id and populate the cache. """ net = self.get_network(net_id) serv_obj = se...
[ "def", "pop_fw_local", "(", "self", ",", "tenant_id", ",", "net_id", ",", "direc", ",", "node_ip", ")", ":", "net", "=", "self", ".", "get_network", "(", "net_id", ")", "serv_obj", "=", "self", ".", "get_service_obj", "(", "tenant_id", ")", "serv_obj", "...
Populate the local cache. Read the Network DB and populate the local cache. Read the subnet from the Subnet DB, given the net_id and populate the cache.
[ "Populate", "the", "local", "cache", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1590-L1614
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.populate_local_cache_tenant
def populate_local_cache_tenant(self, fw_id, fw_data): """Populate the cache for a given tenant. Calls routines to Populate the in and out information. Update the result information. Populate the state information. Populate the router information. """ tenant_id =...
python
def populate_local_cache_tenant(self, fw_id, fw_data): """Populate the cache for a given tenant. Calls routines to Populate the in and out information. Update the result information. Populate the state information. Populate the router information. """ tenant_id =...
[ "def", "populate_local_cache_tenant", "(", "self", ",", "fw_id", ",", "fw_data", ")", ":", "tenant_id", "=", "fw_data", ".", "get", "(", "'tenant_id'", ")", "self", ".", "create_serv_obj", "(", "tenant_id", ")", "serv_obj", "=", "self", ".", "get_service_obj",...
Populate the cache for a given tenant. Calls routines to Populate the in and out information. Update the result information. Populate the state information. Populate the router information.
[ "Populate", "the", "cache", "for", "a", "given", "tenant", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1617-L1655
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.populate_local_cache
def populate_local_cache(self): """Populate the local cache from DB. Read the entries from FW DB and Calls routines to populate the cache. """ fw_dict = self.get_all_fw_db() for fw_id in fw_dict: LOG.info("Populating cache for FW %s", fw_id) fw_data = fw_...
python
def populate_local_cache(self): """Populate the local cache from DB. Read the entries from FW DB and Calls routines to populate the cache. """ fw_dict = self.get_all_fw_db() for fw_id in fw_dict: LOG.info("Populating cache for FW %s", fw_id) fw_data = fw_...
[ "def", "populate_local_cache", "(", "self", ")", ":", "fw_dict", "=", "self", ".", "get_all_fw_db", "(", ")", "for", "fw_id", "in", "fw_dict", ":", "LOG", ".", "info", "(", "\"Populating cache for FW %s\"", ",", "fw_id", ")", "fw_data", "=", "fw_dict", "[", ...
Populate the local cache from DB. Read the entries from FW DB and Calls routines to populate the cache.
[ "Populate", "the", "local", "cache", "from", "DB", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1657-L1666
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_os_dummy_rtr_nwk
def delete_os_dummy_rtr_nwk(self, rtr_id, net_id, subnet_id): """Delete the dummy interface to the router. """ subnet_lst = set() subnet_lst.add(subnet_id) ret = self.os_helper.delete_intf_router(None, None, rtr_id, subnet_lst) if not ret: return ret return s...
python
def delete_os_dummy_rtr_nwk(self, rtr_id, net_id, subnet_id): """Delete the dummy interface to the router. """ subnet_lst = set() subnet_lst.add(subnet_id) ret = self.os_helper.delete_intf_router(None, None, rtr_id, subnet_lst) if not ret: return ret return s...
[ "def", "delete_os_dummy_rtr_nwk", "(", "self", ",", "rtr_id", ",", "net_id", ",", "subnet_id", ")", ":", "subnet_lst", "=", "set", "(", ")", "subnet_lst", ".", "add", "(", "subnet_id", ")", "ret", "=", "self", ".", "os_helper", ".", "delete_intf_router", "...
Delete the dummy interface to the router.
[ "Delete", "the", "dummy", "interface", "to", "the", "router", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1668-L1675
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_os_nwk_db
def delete_os_nwk_db(self, net_id, seg, vlan): """Delete the Openstack Network from the database. Release the segmentation ID, VLAN associated with the net. Delete the network given the partial name. Delete the entry from Network DB, given the net ID. Delete the entry from Firew...
python
def delete_os_nwk_db(self, net_id, seg, vlan): """Delete the Openstack Network from the database. Release the segmentation ID, VLAN associated with the net. Delete the network given the partial name. Delete the entry from Network DB, given the net ID. Delete the entry from Firew...
[ "def", "delete_os_nwk_db", "(", "self", ",", "net_id", ",", "seg", ",", "vlan", ")", ":", "if", "seg", "is", "not", "None", ":", "self", ".", "service_segs", ".", "release_segmentation_id", "(", "seg", ")", "if", "vlan", "is", "not", "None", ":", "self...
Delete the Openstack Network from the database. Release the segmentation ID, VLAN associated with the net. Delete the network given the partial name. Delete the entry from Network DB, given the net ID. Delete the entry from Firewall DB, given the net ID. Release the IN/OUT sug=b...
[ "Delete", "the", "Openstack", "Network", "from", "the", "database", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1677-L1699
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.correct_db_restart
def correct_db_restart(self): """Ensure DB is consistent after unexpected restarts. """ LOG.info("Checking consistency of DB") # Any Segments allocated that's not in Network or FW DB, release it seg_netid_dict = self.service_segs.get_seg_netid_src(fw_const.FW_CONST) vlan_netid_di...
python
def correct_db_restart(self): """Ensure DB is consistent after unexpected restarts. """ LOG.info("Checking consistency of DB") # Any Segments allocated that's not in Network or FW DB, release it seg_netid_dict = self.service_segs.get_seg_netid_src(fw_const.FW_CONST) vlan_netid_di...
[ "def", "correct_db_restart", "(", "self", ")", ":", "LOG", ".", "info", "(", "\"Checking consistency of DB\"", ")", "seg_netid_dict", "=", "self", ".", "service_segs", ".", "get_seg_netid_src", "(", "fw_const", ".", "FW_CONST", ")", "vlan_netid_dict", "=", "self",...
Ensure DB is consistent after unexpected restarts.
[ "Ensure", "DB", "is", "consistent", "after", "unexpected", "restarts", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1702-L1793
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase._prepare_fabric_fw_internal
def _prepare_fabric_fw_internal(self, tenant_id, fw_dict, is_fw_virt, result): """Internal routine to prepare the fabric. This creates an entry in FW DB and runs the SM. """ if not self.auto_nwk_create: LOG.info("Auto network creation disa...
python
def _prepare_fabric_fw_internal(self, tenant_id, fw_dict, is_fw_virt, result): """Internal routine to prepare the fabric. This creates an entry in FW DB and runs the SM. """ if not self.auto_nwk_create: LOG.info("Auto network creation disa...
[ "def", "_prepare_fabric_fw_internal", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ",", "result", ")", ":", "if", "not", "self", ".", "auto_nwk_create", ":", "LOG", ".", "info", "(", "\"Auto network creation disabled\"", ")", "return", "Fals...
Internal routine to prepare the fabric. This creates an entry in FW DB and runs the SM.
[ "Internal", "routine", "to", "prepare", "the", "fabric", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1799-L1837
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.prepare_fabric_fw
def prepare_fabric_fw(self, tenant_id, fw_dict, is_fw_virt, result): """Top level routine to prepare the fabric. """ try: with self.mutex_lock: ret = self._prepare_fabric_fw_internal(tenant_id, fw_dict, is_fw_virt, result...
python
def prepare_fabric_fw(self, tenant_id, fw_dict, is_fw_virt, result): """Top level routine to prepare the fabric. """ try: with self.mutex_lock: ret = self._prepare_fabric_fw_internal(tenant_id, fw_dict, is_fw_virt, result...
[ "def", "prepare_fabric_fw", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ",", "result", ")", ":", "try", ":", "with", "self", ".", "mutex_lock", ":", "ret", "=", "self", ".", "_prepare_fabric_fw_internal", "(", "tenant_id", ",", "fw_dict...
Top level routine to prepare the fabric.
[ "Top", "level", "routine", "to", "prepare", "the", "fabric", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1839-L1848
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_fabric_fw_internal
def delete_fabric_fw_internal(self, tenant_id, fw_dict, is_fw_virt, result): """Internal routine to delete the fabric configuration. This runs the SM and deletes the entries from DB and local cache. """ if not self.auto_nwk_create: LOG.info(...
python
def delete_fabric_fw_internal(self, tenant_id, fw_dict, is_fw_virt, result): """Internal routine to delete the fabric configuration. This runs the SM and deletes the entries from DB and local cache. """ if not self.auto_nwk_create: LOG.info(...
[ "def", "delete_fabric_fw_internal", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ",", "result", ")", ":", "if", "not", "self", ".", "auto_nwk_create", ":", "LOG", ".", "info", "(", "\"Auto network creation disabled\"", ")", "return", "False"...
Internal routine to delete the fabric configuration. This runs the SM and deletes the entries from DB and local cache.
[ "Internal", "routine", "to", "delete", "the", "fabric", "configuration", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1850-L1893
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.delete_fabric_fw
def delete_fabric_fw(self, tenant_id, fw_dict, is_fw_virt, result): """Top level routine to unconfigure the fabric. """ try: with self.mutex_lock: ret = self.delete_fabric_fw_internal(tenant_id, fw_dict, is_fw_virt, result)...
python
def delete_fabric_fw(self, tenant_id, fw_dict, is_fw_virt, result): """Top level routine to unconfigure the fabric. """ try: with self.mutex_lock: ret = self.delete_fabric_fw_internal(tenant_id, fw_dict, is_fw_virt, result)...
[ "def", "delete_fabric_fw", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ",", "result", ")", ":", "try", ":", "with", "self", ".", "mutex_lock", ":", "ret", "=", "self", ".", "delete_fabric_fw_internal", "(", "tenant_id", ",", "fw_dict", ...
Top level routine to unconfigure the fabric.
[ "Top", "level", "routine", "to", "unconfigure", "the", "fabric", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1895-L1904
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.retry_failure_internal
def retry_failure_internal(self, tenant_id, tenant_name, fw_data, is_fw_virt, result): """Internal routine to retry the failed cases. """ if not self.auto_nwk_create: LOG.info("Auto network creation disabled") return False try: #...
python
def retry_failure_internal(self, tenant_id, tenant_name, fw_data, is_fw_virt, result): """Internal routine to retry the failed cases. """ if not self.auto_nwk_create: LOG.info("Auto network creation disabled") return False try: #...
[ "def", "retry_failure_internal", "(", "self", ",", "tenant_id", ",", "tenant_name", ",", "fw_data", ",", "is_fw_virt", ",", "result", ")", ":", "if", "not", "self", ".", "auto_nwk_create", ":", "LOG", ".", "info", "(", "\"Auto network creation disabled\"", ")", ...
Internal routine to retry the failed cases.
[ "Internal", "routine", "to", "retry", "the", "failed", "cases", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1906-L1934
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
FabricBase.retry_failure
def retry_failure(self, tenant_id, tenant_name, fw_data, is_fw_virt, result): """Top level retry failure routine. """ try: with self.mutex_lock: ret = self.retry_failure_internal(tenant_id, tenant_name, f...
python
def retry_failure(self, tenant_id, tenant_name, fw_data, is_fw_virt, result): """Top level retry failure routine. """ try: with self.mutex_lock: ret = self.retry_failure_internal(tenant_id, tenant_name, f...
[ "def", "retry_failure", "(", "self", ",", "tenant_id", ",", "tenant_name", ",", "fw_data", ",", "is_fw_virt", ",", "result", ")", ":", "try", ":", "with", "self", ".", "mutex_lock", ":", "ret", "=", "self", ".", "retry_failure_internal", "(", "tenant_id", ...
Top level retry failure routine.
[ "Top", "level", "retry", "failure", "routine", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1936-L1946
train
openstack/networking-cisco
networking_cisco/plugins/cisco/device_manager/config.py
verify_resource_dict
def verify_resource_dict(res_dict, is_create, attr_info): """Verifies required attributes are in resource dictionary, res_dict. Also checking that an attribute is only specified if it is allowed for the given operation (create/update). Attribute with default values are considered to be optional. ...
python
def verify_resource_dict(res_dict, is_create, attr_info): """Verifies required attributes are in resource dictionary, res_dict. Also checking that an attribute is only specified if it is allowed for the given operation (create/update). Attribute with default values are considered to be optional. ...
[ "def", "verify_resource_dict", "(", "res_dict", ",", "is_create", ",", "attr_info", ")", ":", "if", "(", "(", "bc", ".", "NEUTRON_VERSION", ">=", "bc", ".", "NEUTRON_NEWTON_VERSION", ")", "and", "'tenant_id'", "in", "res_dict", ")", ":", "res_dict", "[", "'p...
Verifies required attributes are in resource dictionary, res_dict. Also checking that an attribute is only specified if it is allowed for the given operation (create/update). Attribute with default values are considered to be optional. This function contains code taken from function 'prepare_request_...
[ "Verifies", "required", "attributes", "are", "in", "resource", "dictionary", "res_dict", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/device_manager/config.py#L148-L199
train
openstack/networking-cisco
networking_cisco/plugins/cisco/device_manager/config.py
uuidify
def uuidify(val): """Takes an integer and transforms it to a UUID format. returns: UUID formatted version of input. """ if uuidutils.is_uuid_like(val): return val else: try: int_val = int(val, 16) except ValueError: with excutils.save_and_reraise_exce...
python
def uuidify(val): """Takes an integer and transforms it to a UUID format. returns: UUID formatted version of input. """ if uuidutils.is_uuid_like(val): return val else: try: int_val = int(val, 16) except ValueError: with excutils.save_and_reraise_exce...
[ "def", "uuidify", "(", "val", ")", ":", "if", "uuidutils", ".", "is_uuid_like", "(", "val", ")", ":", "return", "val", "else", ":", "try", ":", "int_val", "=", "int", "(", "val", ",", "16", ")", "except", "ValueError", ":", "with", "excutils", ".", ...
Takes an integer and transforms it to a UUID format. returns: UUID formatted version of input.
[ "Takes", "an", "integer", "and", "transforms", "it", "to", "a", "UUID", "format", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/device_manager/config.py#L202-L219
train
openstack/networking-cisco
networking_cisco/plugins/cisco/device_manager/config.py
_ensure_format
def _ensure_format(rule, attribute, res_dict): """Verifies that attribute in res_dict is properly formatted. Since, in the .ini-files, lists are specified as ':' separated text and UUID values can be plain integers we need to transform any such values into proper format. Empty strings are converted to ...
python
def _ensure_format(rule, attribute, res_dict): """Verifies that attribute in res_dict is properly formatted. Since, in the .ini-files, lists are specified as ':' separated text and UUID values can be plain integers we need to transform any such values into proper format. Empty strings are converted to ...
[ "def", "_ensure_format", "(", "rule", ",", "attribute", ",", "res_dict", ")", ":", "if", "rule", "==", "'type:uuid'", "or", "(", "rule", "==", "'type:uuid_or_none'", "and", "res_dict", "[", "attribute", "]", ")", ":", "res_dict", "[", "attribute", "]", "="...
Verifies that attribute in res_dict is properly formatted. Since, in the .ini-files, lists are specified as ':' separated text and UUID values can be plain integers we need to transform any such values into proper format. Empty strings are converted to None if validator specifies that None value is acc...
[ "Verifies", "that", "attribute", "in", "res_dict", "is", "properly", "formatted", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/device_manager/config.py#L222-L242
train
openstack/networking-cisco
networking_cisco/plugins/cisco/device_manager/config.py
obtain_hosting_device_credentials_from_config
def obtain_hosting_device_credentials_from_config(): """Obtains credentials from config file and stores them in memory. To be called before hosting device templates defined in the config file are created. """ cred_dict = get_specific_config('cisco_hosting_device_credential') attr_info = { ...
python
def obtain_hosting_device_credentials_from_config(): """Obtains credentials from config file and stores them in memory. To be called before hosting device templates defined in the config file are created. """ cred_dict = get_specific_config('cisco_hosting_device_credential') attr_info = { ...
[ "def", "obtain_hosting_device_credentials_from_config", "(", ")", ":", "cred_dict", "=", "get_specific_config", "(", "'cisco_hosting_device_credential'", ")", "attr_info", "=", "{", "'name'", ":", "{", "'allow_post'", ":", "True", ",", "'allow_put'", ":", "True", ",",...
Obtains credentials from config file and stores them in memory. To be called before hosting device templates defined in the config file are created.
[ "Obtains", "credentials", "from", "config", "file", "and", "stores", "them", "in", "memory", ".", "To", "be", "called", "before", "hosting", "device", "templates", "defined", "in", "the", "config", "file", "are", "created", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/device_manager/config.py#L245-L273
train
openstack/networking-cisco
networking_cisco/plugins/cisco/extensions/routertype.py
RoutertypePluginBase.get_routertypes
def get_routertypes(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): """Lists defined router types.""" pass
python
def get_routertypes(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): """Lists defined router types.""" pass
[ "def", "get_routertypes", "(", "self", ",", "context", ",", "filters", "=", "None", ",", "fields", "=", "None", ",", "sorts", "=", "None", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "page_reverse", "=", "False", ")", ":", "pass" ]
Lists defined router types.
[ "Lists", "defined", "router", "types", "." ]
aa58a30aec25b86f9aa5952b0863045975debfa9
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/extensions/routertype.py#L213-L217
train
tophatmonocle/ims_lti_py
ims_lti_py/tool_provider.py
ToolProvider.has_role
def has_role(self, role): ''' Check whether the Launch Paramters set the role. ''' return self.roles and any([re.search(role, our_role, re.I) for our_role in self.roles])
python
def has_role(self, role): ''' Check whether the Launch Paramters set the role. ''' return self.roles and any([re.search(role, our_role, re.I) for our_role in self.roles])
[ "def", "has_role", "(", "self", ",", "role", ")", ":", "return", "self", ".", "roles", "and", "any", "(", "[", "re", ".", "search", "(", "role", ",", "our_role", ",", "re", ".", "I", ")", "for", "our_role", "in", "self", ".", "roles", "]", ")" ]
Check whether the Launch Paramters set the role.
[ "Check", "whether", "the", "Launch", "Paramters", "set", "the", "role", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_provider.py#L57-L62
train
tophatmonocle/ims_lti_py
ims_lti_py/tool_provider.py
ToolProvider.username
def username(self, default=None): ''' Return the full, given, or family name if set. ''' if self.lis_person_name_given: return self.lis_person_name_given elif self.lis_person_name_family: return self.lis_person_name_family elif self.lis_person_name...
python
def username(self, default=None): ''' Return the full, given, or family name if set. ''' if self.lis_person_name_given: return self.lis_person_name_given elif self.lis_person_name_family: return self.lis_person_name_family elif self.lis_person_name...
[ "def", "username", "(", "self", ",", "default", "=", "None", ")", ":", "if", "self", ".", "lis_person_name_given", ":", "return", "self", ".", "lis_person_name_given", "elif", "self", ".", "lis_person_name_family", ":", "return", "self", ".", "lis_person_name_fa...
Return the full, given, or family name if set.
[ "Return", "the", "full", "given", "or", "family", "name", "if", "set", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_provider.py#L96-L107
train
tophatmonocle/ims_lti_py
ims_lti_py/tool_provider.py
ToolProvider.build_return_url
def build_return_url(self): ''' If the Tool Consumer sent a return URL, add any set messages to the URL. ''' if not self.launch_presentation_return_url: return None lti_message_fields = ['lti_errormsg', 'lti_errorlog', 'lti_msg',...
python
def build_return_url(self): ''' If the Tool Consumer sent a return URL, add any set messages to the URL. ''' if not self.launch_presentation_return_url: return None lti_message_fields = ['lti_errormsg', 'lti_errorlog', 'lti_msg',...
[ "def", "build_return_url", "(", "self", ")", ":", "if", "not", "self", ".", "launch_presentation_return_url", ":", "return", "None", "lti_message_fields", "=", "[", "'lti_errormsg'", ",", "'lti_errorlog'", ",", "'lti_msg'", ",", "'lti_log'", "]", "messages", "=", ...
If the Tool Consumer sent a return URL, add any set messages to the URL.
[ "If", "the", "Tool", "Consumer", "sent", "a", "return", "URL", "add", "any", "set", "messages", "to", "the", "URL", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_provider.py#L152-L181
train
tophatmonocle/ims_lti_py
ims_lti_py/tool_provider.py
DjangoToolProvider.success_redirect
def success_redirect(self, msg='', log=''): ''' Shortcut for redirecting Django view to LTI Consumer with messages ''' from django.shortcuts import redirect self.lti_msg = msg self.lti_log = log return redirect(self.build_return_url())
python
def success_redirect(self, msg='', log=''): ''' Shortcut for redirecting Django view to LTI Consumer with messages ''' from django.shortcuts import redirect self.lti_msg = msg self.lti_log = log return redirect(self.build_return_url())
[ "def", "success_redirect", "(", "self", ",", "msg", "=", "''", ",", "log", "=", "''", ")", ":", "from", "django", ".", "shortcuts", "import", "redirect", "self", ".", "lti_msg", "=", "msg", "self", ".", "lti_log", "=", "log", "return", "redirect", "(",...
Shortcut for redirecting Django view to LTI Consumer with messages
[ "Shortcut", "for", "redirecting", "Django", "view", "to", "LTI", "Consumer", "with", "messages" ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_provider.py#L201-L208
train
tophatmonocle/ims_lti_py
ims_lti_py/tool_provider.py
DjangoToolProvider.error_redirect
def error_redirect(self, errormsg='', errorlog=''): ''' Shortcut for redirecting Django view to LTI Consumer with errors ''' from django.shortcuts import redirect self.lti_errormsg = errormsg self.lti_errorlog = errorlog return redirect(self.build_return_url())
python
def error_redirect(self, errormsg='', errorlog=''): ''' Shortcut for redirecting Django view to LTI Consumer with errors ''' from django.shortcuts import redirect self.lti_errormsg = errormsg self.lti_errorlog = errorlog return redirect(self.build_return_url())
[ "def", "error_redirect", "(", "self", ",", "errormsg", "=", "''", ",", "errorlog", "=", "''", ")", ":", "from", "django", ".", "shortcuts", "import", "redirect", "self", ".", "lti_errormsg", "=", "errormsg", "self", ".", "lti_errorlog", "=", "errorlog", "r...
Shortcut for redirecting Django view to LTI Consumer with errors
[ "Shortcut", "for", "redirecting", "Django", "view", "to", "LTI", "Consumer", "with", "errors" ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_provider.py#L210-L217
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client._notify_thing_lid_change
def _notify_thing_lid_change(self, from_lid, to_lid): """Used by Thing instances to indicate that a rename operation has happened""" try: with self.__private_things: self.__private_things[to_lid] = self.__private_things.pop(from_lid) except KeyError: logge...
python
def _notify_thing_lid_change(self, from_lid, to_lid): """Used by Thing instances to indicate that a rename operation has happened""" try: with self.__private_things: self.__private_things[to_lid] = self.__private_things.pop(from_lid) except KeyError: logge...
[ "def", "_notify_thing_lid_change", "(", "self", ",", "from_lid", ",", "to_lid", ")", ":", "try", ":", "with", "self", ".", "__private_things", ":", "self", ".", "__private_things", "[", "to_lid", "]", "=", "self", ".", "__private_things", ".", "pop", "(", ...
Used by Thing instances to indicate that a rename operation has happened
[ "Used", "by", "Thing", "instances", "to", "indicate", "that", "a", "rename", "operation", "has", "happened" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L235-L248
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.register_catchall_feeddata
def register_catchall_feeddata(self, callback, callback_parsed=None): """ Registers a callback that is called for all feeddata your Thing receives `Example` #!python def feeddata_callback(data): print(data) ... client.register_cat...
python
def register_catchall_feeddata(self, callback, callback_parsed=None): """ Registers a callback that is called for all feeddata your Thing receives `Example` #!python def feeddata_callback(data): print(data) ... client.register_cat...
[ "def", "register_catchall_feeddata", "(", "self", ",", "callback", ",", "callback_parsed", "=", "None", ")", ":", "if", "callback_parsed", ":", "callback", "=", "self", ".", "_get_parsed_feed_callback", "(", "callback_parsed", ",", "callback", ")", "return", "self...
Registers a callback that is called for all feeddata your Thing receives `Example` #!python def feeddata_callback(data): print(data) ... client.register_catchall_feeddata(feeddata_callback) `callback` (required) the function name that yo...
[ "Registers", "a", "callback", "that", "is", "called", "for", "all", "feeddata", "your", "Thing", "receives" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L256-L283
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.register_catchall_controlreq
def register_catchall_controlreq(self, callback, callback_parsed=None): """ Registers a callback that is called for all control requests received by your Thing `Example` #!python def controlreq_callback(data): print(data) ... clie...
python
def register_catchall_controlreq(self, callback, callback_parsed=None): """ Registers a callback that is called for all control requests received by your Thing `Example` #!python def controlreq_callback(data): print(data) ... clie...
[ "def", "register_catchall_controlreq", "(", "self", ",", "callback", ",", "callback_parsed", "=", "None", ")", ":", "if", "callback_parsed", ":", "callback", "=", "self", ".", "_get_parsed_control_callback", "(", "callback_parsed", ",", "callback", ")", "return", ...
Registers a callback that is called for all control requests received by your Thing `Example` #!python def controlreq_callback(data): print(data) ... client.register_catchall_controlreq(controlreq_callback) `callback` (required) the func...
[ "Registers", "a", "callback", "that", "is", "called", "for", "all", "control", "requests", "received", "by", "your", "Thing" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L285-L311
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.register_callback_duplicate
def register_callback_duplicate(self, func, serialised=True): """ Register a callback for resource creation but where the resource already exists in Iotic Space. In this case the existing reference is passed to you. If `serialised` is not set, the callbacks might arrive in a different or...
python
def register_callback_duplicate(self, func, serialised=True): """ Register a callback for resource creation but where the resource already exists in Iotic Space. In this case the existing reference is passed to you. If `serialised` is not set, the callbacks might arrive in a different or...
[ "def", "register_callback_duplicate", "(", "self", ",", "func", ",", "serialised", "=", "True", ")", ":", "self", ".", "__client", ".", "register_callback_duplicate", "(", "partial", "(", "self", ".", "__callback_payload_only", ",", "func", ")", ",", "serialised...
Register a callback for resource creation but where the resource already exists in Iotic Space. In this case the existing reference is passed to you. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The payload passed to your callback is an Ord...
[ "Register", "a", "callback", "for", "resource", "creation", "but", "where", "the", "resource", "already", "exists", "in", "Iotic", "Space", ".", "In", "this", "case", "the", "existing", "reference", "is", "passed", "to", "you", ".", "If", "serialised", "is",...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L383-L416
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.register_callback_renamed
def register_callback_renamed(self, func, serialised=True): """ Register a callback for resource rename. This will be called when any resource is renamed within your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The p...
python
def register_callback_renamed(self, func, serialised=True): """ Register a callback for resource rename. This will be called when any resource is renamed within your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The p...
[ "def", "register_callback_renamed", "(", "self", ",", "func", ",", "serialised", "=", "True", ")", ":", "self", ".", "__client", ".", "register_callback_renamed", "(", "partial", "(", "self", ".", "__callback_payload_only", ",", "func", ")", ",", "serialised", ...
Register a callback for resource rename. This will be called when any resource is renamed within your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The payload passed to your callback is an OrderedDict with the following keys ...
[ "Register", "a", "callback", "for", "resource", "rename", ".", "This", "will", "be", "called", "when", "any", "resource", "is", "renamed", "within", "your", "agent", ".", "If", "serialised", "is", "not", "set", "the", "callbacks", "might", "arrive", "in", ...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L418-L451
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.register_callback_deleted
def register_callback_deleted(self, func, serialised=True): """ Register a callback for resource deletion. This will be called when any resource is deleted within your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The...
python
def register_callback_deleted(self, func, serialised=True): """ Register a callback for resource deletion. This will be called when any resource is deleted within your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The...
[ "def", "register_callback_deleted", "(", "self", ",", "func", ",", "serialised", "=", "True", ")", ":", "self", ".", "__client", ".", "register_callback_deleted", "(", "partial", "(", "self", ".", "__callback_payload_only", ",", "func", ")", ",", "serialised", ...
Register a callback for resource deletion. This will be called when any resource is deleted within your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The payload passed to your callback is an OrderedDict with the following keys ...
[ "Register", "a", "callback", "for", "resource", "deletion", ".", "This", "will", "be", "called", "when", "any", "resource", "is", "deleted", "within", "your", "agent", ".", "If", "serialised", "is", "not", "set", "the", "callbacks", "might", "arrive", "in", ...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L453-L483
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.register_callback_reassigned
def register_callback_reassigned(self, func, serialised=True): """ Register a callback for resource reassignment. This will be called when any resource is reassigned to or from your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested...
python
def register_callback_reassigned(self, func, serialised=True): """ Register a callback for resource reassignment. This will be called when any resource is reassigned to or from your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested...
[ "def", "register_callback_reassigned", "(", "self", ",", "func", ",", "serialised", "=", "True", ")", ":", "self", ".", "__client", ".", "register_callback_reassigned", "(", "partial", "(", "self", ".", "__callback_payload_only", ",", "func", ")", ",", "serialis...
Register a callback for resource reassignment. This will be called when any resource is reassigned to or from your agent. If `serialised` is not set, the callbacks might arrive in a different order to they were requested. The payload passed to your callback is an OrderedDict with the following...
[ "Register", "a", "callback", "for", "resource", "reassignment", ".", "This", "will", "be", "called", "when", "any", "resource", "is", "reassigned", "to", "or", "from", "your", "agent", ".", "If", "serialised", "is", "not", "set", "the", "callbacks", "might",...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L485-L521
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.simulate_feeddata
def simulate_feeddata(self, feedid, data, mime=None, time=None): """Simulate the last feeddata received for given feedid Calls the registered callback for the feed with the last recieved feed data. Allows you to test your code without having to wait for the remote thing to share again. ...
python
def simulate_feeddata(self, feedid, data, mime=None, time=None): """Simulate the last feeddata received for given feedid Calls the registered callback for the feed with the last recieved feed data. Allows you to test your code without having to wait for the remote thing to share again. ...
[ "def", "simulate_feeddata", "(", "self", ",", "feedid", ",", "data", ",", "mime", "=", "None", ",", "time", "=", "None", ")", ":", "self", ".", "__client", ".", "simulate_feeddata", "(", "feedid", ",", "data", ",", "mime", ",", "time", ")" ]
Simulate the last feeddata received for given feedid Calls the registered callback for the feed with the last recieved feed data. Allows you to test your code without having to wait for the remote thing to share again. `feedid` (required) (string) local id of your Feed `data` (optional...
[ "Simulate", "the", "last", "feeddata", "received", "for", "given", "feedid", "Calls", "the", "registered", "callback", "for", "the", "feed", "with", "the", "last", "recieved", "feed", "data", ".", "Allows", "you", "to", "test", "your", "code", "without", "ha...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L543-L558
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.confirm_tell
def confirm_tell(self, data, success): """Confirm that you've done as you were told. Call this from your control callback to confirm action. Used when you are advertising a control and you want to tell the remote requestor that you have done what they asked you to. `Example:` this is a...
python
def confirm_tell(self, data, success): """Confirm that you've done as you were told. Call this from your control callback to confirm action. Used when you are advertising a control and you want to tell the remote requestor that you have done what they asked you to. `Example:` this is a...
[ "def", "confirm_tell", "(", "self", ",", "data", ",", "success", ")", ":", "logger", ".", "info", "(", "\"confirm_tell(success=%s) [lid=\\\"%s\\\",pid=\\\"%s\\\"]\"", ",", "success", ",", "data", "[", "P_ENTITY_LID", "]", ",", "data", "[", "P_LID", "]", ")", "...
Confirm that you've done as you were told. Call this from your control callback to confirm action. Used when you are advertising a control and you want to tell the remote requestor that you have done what they asked you to. `Example:` this is a minimal example to show the idea. Note - no Exce...
[ "Confirm", "that", "you", "ve", "done", "as", "you", "were", "told", ".", "Call", "this", "from", "your", "control", "callback", "to", "confirm", "action", ".", "Used", "when", "you", "are", "advertising", "a", "control", "and", "you", "want", "to", "tel...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L564-L604
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.save_config
def save_config(self): """Save the config, update the seqnum & default language """ self.__config.set('agent', 'seqnum', self.__client.get_seqnum()) self.__config.set('agent', 'lang', self.__client.default_lang) self.__config.save()
python
def save_config(self): """Save the config, update the seqnum & default language """ self.__config.set('agent', 'seqnum', self.__client.get_seqnum()) self.__config.set('agent', 'lang', self.__client.default_lang) self.__config.save()
[ "def", "save_config", "(", "self", ")", ":", "self", ".", "__config", ".", "set", "(", "'agent'", ",", "'seqnum'", ",", "self", ".", "__client", ".", "get_seqnum", "(", ")", ")", "self", ".", "__config", ".", "set", "(", "'agent'", ",", "'lang'", ","...
Save the config, update the seqnum & default language
[ "Save", "the", "config", "update", "the", "seqnum", "&", "default", "language" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L606-L611
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client._get_point_data_handler_for
def _get_point_data_handler_for(self, point): """Used by point instances and data callbacks""" with self.__point_data_handlers: try: return self.__point_data_handlers[point] except KeyError: return self.__point_data_handlers.setdefault(point, Point...
python
def _get_point_data_handler_for(self, point): """Used by point instances and data callbacks""" with self.__point_data_handlers: try: return self.__point_data_handlers[point] except KeyError: return self.__point_data_handlers.setdefault(point, Point...
[ "def", "_get_point_data_handler_for", "(", "self", ",", "point", ")", ":", "with", "self", ".", "__point_data_handlers", ":", "try", ":", "return", "self", ".", "__point_data_handlers", "[", "point", "]", "except", "KeyError", ":", "return", "self", ".", "__po...
Used by point instances and data callbacks
[ "Used", "by", "point", "instances", "and", "data", "callbacks" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L621-L627
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client._wait_and_except_if_failed
def _wait_and_except_if_failed(self, event, timeout=None): """Combines waiting for event and call to `_except_if_failed`. If timeout is not specified the configured sync_timeout is used. """ event.wait(timeout or self.__sync_timeout) self._except_if_failed(event)
python
def _wait_and_except_if_failed(self, event, timeout=None): """Combines waiting for event and call to `_except_if_failed`. If timeout is not specified the configured sync_timeout is used. """ event.wait(timeout or self.__sync_timeout) self._except_if_failed(event)
[ "def", "_wait_and_except_if_failed", "(", "self", ",", "event", ",", "timeout", "=", "None", ")", ":", "event", ".", "wait", "(", "timeout", "or", "self", ".", "__sync_timeout", ")", "self", ".", "_except_if_failed", "(", "event", ")" ]
Combines waiting for event and call to `_except_if_failed`. If timeout is not specified the configured sync_timeout is used.
[ "Combines", "waiting", "for", "event", "and", "call", "to", "_except_if_failed", ".", "If", "timeout", "is", "not", "specified", "the", "configured", "sync_timeout", "is", "used", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L661-L666
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client._except_if_failed
def _except_if_failed(cls, event): """Raises an IOTException from the given event if it was not successful. Assumes timeout success flag on event has not been set yet.""" if event.success is None: raise IOTSyncTimeout('Requested timed out', event) if not event.success: ...
python
def _except_if_failed(cls, event): """Raises an IOTException from the given event if it was not successful. Assumes timeout success flag on event has not been set yet.""" if event.success is None: raise IOTSyncTimeout('Requested timed out', event) if not event.success: ...
[ "def", "_except_if_failed", "(", "cls", ",", "event", ")", ":", "if", "event", ".", "success", "is", "None", ":", "raise", "IOTSyncTimeout", "(", "'Requested timed out'", ",", "event", ")", "if", "not", "event", ".", "success", ":", "msg", "=", "\"Request ...
Raises an IOTException from the given event if it was not successful. Assumes timeout success flag on event has not been set yet.
[ "Raises", "an", "IOTException", "from", "the", "given", "event", "if", "it", "was", "not", "successful", ".", "Assumes", "timeout", "success", "flag", "on", "event", "has", "not", "been", "set", "yet", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L669-L686
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.list
def list(self, all_my_agents=False, limit=500, offset=0): """List `all` the things created by this client on this or all your agents Returns QAPI list function payload Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications pr...
python
def list(self, all_my_agents=False, limit=500, offset=0): """List `all` the things created by this client on this or all your agents Returns QAPI list function payload Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications pr...
[ "def", "list", "(", "self", ",", "all_my_agents", "=", "False", ",", "limit", "=", "500", ",", "offset", "=", "0", ")", ":", "logger", ".", "info", "(", "\"list(all_my_agents=%s, limit=%s, offset=%s)\"", ",", "all_my_agents", ",", "limit", ",", "offset", ")"...
List `all` the things created by this client on this or all your agents Returns QAPI list function payload Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `all_my_agents` (op...
[ "List", "all", "the", "things", "created", "by", "this", "client", "on", "this", "or", "all", "your", "agents" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L688-L710
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.get_thing
def get_thing(self, lid): """Get the details of a newly created Thing. This only applies to asynchronous creation of Things and the new Thing instance can only be retrieved once. Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object, which corresponds to the Thing with the g...
python
def get_thing(self, lid): """Get the details of a newly created Thing. This only applies to asynchronous creation of Things and the new Thing instance can only be retrieved once. Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object, which corresponds to the Thing with the g...
[ "def", "get_thing", "(", "self", ",", "lid", ")", ":", "with", "self", ".", "__new_things", ":", "try", ":", "return", "self", ".", "__new_things", ".", "pop", "(", "lid", ")", "except", "KeyError", "as", "ex", ":", "raise_from", "(", "KeyError", "(", ...
Get the details of a newly created Thing. This only applies to asynchronous creation of Things and the new Thing instance can only be retrieved once. Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object, which corresponds to the Thing with the given local id (nickname) Rai...
[ "Get", "the", "details", "of", "a", "newly", "created", "Thing", ".", "This", "only", "applies", "to", "asynchronous", "creation", "of", "Things", "and", "the", "new", "Thing", "instance", "can", "only", "be", "retrieved", "once", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L712-L727
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Client.py
Client.delete_thing
def delete_thing(self, lid): """Delete a Thing Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) i...
python
def delete_thing(self, lid): """Delete a Thing Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) i...
[ "def", "delete_thing", "(", "self", ",", "lid", ")", ":", "logger", ".", "info", "(", "\"delete_thing(lid=\\\"%s\\\")\"", ",", "lid", ")", "evt", "=", "self", ".", "delete_thing_async", "(", "lid", ")", "self", ".", "_wait_and_except_if_failed", "(", "evt", ...
Delete a Thing Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem betw...
[ "Delete", "a", "Thing" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L756-L769
train
tophatmonocle/ims_lti_py
ims_lti_py/outcome_request.py
OutcomeRequest.from_post_request
def from_post_request(post_request): ''' Convenience method for creating a new OutcomeRequest from a request object. post_request is assumed to be a Django HttpRequest object ''' request = OutcomeRequest() request.post_request = post_request request.proce...
python
def from_post_request(post_request): ''' Convenience method for creating a new OutcomeRequest from a request object. post_request is assumed to be a Django HttpRequest object ''' request = OutcomeRequest() request.post_request = post_request request.proce...
[ "def", "from_post_request", "(", "post_request", ")", ":", "request", "=", "OutcomeRequest", "(", ")", "request", ".", "post_request", "=", "post_request", "request", ".", "process_xml", "(", "post_request", ".", "data", ")", "return", "request" ]
Convenience method for creating a new OutcomeRequest from a request object. post_request is assumed to be a Django HttpRequest object
[ "Convenience", "method", "for", "creating", "a", "new", "OutcomeRequest", "from", "a", "request", "object", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L48-L58
train
tophatmonocle/ims_lti_py
ims_lti_py/outcome_request.py
OutcomeRequest.post_outcome_request
def post_outcome_request(self): ''' POST an OAuth signed request to the Tool Consumer. ''' if not self.has_required_attributes(): raise InvalidLTIConfigError( 'OutcomeRequest does not have all required attributes') consumer = oauth2.Consumer(key=self....
python
def post_outcome_request(self): ''' POST an OAuth signed request to the Tool Consumer. ''' if not self.has_required_attributes(): raise InvalidLTIConfigError( 'OutcomeRequest does not have all required attributes') consumer = oauth2.Consumer(key=self....
[ "def", "post_outcome_request", "(", "self", ")", ":", "if", "not", "self", ".", "has_required_attributes", "(", ")", ":", "raise", "InvalidLTIConfigError", "(", "'OutcomeRequest does not have all required attributes'", ")", "consumer", "=", "oauth2", ".", "Consumer", ...
POST an OAuth signed request to the Tool Consumer.
[ "POST", "an", "OAuth", "signed", "request", "to", "the", "Tool", "Consumer", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L124-L169
train
tophatmonocle/ims_lti_py
ims_lti_py/outcome_request.py
OutcomeRequest.process_xml
def process_xml(self, xml): ''' Parse Outcome Request data from XML. ''' root = objectify.fromstring(xml) self.message_identifier = str( root.imsx_POXHeader.imsx_POXRequestHeaderInfo. imsx_messageIdentifier) try: result = root.imsx_POXB...
python
def process_xml(self, xml): ''' Parse Outcome Request data from XML. ''' root = objectify.fromstring(xml) self.message_identifier = str( root.imsx_POXHeader.imsx_POXRequestHeaderInfo. imsx_messageIdentifier) try: result = root.imsx_POXB...
[ "def", "process_xml", "(", "self", ",", "xml", ")", ":", "root", "=", "objectify", ".", "fromstring", "(", "xml", ")", "self", ".", "message_identifier", "=", "str", "(", "root", ".", "imsx_POXHeader", ".", "imsx_POXRequestHeaderInfo", ".", "imsx_messageIdenti...
Parse Outcome Request data from XML.
[ "Parse", "Outcome", "Request", "data", "from", "XML", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L171-L206
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Config.py
Config.setup_logging
def setup_logging(self): """Setup logging module based on known modules in the config file """ logging.getLogger('amqp').setLevel(str_to_logging(self.get('logging', 'amqp'))) logging.getLogger('rdflib').setLevel(str_to_logging(self.get('logging', 'rdflib')))
python
def setup_logging(self): """Setup logging module based on known modules in the config file """ logging.getLogger('amqp').setLevel(str_to_logging(self.get('logging', 'amqp'))) logging.getLogger('rdflib').setLevel(str_to_logging(self.get('logging', 'rdflib')))
[ "def", "setup_logging", "(", "self", ")", ":", "logging", ".", "getLogger", "(", "'amqp'", ")", ".", "setLevel", "(", "str_to_logging", "(", "self", ".", "get", "(", "'logging'", ",", "'amqp'", ")", ")", ")", "logging", ".", "getLogger", "(", "'rdflib'",...
Setup logging module based on known modules in the config file
[ "Setup", "logging", "module", "based", "on", "known", "modules", "in", "the", "config", "file" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L158-L162
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Config.py
Config.save
def save(self, filename=None): """Write config to file.""" if self.__fname is None and filename is None: raise ValueError('Config loaded from string, no filename specified') conf = self.__config cpa = dict_to_cp(conf) with open(self.__fname if filename is None else fi...
python
def save(self, filename=None): """Write config to file.""" if self.__fname is None and filename is None: raise ValueError('Config loaded from string, no filename specified') conf = self.__config cpa = dict_to_cp(conf) with open(self.__fname if filename is None else fi...
[ "def", "save", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "self", ".", "__fname", "is", "None", "and", "filename", "is", "None", ":", "raise", "ValueError", "(", "'Config loaded from string, no filename specified'", ")", "conf", "=", "self", ...
Write config to file.
[ "Write", "config", "to", "file", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L164-L171
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Config.py
Config.get
def get(self, section, val): """Get a setting or the default `Returns` The current value of the setting `val` or the default, or `None` if not found `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E...
python
def get(self, section, val): """Get a setting or the default `Returns` The current value of the setting `val` or the default, or `None` if not found `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E...
[ "def", "get", "(", "self", ",", "section", ",", "val", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "if", "section", "in", "self", ".", "__config", ":", "if", "val", "in", "self", ".", "__config", "[", "section", "]", ":", "return", "self...
Get a setting or the default `Returns` The current value of the setting `val` or the default, or `None` if not found `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E.g. `"host"`
[ "Get", "a", "setting", "or", "the", "default" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L173-L191
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Config.py
Config.set
def set(self, section, val, data): """Add a setting to the config `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E.g. `"host"` `data` (mandatory) (as appropriate) the new value for the `val` ...
python
def set(self, section, val, data): """Add a setting to the config `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E.g. `"host"` `data` (mandatory) (as appropriate) the new value for the `val` ...
[ "def", "set", "(", "self", ",", "section", ",", "val", ",", "data", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "if", "section", "in", "self", ".", "__config", ":", "self", ".", "__config", "[", "section", "]", "[", "val", "]", "=", "d...
Add a setting to the config `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E.g. `"host"` `data` (mandatory) (as appropriate) the new value for the `val`
[ "Add", "a", "setting", "to", "the", "config" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L193-L205
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Config.py
Config.update
def update(self, section, val, data): """Add a setting to the config, but if same as default or None then no action. This saves the .save writing the defaults `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the...
python
def update(self, section, val, data): """Add a setting to the config, but if same as default or None then no action. This saves the .save writing the defaults `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the...
[ "def", "update", "(", "self", ",", "section", ",", "val", ",", "data", ")", ":", "k", "=", "self", ".", "get", "(", "section", ",", "val", ")", "if", "data", "is", "not", "None", "and", "k", "!=", "data", ":", "self", ".", "set", "(", "section"...
Add a setting to the config, but if same as default or None then no action. This saves the .save writing the defaults `section` (mandatory) (string) the section name in the config E.g. `"agent"` `val` (mandatory) (string) the section name in the config E.g. `"host"` `data` (mandatory)...
[ "Add", "a", "setting", "to", "the", "config", "but", "if", "same", "as", "default", "or", "None", "then", "no", "action", ".", "This", "saves", "the", ".", "save", "writing", "the", "defaults" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L207-L220
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/ThingMeta.py
ThingMeta.get_location
def get_location(self): """Gets the current geo location of your Thing Returns tuple of `(lat, lon)` in `float` or `(None, None)` if location is not set for this Thing """ lat = None lon = None # note: always picks from first triple for _, _, o in self._graph.tri...
python
def get_location(self): """Gets the current geo location of your Thing Returns tuple of `(lat, lon)` in `float` or `(None, None)` if location is not set for this Thing """ lat = None lon = None # note: always picks from first triple for _, _, o in self._graph.tri...
[ "def", "get_location", "(", "self", ")", ":", "lat", "=", "None", "lon", "=", "None", "for", "_", ",", "_", ",", "o", "in", "self", ".", "_graph", ".", "triples", "(", "(", "None", ",", "GEO_NS", ".", "lat", ",", "None", ")", ")", ":", "lat", ...
Gets the current geo location of your Thing Returns tuple of `(lat, lon)` in `float` or `(None, None)` if location is not set for this Thing
[ "Gets", "the", "current", "geo", "location", "of", "your", "Thing" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/ThingMeta.py#L48-L63
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.start
def start(self): """start connection threads, blocks until started """ if not (self.__recv_thread or self.__send_thread): self.__end.clear() self.__send_ready.clear() self.__recv_ready.clear() timeout = self.__socket_timeout + 1 ignore_...
python
def start(self): """start connection threads, blocks until started """ if not (self.__recv_thread or self.__send_thread): self.__end.clear() self.__send_ready.clear() self.__recv_ready.clear() timeout = self.__socket_timeout + 1 ignore_...
[ "def", "start", "(", "self", ")", ":", "if", "not", "(", "self", ".", "__recv_thread", "or", "self", ".", "__send_thread", ")", ":", "self", ".", "__end", ".", "clear", "(", ")", "self", ".", "__send_ready", ".", "clear", "(", ")", "self", ".", "__...
start connection threads, blocks until started
[ "start", "connection", "threads", "blocks", "until", "started" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L120-L162
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.is_alive
def is_alive(self): """Helper function to show if send & recv Threads are running """ if self.__send_ready.is_set() and self.__recv_ready.is_set(): if self.__send_thread is not None and self.__recv_thread is not None: return self.__send_thread.is_alive() and self.__re...
python
def is_alive(self): """Helper function to show if send & recv Threads are running """ if self.__send_ready.is_set() and self.__recv_ready.is_set(): if self.__send_thread is not None and self.__recv_thread is not None: return self.__send_thread.is_alive() and self.__re...
[ "def", "is_alive", "(", "self", ")", ":", "if", "self", ".", "__send_ready", ".", "is_set", "(", ")", "and", "self", ".", "__recv_ready", ".", "is_set", "(", ")", ":", "if", "self", ".", "__send_thread", "is", "not", "None", "and", "self", ".", "__re...
Helper function to show if send & recv Threads are running
[ "Helper", "function", "to", "show", "if", "send", "&", "recv", "Threads", "are", "running" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L164-L170
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.stop
def stop(self): """disconnect, blocks until stopped """ self.__end.set() if self.__recv_thread: self.__recv_thread.join() self.__recv_thread = None if self.__send_thread: self.__send_thread.join() self.__send_thread = None
python
def stop(self): """disconnect, blocks until stopped """ self.__end.set() if self.__recv_thread: self.__recv_thread.join() self.__recv_thread = None if self.__send_thread: self.__send_thread.join() self.__send_thread = None
[ "def", "stop", "(", "self", ")", ":", "self", ".", "__end", ".", "set", "(", ")", "if", "self", ".", "__recv_thread", ":", "self", ".", "__recv_thread", ".", "join", "(", ")", "self", ".", "__recv_thread", "=", "None", "if", "self", ".", "__send_thre...
disconnect, blocks until stopped
[ "disconnect", "blocks", "until", "stopped" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L172-L181
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.__get_ssl_context
def __get_ssl_context(cls, sslca=None): """Make an SSLConext for this Python version using public or sslca """ if ((version_info[0] == 2 and (version_info[1] >= 7 and version_info[2] >= 5)) or (version_info[0] == 3 and version_info[1] >= 4)): logger.debug('SSL method ...
python
def __get_ssl_context(cls, sslca=None): """Make an SSLConext for this Python version using public or sslca """ if ((version_info[0] == 2 and (version_info[1] >= 7 and version_info[2] >= 5)) or (version_info[0] == 3 and version_info[1] >= 4)): logger.debug('SSL method ...
[ "def", "__get_ssl_context", "(", "cls", ",", "sslca", "=", "None", ")", ":", "if", "(", "(", "version_info", "[", "0", "]", "==", "2", "and", "(", "version_info", "[", "1", "]", ">=", "7", "and", "version_info", "[", "2", "]", ">=", "5", ")", ")"...
Make an SSLConext for this Python version using public or sslca
[ "Make", "an", "SSLConext", "for", "this", "Python", "version", "using", "public", "or", "sslca" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L216-L259
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.__recv_cb
def __recv_cb(self, msg): """Calls user-provided callback and marks message for Ack regardless of success """ try: self.__msg_callback(msg) except: logger.exception("AmqpLink.__recv_cb exception calling msg_callback") finally: # only works if a...
python
def __recv_cb(self, msg): """Calls user-provided callback and marks message for Ack regardless of success """ try: self.__msg_callback(msg) except: logger.exception("AmqpLink.__recv_cb exception calling msg_callback") finally: # only works if a...
[ "def", "__recv_cb", "(", "self", ",", "msg", ")", ":", "try", ":", "self", ".", "__msg_callback", "(", "msg", ")", "except", ":", "logger", ".", "exception", "(", "\"AmqpLink.__recv_cb exception calling msg_callback\"", ")", "finally", ":", "self", ".", "__las...
Calls user-provided callback and marks message for Ack regardless of success
[ "Calls", "user", "-", "provided", "callback", "and", "marks", "message", "for", "Ack", "regardless", "of", "success" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L275-L285
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.__send_run
def __send_run(self): """Send request thread """ while not self.__end.is_set(): try: with Connection(userid=self.__prefix + self.__epid, password=self.__passwd, virtual_host=self.__vhost, ...
python
def __send_run(self): """Send request thread """ while not self.__end.is_set(): try: with Connection(userid=self.__prefix + self.__epid, password=self.__passwd, virtual_host=self.__vhost, ...
[ "def", "__send_run", "(", "self", ")", ":", "while", "not", "self", ".", "__end", ".", "is_set", "(", ")", ":", "try", ":", "with", "Connection", "(", "userid", "=", "self", ".", "__prefix", "+", "self", ".", "__epid", ",", "password", "=", "self", ...
Send request thread
[ "Send", "request", "thread" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L374-L423
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.__send_log_set_exc_and_wait
def __send_log_set_exc_and_wait(self, msg, level=None, wait_seconds=CONN_RETRY_DELAY_SECONDS): """To be called in exception context only. msg - message to log level - logging level. If not specified, ERROR unless it is a repeated failure in which case DEBUG. If specified, the given leve...
python
def __send_log_set_exc_and_wait(self, msg, level=None, wait_seconds=CONN_RETRY_DELAY_SECONDS): """To be called in exception context only. msg - message to log level - logging level. If not specified, ERROR unless it is a repeated failure in which case DEBUG. If specified, the given leve...
[ "def", "__send_log_set_exc_and_wait", "(", "self", ",", "msg", ",", "level", "=", "None", ",", "wait_seconds", "=", "CONN_RETRY_DELAY_SECONDS", ")", ":", "logger", ".", "log", "(", "(", "(", "logging", ".", "DEBUG", "if", "self", ".", "__send_exc", "else", ...
To be called in exception context only. msg - message to log level - logging level. If not specified, ERROR unless it is a repeated failure in which case DEBUG. If specified, the given level will always be used. wait_seconds - how long to pause for (so retry is not triggered immediately...
[ "To", "be", "called", "in", "exception", "context", "only", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L425-L440
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/AmqpLink.py
AmqpLink.__send_exc_clear
def __send_exc_clear(self, log_if_exc_set=None): """Clear send exception and time. If exception was previously was set, optionally log log_if_exc_set at INFO level. """ if not (log_if_exc_set is None or self.__send_exc is None): logger.info(log_if_exc_set) self.__send...
python
def __send_exc_clear(self, log_if_exc_set=None): """Clear send exception and time. If exception was previously was set, optionally log log_if_exc_set at INFO level. """ if not (log_if_exc_set is None or self.__send_exc is None): logger.info(log_if_exc_set) self.__send...
[ "def", "__send_exc_clear", "(", "self", ",", "log_if_exc_set", "=", "None", ")", ":", "if", "not", "(", "log_if_exc_set", "is", "None", "or", "self", ".", "__send_exc", "is", "None", ")", ":", "logger", ".", "info", "(", "log_if_exc_set", ")", "self", "....
Clear send exception and time. If exception was previously was set, optionally log log_if_exc_set at INFO level.
[ "Clear", "send", "exception", "and", "time", ".", "If", "exception", "was", "previously", "was", "set", "optionally", "log", "log_if_exc_set", "at", "INFO", "level", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L442-L449
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Mime.py
expand_idx_mimetype
def expand_idx_mimetype(type_): """Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions""" if isinstance(type_, unicode_type): match = __IDX_PATTERN.match(type_) return __IDX_MAPPING.get(match.group(1), type_) if match else type_ else: ret...
python
def expand_idx_mimetype(type_): """Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions""" if isinstance(type_, unicode_type): match = __IDX_PATTERN.match(type_) return __IDX_MAPPING.get(match.group(1), type_) if match else type_ else: ret...
[ "def", "expand_idx_mimetype", "(", "type_", ")", ":", "if", "isinstance", "(", "type_", ",", "unicode_type", ")", ":", "match", "=", "__IDX_PATTERN", ".", "match", "(", "type_", ")", "return", "__IDX_MAPPING", ".", "get", "(", "match", ".", "group", "(", ...
Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions
[ "Returns", "long", "equivalent", "of", "type_", "if", "available", "otherwise", "type_", "itself", ".", "Does", "not", "raise", "exceptions" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Mime.py#L73-L79
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.restore_event
def restore_event(self, requestId): """restore an event based on the requestId. For example if the user app had to shutdown with pending requests. The user can rebuild the Events they were waiting for based on the requestId(s). """ with self.__requests: if requestId ...
python
def restore_event(self, requestId): """restore an event based on the requestId. For example if the user app had to shutdown with pending requests. The user can rebuild the Events they were waiting for based on the requestId(s). """ with self.__requests: if requestId ...
[ "def", "restore_event", "(", "self", ",", "requestId", ")", ":", "with", "self", ".", "__requests", ":", "if", "requestId", "not", "in", "self", ".", "__requests", ":", "self", ".", "__requests", "[", "requestId", "]", "=", "RequestEvent", "(", "requestId"...
restore an event based on the requestId. For example if the user app had to shutdown with pending requests. The user can rebuild the Events they were waiting for based on the requestId(s).
[ "restore", "an", "event", "based", "on", "the", "requestId", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L286-L296
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.simulate_feeddata
def simulate_feeddata(self, feedid, data, mime=None, time=None): """Send feed data""" # Separate public method since internal one does not require parameter checks feedid = Validation.guid_check_convert(feedid) mime = Validation.mime_check_convert(mime, allow_none=True) Validatio...
python
def simulate_feeddata(self, feedid, data, mime=None, time=None): """Send feed data""" # Separate public method since internal one does not require parameter checks feedid = Validation.guid_check_convert(feedid) mime = Validation.mime_check_convert(mime, allow_none=True) Validatio...
[ "def", "simulate_feeddata", "(", "self", ",", "feedid", ",", "data", ",", "mime", "=", "None", ",", "time", "=", "None", ")", ":", "feedid", "=", "Validation", ".", "guid_check_convert", "(", "feedid", ")", "mime", "=", "Validation", ".", "mime_check_conve...
Send feed data
[ "Send", "feed", "data" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L393-L399
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.stop
def stop(self): """Stop the Client, disconnect from queue """ if self.__end.is_set(): return self.__end.set() self.__send_retry_requests_timer.cancel() self.__threadpool.stop() self.__crud_threadpool.stop() self.__amqplink.stop() self._...
python
def stop(self): """Stop the Client, disconnect from queue """ if self.__end.is_set(): return self.__end.set() self.__send_retry_requests_timer.cancel() self.__threadpool.stop() self.__crud_threadpool.stop() self.__amqplink.stop() self._...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "__end", ".", "is_set", "(", ")", ":", "return", "self", ".", "__end", ".", "set", "(", ")", "self", ".", "__send_retry_requests_timer", ".", "cancel", "(", ")", "self", ".", "__threadpool", "....
Stop the Client, disconnect from queue
[ "Stop", "the", "Client", "disconnect", "from", "queue" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L516-L540
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client._request
def _request(self, resource, rtype, action=None, payload=None, offset=None, limit=None, requestId=None, is_crud=False): """_request amqp queue publish helper return: RequestEvent object or None for failed to publish """ end = self.__end if end.is_set(): ...
python
def _request(self, resource, rtype, action=None, payload=None, offset=None, limit=None, requestId=None, is_crud=False): """_request amqp queue publish helper return: RequestEvent object or None for failed to publish """ end = self.__end if end.is_set(): ...
[ "def", "_request", "(", "self", ",", "resource", ",", "rtype", ",", "action", "=", "None", ",", "payload", "=", "None", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "requestId", "=", "None", ",", "is_crud", "=", "False", ")", ":", "e...
_request amqp queue publish helper return: RequestEvent object or None for failed to publish
[ "_request", "amqp", "queue", "publish", "helper" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L577-L601
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__bytes_to_share_data
def __bytes_to_share_data(self, payload): """Attempt to auto-decode data""" rbytes = payload[P_DATA] mime = payload[P_MIME] if mime is None or not self.__auto_encode_decode: return rbytes, mime mime = expand_idx_mimetype(mime).lower() try: if mime...
python
def __bytes_to_share_data(self, payload): """Attempt to auto-decode data""" rbytes = payload[P_DATA] mime = payload[P_MIME] if mime is None or not self.__auto_encode_decode: return rbytes, mime mime = expand_idx_mimetype(mime).lower() try: if mime...
[ "def", "__bytes_to_share_data", "(", "self", ",", "payload", ")", ":", "rbytes", "=", "payload", "[", "P_DATA", "]", "mime", "=", "payload", "[", "P_MIME", "]", "if", "mime", "is", "None", "or", "not", "self", ".", "__auto_encode_decode", ":", "return", ...
Attempt to auto-decode data
[ "Attempt", "to", "auto", "-", "decode", "data" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L960-L977
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__make_hash
def __make_hash(cls, innermsg, token, seqnum): """return the hash for this innermsg, token, seqnum return digest bytes """ hobj = hmacNew(token, digestmod=hashfunc) hobj.update(innermsg) hobj.update(cls.__byte_packer(seqnum)) return hobj.digest()
python
def __make_hash(cls, innermsg, token, seqnum): """return the hash for this innermsg, token, seqnum return digest bytes """ hobj = hmacNew(token, digestmod=hashfunc) hobj.update(innermsg) hobj.update(cls.__byte_packer(seqnum)) return hobj.digest()
[ "def", "__make_hash", "(", "cls", ",", "innermsg", ",", "token", ",", "seqnum", ")", ":", "hobj", "=", "hmacNew", "(", "token", ",", "digestmod", "=", "hashfunc", ")", "hobj", ".", "update", "(", "innermsg", ")", "hobj", ".", "update", "(", "cls", "....
return the hash for this innermsg, token, seqnum return digest bytes
[ "return", "the", "hash", "for", "this", "innermsg", "token", "seqnum", "return", "digest", "bytes" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1069-L1076
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__request_mark_sent
def __request_mark_sent(self, requestId): """Set send time & clear exception from request if set, ignoring non-existent requests""" with self.__requests: try: req = self.__requests[requestId] except KeyError: # request might have had a response alr...
python
def __request_mark_sent(self, requestId): """Set send time & clear exception from request if set, ignoring non-existent requests""" with self.__requests: try: req = self.__requests[requestId] except KeyError: # request might have had a response alr...
[ "def", "__request_mark_sent", "(", "self", ",", "requestId", ")", ":", "with", "self", ".", "__requests", ":", "try", ":", "req", "=", "self", ".", "__requests", "[", "requestId", "]", "except", "KeyError", ":", "pass", "else", ":", "req", ".", "exceptio...
Set send time & clear exception from request if set, ignoring non-existent requests
[ "Set", "send", "time", "&", "clear", "exception", "from", "request", "if", "set", "ignoring", "non", "-", "existent", "requests" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1117-L1127
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__fire_callback
def __fire_callback(self, type_, *args, **kwargs): """Returns True if at least one callback was called""" called = False plain_submit = self.__threadpool.submit with self.__callbacks: submit = self.__crud_threadpool.submit if type_ in _CB_CRUD_TYPES else plain_submit ...
python
def __fire_callback(self, type_, *args, **kwargs): """Returns True if at least one callback was called""" called = False plain_submit = self.__threadpool.submit with self.__callbacks: submit = self.__crud_threadpool.submit if type_ in _CB_CRUD_TYPES else plain_submit ...
[ "def", "__fire_callback", "(", "self", ",", "type_", ",", "*", "args", ",", "**", "kwargs", ")", ":", "called", "=", "False", "plain_submit", "=", "self", ".", "__threadpool", ".", "submit", "with", "self", ".", "__callbacks", ":", "submit", "=", "self",...
Returns True if at least one callback was called
[ "Returns", "True", "if", "at", "least", "one", "callback", "was", "called" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1225-L1235
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__handle_known_solicited
def __handle_known_solicited(self, msg): """returns True if message has been handled as a solicited response""" with self.__requests: try: req = self.__requests[msg[M_CLIENTREF]] except KeyError: return False if self.__handle_low_seq_r...
python
def __handle_known_solicited(self, msg): """returns True if message has been handled as a solicited response""" with self.__requests: try: req = self.__requests[msg[M_CLIENTREF]] except KeyError: return False if self.__handle_low_seq_r...
[ "def", "__handle_known_solicited", "(", "self", ",", "msg", ")", ":", "with", "self", ".", "__requests", ":", "try", ":", "req", "=", "self", ".", "__requests", "[", "msg", "[", "M_CLIENTREF", "]", "]", "except", "KeyError", ":", "return", "False", "if",...
returns True if message has been handled as a solicited response
[ "returns", "True", "if", "message", "has", "been", "handled", "as", "a", "solicited", "response" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1358-L1398
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__clear_references
def __clear_references(self, request, remove_request=True): """Remove any internal references to the given request""" # remove request itself if remove_request: with self.__requests: self.__requests.pop(request.id_) # remove request type specific references ...
python
def __clear_references(self, request, remove_request=True): """Remove any internal references to the given request""" # remove request itself if remove_request: with self.__requests: self.__requests.pop(request.id_) # remove request type specific references ...
[ "def", "__clear_references", "(", "self", ",", "request", ",", "remove_request", "=", "True", ")", ":", "if", "remove_request", ":", "with", "self", ".", "__requests", ":", "self", ".", "__requests", ".", "pop", "(", "request", ".", "id_", ")", "if", "no...
Remove any internal references to the given request
[ "Remove", "any", "internal", "references", "to", "the", "given", "request" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1400-L1411
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
Client.__perform_unsolicited_callbacks
def __perform_unsolicited_callbacks(self, msg): """Callbacks for which a client reference is either optional or does not apply at all""" type_ = msg[M_TYPE] payload = msg[M_PAYLOAD] # callbacks for responses which might be unsolicited (e.g. created or deleted) if type_ in _RSP_P...
python
def __perform_unsolicited_callbacks(self, msg): """Callbacks for which a client reference is either optional or does not apply at all""" type_ = msg[M_TYPE] payload = msg[M_PAYLOAD] # callbacks for responses which might be unsolicited (e.g. created or deleted) if type_ in _RSP_P...
[ "def", "__perform_unsolicited_callbacks", "(", "self", ",", "msg", ")", ":", "type_", "=", "msg", "[", "M_TYPE", "]", "payload", "=", "msg", "[", "M_PAYLOAD", "]", "if", "type_", "in", "_RSP_PAYLOAD_CB_MAPPING", ":", "self", ".", "__fire_callback", "(", "_RS...
Callbacks for which a client reference is either optional or does not apply at all
[ "Callbacks", "for", "which", "a", "client", "reference", "is", "either", "optional", "or", "does", "not", "apply", "at", "all" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1471-L1489
train
tophatmonocle/ims_lti_py
ims_lti_py/launch_params.py
LaunchParamsMixin.roles
def roles(self, roles_list): ''' Set the roles for the current launch. Full list of roles can be found here: http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560479 LIS roles include: * Student * Faculty * Member * Learner * Instr...
python
def roles(self, roles_list): ''' Set the roles for the current launch. Full list of roles can be found here: http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560479 LIS roles include: * Student * Faculty * Member * Learner * Instr...
[ "def", "roles", "(", "self", ",", "roles_list", ")", ":", "if", "roles_list", "and", "isinstance", "(", "roles_list", ",", "list", ")", ":", "self", ".", "roles", "=", "[", "]", ".", "extend", "(", "roles_list", ")", "elif", "roles_list", "and", "isins...
Set the roles for the current launch. Full list of roles can be found here: http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560479 LIS roles include: * Student * Faculty * Member * Learner * Instructor * Mentor * Staff * ...
[ "Set", "the", "roles", "for", "the", "current", "launch", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/launch_params.py#L71-L97
train
tophatmonocle/ims_lti_py
ims_lti_py/launch_params.py
LaunchParamsMixin.process_params
def process_params(self, params): ''' Populates the launch data from a dictionary. Only cares about keys in the LAUNCH_DATA_PARAMETERS list, or that start with 'custom_' or 'ext_'. ''' for key, val in params.items(): if key in LAUNCH_DATA_PARAMETERS and val !=...
python
def process_params(self, params): ''' Populates the launch data from a dictionary. Only cares about keys in the LAUNCH_DATA_PARAMETERS list, or that start with 'custom_' or 'ext_'. ''' for key, val in params.items(): if key in LAUNCH_DATA_PARAMETERS and val !=...
[ "def", "process_params", "(", "self", ",", "params", ")", ":", "for", "key", ",", "val", "in", "params", ".", "items", "(", ")", ":", "if", "key", "in", "LAUNCH_DATA_PARAMETERS", "and", "val", "!=", "'None'", ":", "if", "key", "==", "'roles'", ":", "...
Populates the launch data from a dictionary. Only cares about keys in the LAUNCH_DATA_PARAMETERS list, or that start with 'custom_' or 'ext_'.
[ "Populates", "the", "launch", "data", "from", "a", "dictionary", ".", "Only", "cares", "about", "keys", "in", "the", "LAUNCH_DATA_PARAMETERS", "list", "or", "that", "start", "with", "custom_", "or", "ext_", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/launch_params.py#L99-L119
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/ThingRunner.py
ThingRunner.run
def run(self, background=False): """Runs `on_startup`, `main` and `on_shutdown`, blocking until finished, unless background is set.""" if self.__bgthread: raise Exception('run has already been called (since last stop)') self.__shutdown.clear() if background: self....
python
def run(self, background=False): """Runs `on_startup`, `main` and `on_shutdown`, blocking until finished, unless background is set.""" if self.__bgthread: raise Exception('run has already been called (since last stop)') self.__shutdown.clear() if background: self....
[ "def", "run", "(", "self", ",", "background", "=", "False", ")", ":", "if", "self", ".", "__bgthread", ":", "raise", "Exception", "(", "'run has already been called (since last stop)'", ")", "self", ".", "__shutdown", ".", "clear", "(", ")", "if", "background"...
Runs `on_startup`, `main` and `on_shutdown`, blocking until finished, unless background is set.
[ "Runs", "on_startup", "main", "and", "on_shutdown", "blocking", "until", "finished", "unless", "background", "is", "set", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/ThingRunner.py#L73-L83
train
edx/edx-django-utils
edx_django_utils/monitoring/middleware.py
MonitoringCustomMetricsMiddleware._batch_report
def _batch_report(cls, request): """ Report the collected custom metrics to New Relic. """ if not newrelic: return metrics_cache = cls._get_metrics_cache() try: newrelic.agent.add_custom_parameter('user_id', request.user.id) except Attribut...
python
def _batch_report(cls, request): """ Report the collected custom metrics to New Relic. """ if not newrelic: return metrics_cache = cls._get_metrics_cache() try: newrelic.agent.add_custom_parameter('user_id', request.user.id) except Attribut...
[ "def", "_batch_report", "(", "cls", ",", "request", ")", ":", "if", "not", "newrelic", ":", "return", "metrics_cache", "=", "cls", ".", "_get_metrics_cache", "(", ")", "try", ":", "newrelic", ".", "agent", ".", "add_custom_parameter", "(", "'user_id'", ",", ...
Report the collected custom metrics to New Relic.
[ "Report", "the", "collected", "custom", "metrics", "to", "New", "Relic", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L66-L78
train
edx/edx-django-utils
edx_django_utils/monitoring/middleware.py
MonitoringMemoryMiddleware.process_request
def process_request(self, request): """ Store memory data to log later. """ if self._is_enabled(): self._cache.set(self.guid_key, six.text_type(uuid4())) log_prefix = self._log_prefix(u"Before", request) self._cache.set(self.memory_data_key, self._memo...
python
def process_request(self, request): """ Store memory data to log later. """ if self._is_enabled(): self._cache.set(self.guid_key, six.text_type(uuid4())) log_prefix = self._log_prefix(u"Before", request) self._cache.set(self.memory_data_key, self._memo...
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_is_enabled", "(", ")", ":", "self", ".", "_cache", ".", "set", "(", "self", ".", "guid_key", ",", "six", ".", "text_type", "(", "uuid4", "(", ")", ")", ")", "log_...
Store memory data to log later.
[ "Store", "memory", "data", "to", "log", "later", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L115-L122
train
edx/edx-django-utils
edx_django_utils/monitoring/middleware.py
MonitoringMemoryMiddleware.process_response
def process_response(self, request, response): """ Logs memory data after processing response. """ if self._is_enabled(): log_prefix = self._log_prefix(u"After", request) new_memory_data = self._memory_data(log_prefix) log_prefix = self._log_prefix(u"...
python
def process_response(self, request, response): """ Logs memory data after processing response. """ if self._is_enabled(): log_prefix = self._log_prefix(u"After", request) new_memory_data = self._memory_data(log_prefix) log_prefix = self._log_prefix(u"...
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ")", ":", "if", "self", ".", "_is_enabled", "(", ")", ":", "log_prefix", "=", "self", ".", "_log_prefix", "(", "u\"After\"", ",", "request", ")", "new_memory_data", "=", "self", ".", ...
Logs memory data after processing response.
[ "Logs", "memory", "data", "after", "processing", "response", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L124-L136
train
edx/edx-django-utils
edx_django_utils/monitoring/middleware.py
MonitoringMemoryMiddleware._log_prefix
def _log_prefix(self, prefix, request): """ Returns a formatted prefix for logging for the given request. """ # After a celery task runs, the request cache is cleared. So if celery # tasks are running synchronously (CELERY_ALWAYS _EAGER), "guid_key" # will no longer be in...
python
def _log_prefix(self, prefix, request): """ Returns a formatted prefix for logging for the given request. """ # After a celery task runs, the request cache is cleared. So if celery # tasks are running synchronously (CELERY_ALWAYS _EAGER), "guid_key" # will no longer be in...
[ "def", "_log_prefix", "(", "self", ",", "prefix", ",", "request", ")", ":", "cached_guid_response", "=", "self", ".", "_cache", ".", "get_cached_response", "(", "self", ".", "guid_key", ")", "cached_guid", "=", "cached_guid_response", ".", "get_value_or_default", ...
Returns a formatted prefix for logging for the given request.
[ "Returns", "a", "formatted", "prefix", "for", "logging", "for", "the", "given", "request", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L145-L154
train
edx/edx-django-utils
edx_django_utils/monitoring/middleware.py
MonitoringMemoryMiddleware._memory_data
def _memory_data(self, log_prefix): """ Returns a dict with information for current memory utilization. Uses log_prefix in log statements. """ machine_data = psutil.virtual_memory() process = psutil.Process() process_data = { 'memory_info': process.ge...
python
def _memory_data(self, log_prefix): """ Returns a dict with information for current memory utilization. Uses log_prefix in log statements. """ machine_data = psutil.virtual_memory() process = psutil.Process() process_data = { 'memory_info': process.ge...
[ "def", "_memory_data", "(", "self", ",", "log_prefix", ")", ":", "machine_data", "=", "psutil", ".", "virtual_memory", "(", ")", "process", "=", "psutil", ".", "Process", "(", ")", "process_data", "=", "{", "'memory_info'", ":", "process", ".", "get_memory_i...
Returns a dict with information for current memory utilization. Uses log_prefix in log statements.
[ "Returns", "a", "dict", "with", "information", "for", "current", "memory", "utilization", ".", "Uses", "log_prefix", "in", "log", "statements", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L156-L175
train
edx/edx-django-utils
edx_django_utils/monitoring/middleware.py
MonitoringMemoryMiddleware._log_diff_memory_data
def _log_diff_memory_data(self, prefix, new_memory_data, old_memory_data): """ Computes and logs the difference in memory utilization between the given old and new memory data. """ def _vmem_used(memory_data): return memory_data['machine_data'].used def _proc...
python
def _log_diff_memory_data(self, prefix, new_memory_data, old_memory_data): """ Computes and logs the difference in memory utilization between the given old and new memory data. """ def _vmem_used(memory_data): return memory_data['machine_data'].used def _proc...
[ "def", "_log_diff_memory_data", "(", "self", ",", "prefix", ",", "new_memory_data", ",", "old_memory_data", ")", ":", "def", "_vmem_used", "(", "memory_data", ")", ":", "return", "memory_data", "[", "'machine_data'", "]", ".", "used", "def", "_process_mem_percent"...
Computes and logs the difference in memory utilization between the given old and new memory data.
[ "Computes", "and", "logs", "the", "difference", "in", "memory", "utilization", "between", "the", "given", "old", "and", "new", "memory", "data", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L177-L202
train
edx/edx-django-utils
edx_django_utils/cache/utils.py
TieredCache.set_all_tiers
def set_all_tiers(key, value, django_cache_timeout=DEFAULT_TIMEOUT): """ Caches the value for the provided key in both the request cache and the django cache. Args: key (string) value (object) django_cache_timeout (int): (Optional) Timeout used to det...
python
def set_all_tiers(key, value, django_cache_timeout=DEFAULT_TIMEOUT): """ Caches the value for the provided key in both the request cache and the django cache. Args: key (string) value (object) django_cache_timeout (int): (Optional) Timeout used to det...
[ "def", "set_all_tiers", "(", "key", ",", "value", ",", "django_cache_timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "DEFAULT_REQUEST_CACHE", ".", "set", "(", "key", ",", "value", ")", "django_cache", ".", "set", "(", "key", ",", "value", ",", "django_cache_timeou...
Caches the value for the provided key in both the request cache and the django cache. Args: key (string) value (object) django_cache_timeout (int): (Optional) Timeout used to determine if and for how long to cache in the django cache. A timeout of ...
[ "Caches", "the", "value", "for", "the", "provided", "key", "in", "both", "the", "request", "cache", "and", "the", "django", "cache", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L172-L187
train
edx/edx-django-utils
edx_django_utils/cache/utils.py
TieredCache._get_cached_response_from_django_cache
def _get_cached_response_from_django_cache(key): """ Retrieves a CachedResponse for the given key from the django cache. If the request was set to force cache misses, then this will always return a cache miss response. Args: key (string) Returns: ...
python
def _get_cached_response_from_django_cache(key): """ Retrieves a CachedResponse for the given key from the django cache. If the request was set to force cache misses, then this will always return a cache miss response. Args: key (string) Returns: ...
[ "def", "_get_cached_response_from_django_cache", "(", "key", ")", ":", "if", "TieredCache", ".", "_should_force_django_cache_miss", "(", ")", ":", "return", "CachedResponse", "(", "is_found", "=", "False", ",", "key", "=", "key", ",", "value", "=", "None", ")", ...
Retrieves a CachedResponse for the given key from the django cache. If the request was set to force cache misses, then this will always return a cache miss response. Args: key (string) Returns: A CachedResponse with is_found status and value.
[ "Retrieves", "a", "CachedResponse", "for", "the", "given", "key", "from", "the", "django", "cache", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L218-L237
train
edx/edx-django-utils
edx_django_utils/cache/utils.py
TieredCache._set_request_cache_if_django_cache_hit
def _set_request_cache_if_django_cache_hit(key, django_cached_response): """ Sets the value in the request cache if the django cached response was a hit. Args: key (string) django_cached_response (CachedResponse) """ if django_cached_response.is_found: ...
python
def _set_request_cache_if_django_cache_hit(key, django_cached_response): """ Sets the value in the request cache if the django cached response was a hit. Args: key (string) django_cached_response (CachedResponse) """ if django_cached_response.is_found: ...
[ "def", "_set_request_cache_if_django_cache_hit", "(", "key", ",", "django_cached_response", ")", ":", "if", "django_cached_response", ".", "is_found", ":", "DEFAULT_REQUEST_CACHE", ".", "set", "(", "key", ",", "django_cached_response", ".", "value", ")" ]
Sets the value in the request cache if the django cached response was a hit. Args: key (string) django_cached_response (CachedResponse)
[ "Sets", "the", "value", "in", "the", "request", "cache", "if", "the", "django", "cached", "response", "was", "a", "hit", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L240-L250
train
edx/edx-django-utils
edx_django_utils/cache/utils.py
TieredCache._get_and_set_force_cache_miss
def _get_and_set_force_cache_miss(request): """ Gets value for request query parameter FORCE_CACHE_MISS and sets it in the default request cache. This functionality is only available for staff. Example: http://clobert.com/api/v1/resource?force_cache_miss=true ...
python
def _get_and_set_force_cache_miss(request): """ Gets value for request query parameter FORCE_CACHE_MISS and sets it in the default request cache. This functionality is only available for staff. Example: http://clobert.com/api/v1/resource?force_cache_miss=true ...
[ "def", "_get_and_set_force_cache_miss", "(", "request", ")", ":", "if", "not", "(", "request", ".", "user", "and", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_staff", ")", ":", "force_cache_miss", "=", "False", "else", ...
Gets value for request query parameter FORCE_CACHE_MISS and sets it in the default request cache. This functionality is only available for staff. Example: http://clobert.com/api/v1/resource?force_cache_miss=true
[ "Gets", "value", "for", "request", "query", "parameter", "FORCE_CACHE_MISS", "and", "sets", "it", "in", "the", "default", "request", "cache", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L253-L268
train
edx/edx-django-utils
edx_django_utils/cache/utils.py
TieredCache._should_force_django_cache_miss
def _should_force_django_cache_miss(cls): """ Returns True if the tiered cache should force a cache miss for the django cache, and False otherwise. """ cached_response = DEFAULT_REQUEST_CACHE.get_cached_response(SHOULD_FORCE_CACHE_MISS_KEY) return False if not cached_res...
python
def _should_force_django_cache_miss(cls): """ Returns True if the tiered cache should force a cache miss for the django cache, and False otherwise. """ cached_response = DEFAULT_REQUEST_CACHE.get_cached_response(SHOULD_FORCE_CACHE_MISS_KEY) return False if not cached_res...
[ "def", "_should_force_django_cache_miss", "(", "cls", ")", ":", "cached_response", "=", "DEFAULT_REQUEST_CACHE", ".", "get_cached_response", "(", "SHOULD_FORCE_CACHE_MISS_KEY", ")", "return", "False", "if", "not", "cached_response", ".", "is_found", "else", "cached_respon...
Returns True if the tiered cache should force a cache miss for the django cache, and False otherwise.
[ "Returns", "True", "if", "the", "tiered", "cache", "should", "force", "a", "cache", "miss", "for", "the", "django", "cache", "and", "False", "otherwise", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L271-L278
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Validation.py
Validation.check_convert_string
def check_convert_string(obj, name=None, no_leading_trailing_whitespace=True, no_whitespace=False, no_newline=True, whole_word=False, min_len=1, m...
python
def check_convert_string(obj, name=None, no_leading_trailing_whitespace=True, no_whitespace=False, no_newline=True, whole_word=False, min_len=1, m...
[ "def", "check_convert_string", "(", "obj", ",", "name", "=", "None", ",", "no_leading_trailing_whitespace", "=", "True", ",", "no_whitespace", "=", "False", ",", "no_newline", "=", "True", ",", "whole_word", "=", "False", ",", "min_len", "=", "1", ",", "max_...
Ensures the provided object can be interpreted as a unicode string, optionally with additional restrictions imposed. By default this means a non-zero length string which does not begin or end in whitespace.
[ "Ensures", "the", "provided", "object", "can", "be", "interpreted", "as", "a", "unicode", "string", "optionally", "with", "additional", "restrictions", "imposed", ".", "By", "default", "this", "means", "a", "non", "-", "zero", "length", "string", "which", "doe...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Validation.py#L66-L93
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Validation.py
Validation.__valid_url
def __valid_url(cls, url): """Expects input to already be a valid string""" bits = urlparse(url) return ((bits.scheme == "http" or bits.scheme == "https") and _PATTERN_URL_PART.match(bits.netloc) and _PATTERN_URL_PART.match(bits.path))
python
def __valid_url(cls, url): """Expects input to already be a valid string""" bits = urlparse(url) return ((bits.scheme == "http" or bits.scheme == "https") and _PATTERN_URL_PART.match(bits.netloc) and _PATTERN_URL_PART.match(bits.path))
[ "def", "__valid_url", "(", "cls", ",", "url", ")", ":", "bits", "=", "urlparse", "(", "url", ")", "return", "(", "(", "bits", ".", "scheme", "==", "\"http\"", "or", "bits", ".", "scheme", "==", "\"https\"", ")", "and", "_PATTERN_URL_PART", ".", "match"...
Expects input to already be a valid string
[ "Expects", "input", "to", "already", "be", "a", "valid", "string" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Validation.py#L231-L236
train
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Validation.py
Validation.location_check
def location_check(lat, lon): """For use by Core client wrappers""" if not (isinstance(lat, number_types) and -90 <= lat <= 90): raise ValueError("Latitude: '{latitude}' invalid".format(latitude=lat)) if not (isinstance(lon, number_types) and -180 <= lon <= 180): raise V...
python
def location_check(lat, lon): """For use by Core client wrappers""" if not (isinstance(lat, number_types) and -90 <= lat <= 90): raise ValueError("Latitude: '{latitude}' invalid".format(latitude=lat)) if not (isinstance(lon, number_types) and -180 <= lon <= 180): raise V...
[ "def", "location_check", "(", "lat", ",", "lon", ")", ":", "if", "not", "(", "isinstance", "(", "lat", ",", "number_types", ")", "and", "-", "90", "<=", "lat", "<=", "90", ")", ":", "raise", "ValueError", "(", "\"Latitude: '{latitude}' invalid\"", ".", "...
For use by Core client wrappers
[ "For", "use", "by", "Core", "client", "wrappers" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Validation.py#L239-L245
train