consts.py 2.8 KB
Newer Older
tlavocat's avatar
tlavocat committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import json

#constants
GETSPWE = "get spawn errors"
GETSPWN = "get spawn"
STOPMPI = "stop mpi bridge"
STRTMPI = "start mpi bridge"
PORT    = "port"
MPISEND = "mpi send"
MPICLN  = "mpi clean"
MPIDEPL = "mpi deploy communicator"
MPIREG  = "mpi register"
REG     = "register"
RANKS   = "ranks"
BULKR   = "bulk replic"
DEAD    = "dead node"
MYRANK  = "my rank"
BRIDGED = "bridge dead"
HEARTBTR= "heart beat reply"
HEARTBT = "heart beat"
SEQ     = "seq"
OPTIONS = "options"
STATUS  = "status"
STDERR  = "stderr"
STDOUT  = "stdout"
CALLBACK= "callback"
TERMNET = "terminate network"
TERMHIM = "terminate children"
DNETID  = "destination network"
DNODE   = "destination node"
SNETID  = "source network"
SNODE   = "source node"
RSHTABLE= "request table"
SHTABLE = "share table"
VISIBLTY= "visibility"
CREAT   = "creation"
SPANTR  = "spanning tree"
ACTION  = "action"
REPLIC  = "replicate"
INVJSON = "Invalid JSON"
MTNETWRK= "mpi trans network"
TNETWRK = "trans network"
TAKTUK  = "taktuk"
ACKQUIT = "ack-quit"
QUIT    = "quit"
ORDER   = "order"
WAITR   = "wait reduce"
NNUMBER = "network renumber"
NUPDATE = "network update"
SYNCHRO = "synchronize"
NETWORK = "network"
SPAWN   = "spawn"
INTERNAL= "internal"
RANK    = "rank"
INFOS   = "infos"
BR_EXEC = "broadcast exec"
EXECUTE = "execute"
MESSAGE = "message"
DEST    = "dest"
TARGET  = "target"
COMMAND = "command"
DATA    = "data"
FROM    = "from"
LENGTH  = "length"
CONTROL = "control"
ACK     = "ack"
TYPE    = "type"
LOG     = "log"
VALUE   = "value"
ID      = "id"

UINT32  = 4
TRUE    = "true"
FALSE   = "false"

# routing rules

PROTECTED = "protected"
PRIVATE   = "private"
PUBLIC    = "public"

# static JSON

DEMAND_INFOS   = json.dumps({TYPE:CONTROL,VALUE:INFOS});
QUIT_ORDER     = json.dumps({TYPE:ORDER,ORDER:QUIT});
ACK_QUIT_ORDER = json.dumps({TYPE:ORDER,ORDER:ACKQUIT});
HB             = json.dumps({TYPE:HEARTBT});
HBR            = json.dumps({TYPE:HEARTBTR});
REQUEST_TABLES = json.dumps({ACTION:RSHTABLE})

#parameters
encoding = "utf-8"
timeout  = 30
heartBeat= 30
MAXQ     = 500

#states
BOOSTRAP            = "bootstrap"
INIT                = "init"
INITd               = "initialized"
RUNING              = "running"
SICK                = "sick"
DONE                = "done"
ERROR               = "error"
TIMEOUT             = "timeout"
CANCELED            = "canceled"
TERMINAISON_PENDING = "terminaison pending"


class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
    WHITE = '\x1B[37m'

def bold(str) :
    return bcolors.BOLD+str+bcolors.ENDC

def blue(str) :
    return bold(bcolors.OKBLUE+str+bcolors.ENDC)

def green(str) :
    return bold(bcolors.OKGREEN+str+bcolors.ENDC)

def error(str) :
    return bold(bcolors.FAIL+str+bcolors.ENDC)