def load_devices(ref='all'): req = base_url + "request=getstatus&ref={}".format(ref) json_data = do_communication(req) devices_json = json_data.get('Devices') for dev in devices_json: devices.add_device(dev)
def start_selected_task(nameOfTask): """ Starts the selected task :param nameOfTask: The name of the user selected task :return: None """ NAME = 0 PASSWORD = 1 if nameOfTask == "Change password": # Start the change password task password.change_password(users.currentUser) elif nameOfTask == "Add group": # Start add group task newGroup = groups.add_group() groups.add_tasks(newGroup) elif nameOfTask == "Add user": # Start add user task newUserInfo = users.add_user() if newUserInfo is not None: users.add_user_to_group(newUserInfo[NAME], newUserInfo[PASSWORD]) else: # The user canceled pass elif nameOfTask == "Reset user password": # Start reset user password password.reset_user_password() elif nameOfTask == "Remove user": # Remove user users.remove_user() elif nameOfTask == "Add Device": # Add device devices.add_device() elif nameOfTask == "Rename Device": # Rename device devices.rename_device() elif nameOfTask == "Remove Device": # Remove device devices.remove_device() else: easygui.msgbox( "Task: {0} has not been implemented.".format(nameOfTask)) return None
def apn(): if request.method == 'POST': device_token = request.values.get('deviceToken') api_token = request.headers.get('X-API-Token') if API_TOKEN is None: return abort(404) if device_token is None: return make_response(jsonify({ 'error': '`deviceToken` is required' }), 400) if api_token == API_TOKEN: row = devices.add_device(device_token) return jsonify({ 'result': row }) else: return make_response(jsonify({ 'error': 'Invalid API Token' }), 400) else: return abort(404)
def method_add_device(): devices.add_device()