Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
def method_add_device():
    devices.add_device()