Commit 743e9c6e00c43c989eea6811ceafef5f86883c00

Authored by Jeremy
1 parent 0afcefa9
Exists in master and in 1 other branch dev

Update user simulator

simulators/config/s1.json deleted
... ... @@ -1,3 +0,0 @@
1   -{
2   - "Request" : {"id" : 1, "time" : 4}
3   -}
simulators/config/user/conf.json 0 โ†’ 100644
... ... @@ -0,0 +1,14 @@
  1 +[
  2 + {
  3 + "id" : 1,
  4 + "time": 4
  5 + },
  6 + {
  7 + "id" : 2,
  8 + "time": 4
  9 + },
  10 + {
  11 + "id" : 3,
  12 + "time": 4
  13 + }
  14 +]
... ...
simulators/config/user/conf1.json 0 โ†’ 100644
simulators/config/user/conf2.json 0 โ†’ 100644
simulators/fixtures/simulation.json
1 1 [
2   -{
  2 + {
  3 + "model": "common.userlevel",
  4 + "pk": 42,
  5 + "fields": {
  6 + "name": "Simulation",
  7 + "desc": "",
  8 + "priority": 0,
  9 + "quota": 9999.0
  10 + }
  11 + },
  12 + {
  13 + "model": "auth.user",
  14 + "pk": 42,
  15 + "fields": {
  16 + "password": "pbkdf2_sha256$24000$HRial3QUfrlz$bVuEzQaXthOd9GZVXd2449LDEF8EMQure69nA/Hu7qQ=",
  17 + "last_login": "2016-08-10T15:16:42.327Z",
  18 + "is_superuser": true,
  19 + "username": "simulator",
  20 + "first_name": "",
  21 + "last_name": "",
  22 + "email": "simulator@example.com",
  23 + "is_staff": true,
  24 + "is_active": true,
  25 + "date_joined": "2016-08-10T15:15:58.481Z",
  26 + "groups": [],
  27 + "user_permissions": []
  28 + }
  29 + },
  30 + {
  31 + "model": "common.pyrosuser",
  32 + "pk": 42,
  33 + "fields": {
  34 + "user": 42,
  35 + "country": 1,
  36 + "user_level": 42,
  37 + "desc": "",
  38 + "created": "2016-08-11T07:54:05.627Z",
  39 + "updated": "2016-08-11T07:54:05.627Z",
  40 + "tel": "",
  41 + "address": "",
  42 + "laboratory": "IRAP",
  43 + "last_connect": null,
  44 + "cur_connect": null,
  45 + "putvalid_beg": null,
  46 + "putvalid_end": null,
  47 + "acqvalid_beg": "",
  48 + "acqvalid_end": "",
  49 + "quota": 9999.0,
  50 + "quota_rea": null,
  51 + "u_priority": 1,
  52 + "p_priority": 1,
  53 + "dir_level": null,
  54 + "can_del_void_req": false
  55 + }
  56 + },
  57 + {
  58 + "model": "common.scientificprogram",
  59 + "pk": 42,
  60 + "fields": {
  61 + "name": "SIMULATION",
  62 + "desc": "",
  63 + "quota": 9999.0,
  64 + "priority": 0,
  65 + "pyros_users": [
  66 + 42
  67 + ]
  68 + }
  69 + },
3 70  
4   -}
  71 + {
  72 + "model": "common.request",
  73 + "pk":1,
  74 + "fields" : {
  75 + "name" : "Request Simulation 1",
  76 + "desc" : "Request description 1",
  77 + "created" : "2016-11-18T16:44:30Z",
  78 + "updated" : "2016-11-18T16:44:30Z",
  79 + "is_alert" : 0,
  80 + "target_type" : "test",
  81 + "status" : "test",
  82 + "autodeposit" : 0,
  83 + "checkpoint" : "test",
  84 + "flag" : "test",
  85 + "complete" : 0,
  86 + "submitted" : 0,
  87 + "pyros_user_id" : 42,
  88 + "scientific_program_id" : 42
  89 + }
  90 + },
  91 + {
  92 + "model": "common.request",
  93 + "pk":2,
  94 + "fields" : {
  95 + "name" : "Request Simulation 2",
  96 + "desc" : "Request description 2",
  97 + "created" : "2016-11-18T16:44:30Z",
  98 + "updated" : "2016-11-18T16:44:30Z",
  99 + "is_alert" : 0,
  100 + "target_type" : "test",
  101 + "status" : "test",
  102 + "autodeposit" : 0,
  103 + "checkpoint" : "test",
  104 + "flag" : "test",
  105 + "complete" : 0,
  106 + "submitted" : 0,
  107 + "pyros_user_id" : 42,
  108 + "scientific_program_id" : 42
  109 + }
  110 + },
  111 + {
  112 + "model": "common.request",
  113 + "pk":3,
  114 + "fields" : {
  115 + "name" : "Request Simulation 3",
  116 + "desc" : "Request description 3",
  117 + "created" : "2016-11-18T16:44:30Z",
  118 + "updated" : "2016-11-18T16:44:30Z",
  119 + "is_alert" : 0,
  120 + "target_type" : "test",
  121 + "status" : "test",
  122 + "autodeposit" : 0,
  123 + "checkpoint" : "test",
  124 + "flag" : "test",
  125 + "complete" : 0,
  126 + "submitted" : 0,
  127 + "pyros_user_id" : 42,
  128 + "scientific_program_id" : 42
  129 + }
  130 + },
  131 + {
  132 + "model": "common.sequence",
  133 + "pk": 1,
  134 + "fields": {
  135 + "name" : "Sequence 1",
  136 + "desc" : "Sequence 1",
  137 + "created" : "2016-11-18T16:44:30Z",
  138 + "updated" : "2016-11-18T16:44:30Z",
  139 + "is_alert" : 0,
  140 + "status" : "Sequence 1",
  141 + "target_coords" : "100,100",
  142 + "with_drift" : 0,
  143 + "priority" : 1,
  144 + "analysis_method" : "DARK",
  145 + "moon_min" : 0,
  146 + "alt_min" : 0,
  147 + "type" : "test",
  148 + "img_current" : 0,
  149 + "img_total" : 5,
  150 + "not_obs" : 0,
  151 + "obsolete" : 0,
  152 + "processing" : 0,
  153 + "flag" : "flag",
  154 + "jd1" : 5.1,
  155 + "jd2" : 10.2,
  156 + "t_prefered" : 5.1,
  157 + "duration" : 5.1,
  158 + "overhead" : 0,
  159 + "ra" : 56,
  160 + "dec" : 34,
  161 + "request_id" : 1
  162 + }
  163 + },
  164 + {
  165 + "model": "common.sequence",
  166 + "pk": 2,
  167 + "fields": {
  168 + "name" : "Sequence 2",
  169 + "desc" : "Sequence 2",
  170 + "created" : "2016-11-18T16:44:30Z",
  171 + "updated" : "2016-11-18T16:44:30Z",
  172 + "is_alert" : 0,
  173 + "status" : "Sequence 2",
  174 + "target_coords" : "200,200",
  175 + "with_drift" : 0,
  176 + "priority" : 1,
  177 + "analysis_method" : "DARK",
  178 + "moon_min" : 0,
  179 + "alt_min" : 0,
  180 + "type" : "test",
  181 + "img_current" : 0,
  182 + "img_total" : 2,
  183 + "not_obs" : 0,
  184 + "obsolete" : 0,
  185 + "processing" : 0,
  186 + "flag" : "flag",
  187 + "jd1" : 13.1,
  188 + "jd2" : 18.2,
  189 + "t_prefered" : 13.1,
  190 + "duration" : 5.1,
  191 + "overhead" : 0,
  192 + "ra" : 56,
  193 + "dec" : 34,
  194 + "request_id" : 1
  195 + }
  196 + },
  197 + {
  198 + "model": "common.sequence",
  199 + "pk": 3,
  200 + "fields": {
  201 + "name" : "Sequence 3",
  202 + "desc" : "Sequence 3",
  203 + "created" : "2016-11-18T16:44:30Z",
  204 + "updated" : "2016-11-18T16:44:30Z",
  205 + "is_alert" : 0,
  206 + "status" : "Sequence 3",
  207 + "target_coords" : "200,200",
  208 + "with_drift" : 0,
  209 + "priority" : 1,
  210 + "analysis_method" : "DARK",
  211 + "moon_min" : 0,
  212 + "alt_min" : 0,
  213 + "type" : "test",
  214 + "img_current" : 0,
  215 + "img_total" : 2,
  216 + "not_obs" : 0,
  217 + "obsolete" : 0,
  218 + "processing" : 0,
  219 + "flag" : "flag",
  220 + "jd1" : 13.1,
  221 + "jd2" : 18.2,
  222 + "t_prefered" : 13.1,
  223 + "duration" : 5.1,
  224 + "overhead" : 0,
  225 + "ra" : 56,
  226 + "dec" : 34,
  227 + "request_id" : 2
  228 + }
  229 + },
  230 + {
  231 + "model": "common.sequence",
  232 + "pk": 4,
  233 + "fields": {
  234 + "name" : "Sequence 4",
  235 + "desc" : "Sequence 4",
  236 + "created" : "2016-11-18T16:44:30Z",
  237 + "updated" : "2016-11-18T16:44:30Z",
  238 + "is_alert" : 0,
  239 + "status" : "Sequence 4",
  240 + "target_coords" : "200,200",
  241 + "with_drift" : 0,
  242 + "priority" : 1,
  243 + "analysis_method" : "DARK",
  244 + "moon_min" : 0,
  245 + "alt_min" : 0,
  246 + "type" : "test",
  247 + "img_current" : 0,
  248 + "img_total" : 2,
  249 + "not_obs" : 0,
  250 + "obsolete" : 0,
  251 + "processing" : 0,
  252 + "flag" : "flag",
  253 + "jd1" : 13.1,
  254 + "jd2" : 18.2,
  255 + "t_prefered" : 13.1,
  256 + "duration" : 5.1,
  257 + "overhead" : 0,
  258 + "ra" : 56,
  259 + "dec" : 34,
  260 + "request_id" : 3
  261 + }
  262 + },
  263 + {
  264 + "model" : "common.album",
  265 + "pk": 1,
  266 + "fields": {
  267 + "name": "album 1",
  268 + "desc" : "album 1",
  269 + "created" : "2016-11-18T16:44:30Z",
  270 + "updated" : "2016-11-18T16:44:30Z",
  271 + "complete" : 0,
  272 + "detector_id" : 1,
  273 + "sequence_id" : 1
  274 + }
  275 + },
  276 + {
  277 + "model" : "common.album",
  278 + "pk": 2,
  279 + "fields": {
  280 + "name": "album 2",
  281 + "desc" : "album 2",
  282 + "created" : "2016-11-18T16:44:30Z",
  283 + "updated" : "2016-11-18T16:44:30Z",
  284 + "complete" : 0,
  285 + "detector_id" : 1,
  286 + "sequence_id" : 2
  287 + }
  288 + },
  289 + {
  290 + "model" : "common.album",
  291 + "pk": 3,
  292 + "fields": {
  293 + "name": "album 3",
  294 + "desc" : "album 3",
  295 + "created" : "2016-11-18T16:44:30Z",
  296 + "updated" : "2016-11-18T16:44:30Z",
  297 + "complete" : 0,
  298 + "detector_id" : 2,
  299 + "sequence_id" : 2
  300 + }
  301 + },
  302 + {
  303 + "model" : "common.album",
  304 + "pk": 4,
  305 + "fields": {
  306 + "name": "album 4",
  307 + "desc" : "album 4",
  308 + "created" : "2016-11-18T16:44:30Z",
  309 + "updated" : "2016-11-18T16:44:30Z",
  310 + "complete" : 0,
  311 + "detector_id" : 1,
  312 + "sequence_id" : 3
  313 + }
  314 + },
  315 + {
  316 + "model" : "common.album",
  317 + "pk": 5,
  318 + "fields": {
  319 + "name": "album 5",
  320 + "desc" : "album 5",
  321 + "created" : "2016-11-18T16:44:30Z",
  322 + "updated" : "2016-11-18T16:44:30Z",
  323 + "complete" : 0,
  324 + "detector_id" : 1,
  325 + "sequence_id" : 4
  326 + }
  327 + },
  328 + {
  329 + "model" : "common.plan",
  330 + "pk" : 1,
  331 + "fields": {
  332 + "name" : "plan 1",
  333 + "desc" : "plan 1",
  334 + "created" : "2016-11-18T16:44:30Z",
  335 + "updated" : "2016-11-18T16:44:30Z",
  336 + "duration" : 10,
  337 + "position" : "100,100",
  338 + "exposure_time" : 10,
  339 + "nb_images" : 5,
  340 + "dithering" : 0,
  341 + "complete" : 0,
  342 + "album_id" : 1,
  343 + "filter_id" : 1
  344 + }
  345 + },
  346 + {
  347 + "model" : "common.plan",
  348 + "pk" : 2,
  349 + "fields": {
  350 + "name" : "plan 2",
  351 + "desc" : "plan 2",
  352 + "created" : "2016-11-18T16:44:30Z",
  353 + "updated" : "2016-11-18T16:44:30Z",
  354 + "duration" : 10,
  355 + "position" : "200,200",
  356 + "exposure_time" : 10,
  357 + "nb_images" : 5,
  358 + "dithering" : 0,
  359 + "complete" : 0,
  360 + "album_id" : 1,
  361 + "filter_id" : 2
  362 + }
  363 + },
  364 + {
  365 + "model" : "common.plan",
  366 + "pk" : 3,
  367 + "fields": {
  368 + "name" : "plan 1",
  369 + "desc" : "plan 1",
  370 + "created" : "2016-11-18T16:44:30Z",
  371 + "updated" : "2016-11-18T16:44:30Z",
  372 + "duration" : 10,
  373 + "position" : "200,200",
  374 + "exposure_time" : 10,
  375 + "nb_images" : 5,
  376 + "dithering" : 0,
  377 + "complete" : 0,
  378 + "album_id" : 2,
  379 + "filter_id" : 3
  380 + }
  381 + },
  382 + {
  383 + "model" : "common.plan",
  384 + "pk" : 4,
  385 + "fields": {
  386 + "name" : "plan 4",
  387 + "desc" : "plan 4",
  388 + "created" : "2016-11-18T16:44:30Z",
  389 + "updated" : "2016-11-18T16:44:30Z",
  390 + "duration" : 10,
  391 + "position" : "100,100",
  392 + "exposure_time" : 10,
  393 + "nb_images" : 5,
  394 + "dithering" : 0,
  395 + "complete" : 0,
  396 + "album_id" : 3,
  397 + "filter_id" : 1
  398 + }
  399 + },
  400 + {
  401 + "model" : "common.plan",
  402 + "pk" : 5,
  403 + "fields": {
  404 + "name" : "plan 5",
  405 + "desc" : "plan 5",
  406 + "created" : "2016-11-18T16:44:30Z",
  407 + "updated" : "2016-11-18T16:44:30Z",
  408 + "duration" : 10,
  409 + "position" : "200,200",
  410 + "exposure_time" : 10,
  411 + "nb_images" : 5,
  412 + "dithering" : 0,
  413 + "complete" : 0,
  414 + "album_id" : 4,
  415 + "filter_id" : 2
  416 + }
  417 + },
  418 + {
  419 + "model" : "common.plan",
  420 + "pk" : 6,
  421 + "fields": {
  422 + "name" : "plan 6",
  423 + "desc" : "plan 6",
  424 + "created" : "2016-11-18T16:44:30Z",
  425 + "updated" : "2016-11-18T16:44:30Z",
  426 + "duration" : 10,
  427 + "position" : "200,200",
  428 + "exposure_time" : 10,
  429 + "nb_images" : 5,
  430 + "dithering" : 0,
  431 + "complete" : 0,
  432 + "album_id" : 5,
  433 + "filter_id" : 1
  434 + }
  435 + }
5 436 ]
... ...
simulators/scripts/simulator_launch.sh
... ... @@ -3,10 +3,15 @@
3 3 SIM_FIXTURES="../simulators/fixtures/"
4 4 SIM_PATH="../simulators/"
5 5  
  6 +cd "$SIM_PATH"fixtures/
