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

113

114

115

116

117

#!/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/>. 

# 

 

from builtins import object 

import argparse 

 

 

class RunOrcaParser(object): 

"""An argument parser for the orchestration config file generation 

and execution 

""" 

 

def __init__(self, basename): 

"""Construct a RunOrcaParser 

@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 

@param argv: list containing the command line arguments 

@return: the parser options and remaining arguments 

""" 

 

parser = argparse.ArgumentParser(prog=basename, usage="[-h] -p PLATFORM -e EUPSPATH \ 

((-c COMMAND -i INPUTDATAFILE) | (-D DAGSCRIPT -I INPUTSCRIPT)) \ 

[-N NODESET] \ 

[-n IDSPERJOB] \ 

[-r DEFAULTROOT] \ 

[-l LOCALSCRATCH] \ 

[-d DATADIRECTORY] \ 

[-F FILESYSTEMDOMAIN] \ 

[-u USER_NAME] \ 

[-H USER_HOME] \ 

[-P PLATFORMCONFIG] \ 

[-R RUNID] \ 

[-v] [-s SETUP SETUP]") 

parser.add_argument("-p", "--platform", action="store", dest="platform", 

default=None, help="platform", required=True) 

 

command_group = parser.add_argument_group("parallel command") 

command_group.add_argument("-c", "--command", action="store", dest="command", 

default=None, help="command") 

command_group.add_argument("-i", "--id-file", action="store", dest="inputDataFile", 

default=None, help="list of ids") 

 

dag_group = parser.add_argument_group("dag script") 

dag_group.add_argument("-D", "--dag-script", action="store", dest="dagscript", 

default=None, help="dag script") 

dag_group.add_argument("-I", "--input-script", action="store", dest="inputscript", 

default=None, help="input script") 

 

parser.add_argument("-e", "--eups-path", action="store", dest="eupsPath", 

default=None, help="eups path", required=True) 

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

default=None, dest="nodeSet", 

help="name of collection of nodes to use (required by some platforms)", 

required=False) 

parser.add_argument("-n", "--ids-per-job", action="store", 

default=None, dest="idsPerJob", help="ids per job") 

parser.add_argument("-r", "--default-root", action="store", dest="defaultRoot", 

default=None, help="remote working directory for Condor") 

parser.add_argument("-l", "--local-scratch", action="store", dest="localScratch", 

default=None, help="local staging directory for Condor") 

parser.add_argument("-d", "--data-directory", action="store", dest="dataDirectory", 

default=None, help="where the data is located") 

 

parser.add_argument("-F", "--file-system-domain", action="store", dest="fileSystemDomain", 

default=None, help="file system domain") 

parser.add_argument("-u", "--user-name", action="store", dest="user_name", default=None, help="user") 

parser.add_argument("-H", "--user-home", action="store", dest="user_home", default=None, help="home") 

parser.add_argument("-R", "--run-id", action="store", dest="runid", default=None, help="run id") 

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

default=False, help="verbose") 

parser.add_argument("-s", "--setup", action="append", nargs=2, help="setup") 

parser.add_argument("-P", "--platformconfig", action="store", dest="platformConfig", 

default=None, help="platform configuration file") 

 

args = parser.parse_args() 

 

if args.dagscript is None: 

if args.command is None or args.inputDataFile is None: 

parser.print_help() 

parser.exit() 

return args 

 

def getArgs(self): 

"""Accessor method to get options set on initialization 

@return opts: command line options 

""" 

return self.args