Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

#!/usr/bin/env python 

 

# 

# LSST Data Management System 

# Copyright 2008-2016 LSST Corporation. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <http://www.lsstcorp.org/LegalNotices/>. 

# 

 

import argparse 

 

 

class AllocatorParser: 

"""An argument parser for node allocation requests. 

 

Parameters 

---------- 

basename : `str` 

The name used to identify the running program 

""" 

 

def __init__(self, basename): 

"""Construct an AllocatorParser 

@param argv: list containing the command line arguments 

@return: the parser options and remaining arguments 

""" 

 

self.defaults = {} 

 

self.args = [] 

 

self.args = self.parseArgs(basename) 

 

def parseArgs(self, basename): 

"""Parse command line, and test for required arguments 

 

Parameters 

---------- 

argv: `list` 

list of strings containing the command line arguments 

 

Returns 

------- 

The parser options and remaining arguments 

""" 

 

parser = argparse.ArgumentParser(prog=basename) 

parser.add_argument("platform", help="node allocation platform") 

parser.add_argument("-n", "--node-count", action="store", default=None, 

dest="nodeCount", help="number of nodes to use", type=int, required=True) 

parser.add_argument("-c", "--cpus", action="store", default=None, dest="cpus", 

help="cpus per node (WAS '-s' (--slots) option)", type=int, required=True) 

parser.add_argument("-m", "--maximum-wall-clock", action="store", dest="maximumWallClock", 

default=None, help="maximum wall clock time", type=str, required=True) 

parser.add_argument("-N", "--node-set", action="store", 

dest="nodeSet", default=None, help="node set name") 

parser.add_argument("-q", "--queue", action="store", dest="queue", 

default="debug", help="queue name") 

parser.add_argument("-e", "--email", action="store_true", dest="email", 

default=None, help="email notification flag") 

parser.add_argument("-O", "--output-log", action="store", dest="outputLog", 

default=None, help="Output log filename") 

parser.add_argument("-E", "--error-log", action="store", dest="errorLog", 

default=None, help="Error log filename") 

parser.add_argument("-g", "--glidein-shutdown", action="store", dest="glideinShutdown", 

type=int, default=None, help="glide-in inactivity shutdown time in seconds") 

parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="verbose") 

parser.add_argument("-r", "--reservation", action="store", dest="reservation", 

default=None, help="run id") 

parser.add_argument("-d", "--dynamic", const='__default__', nargs='?', action="store", 

dest="dynamic", type=str, default=None, help="configure to use dynamic slots") 

 

self.args = parser.parse_args() 

 

return self.args 

 

def getArgs(self): 

"""Accessor method to get arguments left after standard parsed options 

are initialized. 

 

Returns 

------- 

args: `list` 

remaining command line arguments 

""" 

return self.args 

 

def getPlatform(self): 

"""Accessor method to retrieve the "platform" that was specified on 

the command line. 

 

Returns 

------- 

platform: `str` 

the name of the "platform" 

""" 

return self.args.platform