File: tool.py

package info (click to toggle)
pmix 6.0.0%2Breally5.0.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 11,756 kB
  • sloc: ansic: 125,921; sh: 4,265; python: 2,530; makefile: 2,109; xml: 1,611; perl: 1,151; lex: 138
file content (32 lines) | stat: -rwxr-xr-x 1,018 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3

from pmix import *
from os import *
import time

def main():
    foo = PMIxTool()
    print("Testing PMIx Tool ", foo.get_version())
    # construct a session tmpdir
    uid = os.geteuid()
    gid = os.getegid()
    basename = os.path.basename(__file__)
    tmpdir = os.getenv('TMPDIR')
    sessiondir = os.path.join(tmpdir, basename + '.session.' + str(uid) + '.' + str(gid))
    info = [{'key':PMIX_LAUNCHER, 'value':True, 'val_type':PMIX_BOOL},
            {'key':PMIX_SERVER_TOOL_SUPPORT, 'value':True, 'val_type':PMIX_BOOL},
            {'key':PMIX_SERVER_TMPDIR, 'value':sessiondir, 'val_type':PMIX_STRING}]
    (my_result, myproc) = foo.init(info)
    if 0 != my_result:
        print("FAILED TO INIT", foo.error_string(my_result))
        exit(1)

    # construct an application to spawn
    app = {'cmd':'hostname', 'maxprocs':1}
    foo.spawn(None, [app])
    time.sleep(2.0)
    # finalize
    foo.finalize()
    print("Tool finalize complete")
if __name__ == '__main__':
    main()