source: trunk/examples/ha_server.py @ 356

Last change on this file since 356 was 356, checked in by martijk, 6 years ago

python3 compatible print #26732

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2#
3# Author: Bas van der Vlies <basv@sara.nl>
4# Date  : 15 Apr 2009
5# Desc. : Usage of the High Availabilty functions in torque
6#
7# SVN info:
8# $Id: new_interface.py 74 2005-03-04 09:11:10Z bas $
9#
10#
11#
12import sys
13
14import pbs
15
16def method1():
17        pbs_server = pbs.pbs_default() 
18        if not pbs_server:
19                print("No default pbs server")
20                sys.exit(1)
21
22        con = pbs.pbs_connect(pbs_server)
23        if con == -1:
24                print("Default pbs server connection failed")
25                pbs_server = pbs.pbs_fbserver()
26                if not pbs_server:
27                        print("No pbs fallback server")
28                        sys.exit(1)
29                else:
30                        con = pbs.pbs_connect(pbs_server)
31                        if con == -1:
32                                print("pbs fallback server connection failed")
33                                sys.exit(1)
34
35        print("Connected to %s" %(pbs_server))
36
37def method2():
38        try:
39                server_list = pbs.pbs_get_server_list().split(',')
40        except AttributeError, detail:
41                print('The installed torque version does not support pbs_get_server_list function')
42                sys.exit(1)
43        for server in server_list:
44                pbs_server = server
45                con = pbs.pbs_connect(server)
46                if con != -1:
47                        break
48
49        if con == -1:
50                print('Could not connect to a server (%s)' %('.'.join(server_list)))
51                sys.exit(1)
52
53        print("Connected to %s" %(pbs_server))
54
55
56method1()
57method2()
58
59
Note: See TracBrowser for help on using the repository browser.