/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pyserver/pcilib_api_server.py

  • Committer: Suren A. Chilingaryan
  • Date: 2016-03-04 18:30:43 UTC
  • mfrom: (346.1.39 pcitool)
  • Revision ID: csa@suren.me-20160304183043-mjf6xvyermjh5olg
Integrate last part of Python code from Vasiliy Chernov

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
            lock_id = str(data.get('lock_id'))
262
262
            
263
263
            try:
264
 
               s.pcilib.lock(lock_id)
 
264
               s.pcilib.lock_persistent(lock_id)
265
265
            except Exception as e:
266
266
               s.error(str(e), data) 
267
267
               return
280
280
               
281
281
            #parse command arguments and convert them to string
282
282
            lock_id = str(data.get('lock_id'))
 
283
            persistent = bool(data.get('persistent', False))
283
284
            
284
285
            try:
285
 
               s.pcilib.try_lock(lock_id)
 
286
               if persistent:
 
287
                  s.pcilib.try_lock_persistent(lock_id)
 
288
               else:
 
289
                  s.pcilib.try_lock(lock_id)
286
290
            except Exception as e:
287
291
               s.error(str(e), data) 
288
292
               return
301
305
               
302
306
            #parse command arguments and convert them to string
303
307
            lock_id = str(data.get('lock_id'))
 
308
            persistent = bool(data.get('persistent', False))
304
309
            
305
310
            try:
306
 
               s.pcilib.unlock(lock_id)
 
311
               if persistent:
 
312
                  s.pcilib.unlock_persistent(lock_id)
 
313
               else:
 
314
                  s.pcilib.unlock(lock_id)
307
315
            except Exception as e:
308
316
               s.error(str(e), data) 
309
317
               return
398
406
      '  Server receive commands via http GET with json packet.\n'
399
407
      '  content-type should have value "application/json"\n'
400
408
      '  Server could handle only commands. to set command, you\n'
401
 
      '  should specify field "command" in packet with command name\n'
 
409
      '  should specify field "command" in packet with command name\n\n'
 
410
      '  If you use html server, you should call commands via GET request\n'
 
411
      '  like http://<server_host>:<port>/json/<command>?<arg1>=<arg_val1>&... \n'
 
412
      '\n'
402
413
      '  List of commands:\n'
403
414
      '\n'
404
415
      '  command: help - Get help. This will return usage\n'
405
416
      '\n'
406
417
      
407
 
      '  command: open - Opens context of device. It will be reopened if already open.\n'
408
 
      '    required fields\n'
409
 
      '      device:       - path to the device file [/dev/fpga0]\n'
410
 
      '    optional fields\n'
411
 
      '      model:       - specifies the model of hardware, autodetected if doesnt exists\n'
412
 
      '\n'
 
418
      #'  command: open - Opens context of device. It will be reopened if already open.\n'
 
419
      #'    required fields\n'
 
420
      #'      device:       - path to the device file [/dev/fpga0]\n'
 
421
      #'    optional fields\n'
 
422
      #'      model:       - specifies the model of hardware, autodetected if doesnt exists\n'
 
423
      #'\n'
413
424
      
414
425
      '  command: get_registers_list - Returns the list of registers provided by the hardware model.\n'
415
426
      '    optional fields\n'
462
473
      '  command: try_lock - this function will try to take a lock for the mutex pointed by \n'
463
474
      '                    lockfunction to acquire a lock, but that returns immediatly if the\n'
464
475
      '                    lock can\'t be acquired on first try\n'
 
476
      '    required fields\n'
465
477
      '      lock_id: - lock id\n'
 
478
      '    optional fields\n'
 
479
      '      persistent: - 1 - lock is persistent, 0 othervise (default: 0)\n'
466
480
      '\n'
467
481
      
468
482
      '  command: unlock - this function unlocks the lock.\n'
469
483
      '    required fields\n'
470
484
      '      lock_id: - lock id\n'
 
485
      '    optional fields\n'
 
486
      '      persistent: - 1 - lock is persistent, 0 othervise (default: 0)\n'
471
487
      '\n'
472
488
      
473
489
      '  command: get_scripts_list - Get aviable scripts with description\n'