~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to extras/validation/Autovalidation/CommandLine.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#============================================================================
2
 
#
3
 
#     This file is part of the Code_Saturne Kernel, element of the
4
 
#     Code_Saturne CFD tool.
5
 
#
6
 
#     Copyright (C) 1998-2008 EDF S.A., France
7
 
#
8
 
#     contact: saturne-support@edf.fr
9
 
#
10
 
#     The Code_Saturne Kernel is free software; you can redistribute it
11
 
#     and/or modify it under the terms of the GNU General Public License
12
 
#     as published by the Free Software Foundation; either version 2 of
13
 
#     the License, or (at your option) any later version.
14
 
#
15
 
#     The Code_Saturne Kernel is distributed in the hope that it will be
16
 
#     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17
 
#     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
#     GNU General Public License for more details.
19
 
#
20
 
#     You should have received a copy of the GNU General Public License
21
 
#     along with the Code_Saturne Kernel; if not, write to the
22
 
#     Free Software Foundation, Inc.,
23
 
#     51 Franklin St, Fifth Floor,
24
 
#     Boston, MA  02110-1301  USA
25
 
#
26
 
#============================================================================
27
 
#-------------------------------------------------------------------------------
28
 
# Library modules import
29
 
#-------------------------------------------------------------------------------
30
 
 
31
 
import sys, getopt
32
 
 
33
 
#-------------------------------------------------------------------------------
34
 
# Application modules import
35
 
#-------------------------------------------------------------------------------
36
 
import Autovalidation.Common as Common
37
 
 
38
 
 
39
 
def usage():
40
 
    """
41
 
    Usage of autovalid
42
 
    """
43
 
    txt="""
44
 
Usage:\n\nautovalid -f [xml file name] [-d [local directory]]
45
 
 
46
 
Valid options are one or more of the following:
47
 
 
48
 
-f [xml file name]
49
 
--file [xml file name]
50
 
 
51
 
     Upload a studies list.
52
 
 
53
 
-d [directory]
54
 
--tmpdirectory [directory]
55
 
 
56
 
     Define the local directory.
57
 
 
58
 
-h
59
 
--help
60
 
 
61
 
     Prints this help message.
62
 
----------------------------------------------------------------------
63
 
"""
64
 
    return txt
65
 
 
66
 
def process_cmd_line (arg):
67
 
    
68
 
    options = "f:hd:"
69
 
    long_opts = ['file=', 'help', 'tmpdirectory=']
70
 
 
71
 
    try:
72
 
        opts, args = getopt.getopt(arg, options, long_opts)
73
 
    except getopt.error, msg:
74
 
        print "\nWarning:\n", msg
75
 
        print usage()
76
 
        print "Warning:\n", msg, "\n"
77
 
        sys.exit(1)
78
 
 
79
 
    if (opts and args) or len(args)>1 : 
80
 
        print usage()
81
 
        sys.exit(1)
82
 
 
83
 
    if not opts and args :
84
 
        print usage()
85
 
        sys.exit(1)
86
 
 
87
 
    for o, a in opts:
88
 
        if o in ('-f', '--file'):
89
 
            Common.XMLFileName = a
90
 
        if o in ('-d', '--tmpdirectory'):
91
 
            Common.tmpDirectory = a
92
 
        if o in ('-h', '--help'):
93
 
            print usage()
94
 
            sys.exit(1)
95
 
 
96
 
    if Common.XMLFileName == "":
97
 
        print usage()
98
 
        sys.exit(1)