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

« back to all changes in this revision

Viewing changes to bin/cs_info.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 User Interface, element of the
4
 
#     Code_Saturne CFD tool.
5
 
#
6
 
#     Copyright (C) 1998-2010 EDF S.A., France
7
 
#
8
 
#     contact: saturne-support@edf.fr
9
 
#
10
 
#     The Code_Saturne User Interface 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 User Interface 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
 
 
 
1
#!/usr/bin/env python
 
2
 
 
3
#-------------------------------------------------------------------------------
 
4
 
 
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
 
6
#
 
7
# Copyright (C) 1998-2011 EDF S.A.
 
8
#
 
9
# This program is free software; you can redistribute it and/or modify it under
 
10
# the terms of the GNU General Public License as published by the Free Software
 
11
# Foundation; either version 2 of the License, or (at your option) any later
 
12
# version.
 
13
#
 
14
# This program is distributed in the hope that it will be useful, but WITHOUT
 
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
16
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
17
# details.
 
18
#
 
19
# You should have received a copy of the GNU General Public License along with
 
20
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
21
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
22
 
 
23
#-------------------------------------------------------------------------------
28
24
 
29
25
"""
30
26
This module describes the script used to display information on Code_Saturne.
44
40
import os, sys, pwd, shutil, stat
45
41
from optparse import OptionParser
46
42
 
47
 
import cs_config
48
 
 
49
 
 
50
43
#-------------------------------------------------------------------------------
51
44
# Processes the passed command line arguments
52
45
#-------------------------------------------------------------------------------
53
46
 
54
47
 
55
 
def process_cmd_line(argv):
 
48
def process_cmd_line(argv, pkg):
56
49
    """
57
50
    Processes the passed command line arguments.
58
51
 
75
68
 
76
69
    parser.add_option("--version", dest="version",
77
70
                      action="store_true",
78
 
                      help="print Code_Saturne version number")
 
71
                      help="print version number")
79
72
 
80
73
    parser.set_defaults(pdf_reader=None)
81
74
    parser.set_defaults(guides=[])
84
77
    (options, args) = parser.parse_args(argv)
85
78
 
86
79
    if options.version:
87
 
        print_version()
 
80
        print_version(pkg)
88
81
        sys.exit(0)
89
82
 
90
83
    if len(args) > 0 or len(options.guides) == 0:
99
92
#-------------------------------------------------------------------------------
100
93
 
101
94
 
102
 
def print_version():
 
95
def print_version(pkg):
103
96
    """
104
97
    Print Code_Saturne version.
105
98
    """
106
99
 
107
 
    print "Code_Saturne version: %s" % cs_config.package.version
 
100
    print(pkg.name + " version: " + pkg.version)
108
101
 
109
102
 
110
103
#-------------------------------------------------------------------------------
112
105
#-------------------------------------------------------------------------------
113
106
 
114
107
 
115
 
def launch_manual(reader, m):
 
108
def launch_manual(reader, m, pkg):
116
109
    """
117
110
    Launch the corresponding PDF manual.
118
111
    """
123
116
                 "kde-open",       # KDE 4
124
117
                 "exo-open"]       # Xfce
125
118
 
126
 
    readers = ["evince", "gpdf", "kpdf", "xpdf", "acroread"]
 
119
    readers = ["okular", "evince", "kpdf", "gpdf", "xpdf", "acroread"]
127
120
 
128
 
    manual = os.path.join(cs_config.dirs.pdfdir, m) + '.pdf'
 
121
    manual = os.path.join(pkg.pdfdir, m) + '.pdf'
129
122
 
130
123
    if not os.path.isfile(manual):
131
 
        print "File %s not found." % manual
 
124
        print("File %s not found." % manual)
132
125
        return
133
126
 
134
127
    # First:  use the reader specified by the user, if any
150
143
                if os.system(cmd) == 0:
151
144
                    return
152
145
 
153
 
 
154
 
#-------------------------------------------------------------------------------
155
 
# Creation of the study directory
156
 
#-------------------------------------------------------------------------------
157
 
 
158
 
 
159
 
def main(argv):
 
146
#-------------------------------------------------------------------------------
 
147
# Main
 
148
#-------------------------------------------------------------------------------
 
149
 
 
150
def main(argv, pkg):
160
151
    """
161
152
    Main function.
162
153
    """
163
154
 
164
 
    manuals, reader = process_cmd_line(argv)
 
155
    manuals, reader = process_cmd_line(argv, pkg)
165
156
 
166
157
    for m in manuals:
167
 
        launch_manual(reader, m)
168
 
 
169
 
 
170
 
if __name__ == "__main__":
171
 
    main(sys.argv[1:])
 
158
        launch_manual(reader, m, pkg)
172
159
 
173
160
#-------------------------------------------------------------------------------
174
161
# End