6 7 echo -n "Existing simulations : "
7   -ls "$SIM_FIXTURES"
8   -echo -n "Enter which simulation you want to launch : "
9   -read -r line
  8 +ls
  9 +read -e -p "Enter which simulation you want to launch : " line
  10 +cd - > /dev/null
  11 +
  12 +if [[ $line != *[!\ ]* ]]; then
  13 + line="simulation.json"
  14 +fi
10 15  
11 16 if [ ! -f "$SIM_FIXTURES"/"$line" ]; then
12 17 echo "This simulation doesn't exist"
... ...
src/userSimulator/tasks.py
... ... @@ -12,21 +12,31 @@ import json
12 12 log = l.setupLogger("simulator", "simulator")
13 13  
14 14 SIMULATOR_VALUE = None
  15 +CONF_PATH = "%s/../simulators/config/user/"%settings.BASE_DIR
15 16  
16 17 class simulator(Task):
17   - shouldClean = False
18   -
19   - def loadJson(self, path):
20   - json_data = open(path, 'r')
21   - # if (not json_data.is_open()):
  18 + shouldClean = True
  19 + conf_file = CONF_PATH + SIMULATOR_VALUE
  20 + array_requests = []
  21 +
  22 + def loadJson(self):
  23 + self.conf_file = self.conf_file.replace("simulation", "conf")
  24 + try:
  25 + json_data = open(self.conf_file, 'r')
  26 + except IOError:
  27 + log.error("File %s does not exist"%("SIMULATOR_VALUE".replace("simulation", "conf")))
  28 + return (1)
  29 + self.json_data = json.loads(json_data.read())
  30 + return (0)
22 31  
23 32 def run(self):
24   - print('-------------------------------')
25   - print(SIMULATOR_VALUE)
  33 + if (self.loadJson()):
  34 + return (0)
  35 + for dic in self.json_data:
  36 + self.array_requests.append(Request.objects.get(pk=dic["id"]))
  37 + for req in self.array_requests:
  38 + print(req.name)
26 39  
27   - # END OF EXECTUION (KILLING WEB SERVER AN PROCESS)
28   - if (self.shouldClean == True):
29   - os.system("%s/../pyrosrun.sh kill_simulation"%settings.BASE_DIR)
30 40  
31 41 if __name__ == "__main__":
32 42 sim = simulator(Task)
... ...