from enum import IntEnum

ENCODING = "ascii"


class Error(IntEnum):
    SUCCESS = 0
    INVALID_ARGUMENT = 1


class Measure(IntEnum):
    OS_NAME = 0
    OS_KERNEL = 1
    TIME_START = 44
    TIME_STOP = 45
    TIME_ELAPSED_WALL_CLOCK_MS = 2
    TIME_ELAPSED_USER_MS = 3
    TIME_ELAPSED_SYSTEM_MS = 4
    CPU_USED_PROCESS_PERCENT = 5
    CPU_USED_SYSTEM_PERCENT = 6
    CPU_AVAILABLE_SYSTEM_CORES = 7
    CPU_ENERGY_SYSTEM_JOULES = 8
    CPU_FEATURES = 9
    CPU_FREQUENCY_MHZ = 10
    CPU_FREQUENCY_MIN_MHZ = 11
    CPU_FREQUENCY_MAX_MHZ = 12
    CPU_VENDOR_ID = 13
    CPU_BYTE_ORDER = 14
    CPU_ARCHITECTURE = 15
    CPU_MODEL_NAME = 16
    CPU_CORES_PER_SOCKET = 17
    CPU_THREADS_PER_CORE = 18
    CPU_CACHES = 19
    CPU_VIRTUALIZATION = 20
    RAM_USED_PROCESS_KB = 21
    RAM_USED_SYSTEM_MB = 22
    RAM_AVAILABLE_SYSTEM_MB = 23
    RAM_ENERGY_SYSTEM_JOULES = 24
    GPU_SUPPORTED = 25
    GPU_MODEL_NAME = 26
    GPU_AVAILABLE_SYSTEM_CORES = 27  # aka. GPU_NUM_CORES
    GPU_USED_PROCESS_PERCENT = 28
    GPU_USED_SYSTEM_PERCENT = 29
    GPU_VRAM_USED_PROCESS_MB = 30
    GPU_VRAM_USED_SYSTEM_MB = 31
    GPU_VRAM_AVAILABLE_SYSTEM_MB = 32
    GPU_ENERGY_SYSTEM_JOULES = 33
    GIT_IS_REPO = 34
    GIT_HASH = 35
    GIT_LAST_COMMIT_HASH = 36
    GIT_BRANCH = 37
    GIT_BRANCH_UPSTREAM = 38
    GIT_TAGS = 39
    GIT_REMOTE_ORIGIN = 40
    GIT_UNCOMMITTED_CHANGES = 41
    GIT_UNPUSHED_CHANGES = 42
    GIT_UNCHECKED_FILES = 43
    GIT_ROOT = 46
    GIT_ARCHIVE_PATH = 47
    PYTHON_VERSION = 1000
    PYTHON_EXECUTABLE = 1001
    PYTHON_ARGUMENTS = 1002
    PYTHON_MODULES = 1003
    PYTHON_INSTALLED_PACKAGES = 1004
    PYTHON_IS_INTERACTIVE = 1005
    PYTHON_SCRIPT_FILE_PATH = 1006
    # 1007 was used in previous versions of the library.
    PYTHON_NOTEBOOK_FILE_PATH = 1008
    # 1009 was used in previous versions of the library.
    PYTHON_CODE_ARCHIVE_PATH = 1010
    PYTHON_SCRIPT_FILE_PATH_IN_CODE_ARCHIVE = 1011
    PYTHON_NOTEBOOK_FILE_PATH_IN_CODE_ARCHIVE = 1012


INVALID_MEASURE = -1


ALL_MEASURES = set(Measure)


class Aggregation(IntEnum):
    NO = 1 << 0
    MAX = 1 << 1
    MIN = 1 << 2
    MEAN = 1 << 3


INVALID_AGGREGATION = -1


ALL_AGGREGATIONS = set(Aggregation)


class ResultType(IntEnum):
    STRING = 0
    INTEGER = 1
    FLOATING = 2
    BOOLEAN = 3
    WSTRING = 4
    STRING_LIST = STRING | 1 << 7
    INTEGER_LIST = INTEGER | 1 << 7
    FLOATING_LIST = FLOATING | 1 << 7
    BOOLEAN_LIST = BOOLEAN | 1 << 7
    WSTRING_LIST = WSTRING | 1 << 7


class LogLevel(IntEnum):
    TRACE = 0
    DEBUG = 1
    INFO = 2
    WARN = 3
    ERROR = 4
    CRITICAL = 5
