|
| 1 | +# Copyright (C) 2024 ANSYS, Inc. and/or its affiliates. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +# |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | + |
| 24 | +def inquire(self, strarray="", func="", arg1="", arg2=""): |
| 25 | + """Returns system information. |
| 26 | +
|
| 27 | + By default, with no arguments, it returns the working directory. |
| 28 | +
|
| 29 | + >>> mapdl.inquire() |
| 30 | + C:\\Users\\user\\AppData\\Local\\Temp\\ansys_nynvxsaooh |
| 31 | +
|
| 32 | + Parameters |
| 33 | + ---------- |
| 34 | + strarray : str, optional |
| 35 | + Name of the string array or parameter that will hold the returned values. |
| 36 | + Normally, if used in a python script you should just work with the |
| 37 | + return value from this method. |
| 38 | +
|
| 39 | + func : str, optional |
| 40 | + Specifies the type of system information returned. See the |
| 41 | + notes section for more information. |
| 42 | +
|
| 43 | + arg1 : str, optional |
| 44 | + First argument. See notes for ``arg1`` definition. |
| 45 | +
|
| 46 | + arg2 : str, optional |
| 47 | + Second argument. See notes for ``arg1`` definition. |
| 48 | +
|
| 49 | + Returns |
| 50 | + ------- |
| 51 | + str |
| 52 | + Value of the inquired item. |
| 53 | +
|
| 54 | + Notes |
| 55 | + ----- |
| 56 | + The ``/INQUIRE`` command is valid in any processor. |
| 57 | +
|
| 58 | + .. warning:: |
| 59 | + Take note that from version 0.60.4 and later, the command behaviour |
| 60 | + has been changed. |
| 61 | + Previously, the ``StrArray`` argument was omitted. For example: |
| 62 | + >>> mapdl.inquire('DIRECTORY') |
| 63 | + C:\\Users\\user\\AppData\\Local\\Temp\\ansys_nynvxsaooh |
| 64 | +
|
| 65 | + Now this will raise an exception. |
| 66 | + The default behaviour now, requires to input ``StrArray``: |
| 67 | + >>> mapdl.inquire('', 'DIRECTORY') |
| 68 | + C:\\Users\\user\\AppData\\Local\\Temp\\ansys_nynvxsaooh |
| 69 | +
|
| 70 | + **GENERAL FUNC OPTIONS** |
| 71 | +
|
| 72 | + - ``LOGIN`` - Returns the pathname of the login directory on Linux |
| 73 | + systems or the pathname of the default directory (including |
| 74 | + drive letter) on Windows systems. |
| 75 | + - ``DOCU`` - Pathname of the ANSYS documentation directory. |
| 76 | + - ``APDL`` - Pathname of the ANSYS APDL directory. |
| 77 | + - ``PROG`` - Pathname of the ANSYS executable directory. |
| 78 | + - ``AUTH`` - Pathname of the directory in which the license file resides. |
| 79 | + - ``USER`` - Name of the user currently logged-in. |
| 80 | + - ``DIRECTORY`` - Pathname of the current directory. |
| 81 | + - ``JOBNAME`` - Current Jobname. |
| 82 | + - ``RSTDIR`` - Result file directory. |
| 83 | + - ``RSTFILE`` - Result file name. |
| 84 | + - ``RSTEXT`` - Result file extension. |
| 85 | + - ``OUTPUT`` - Current output file name. |
| 86 | +
|
| 87 | +
|
| 88 | + **RETURNING THE VALUE OF AN ENVIRONMENT VARIABLE TO A PARAMETER** |
| 89 | +
|
| 90 | + If ``FUNC=ENV``, the command format is ``/INQUIRE,StrArray,ENV,ENVNAME,Substring``. |
| 91 | + In this instance, ENV specifies that the command should return the |
| 92 | + value of an environment variable. |
| 93 | + The following defines the remaining fields: |
| 94 | +
|
| 95 | + Envname: |
| 96 | + Specifies the name of the environment variable. |
| 97 | +
|
| 98 | + Substring: |
| 99 | + If ``Substring = 1``, the first substring (up to the first colon (:)) is returned. |
| 100 | + If ``Substring = 2``, the second substring is returned, etc. For Windows platforms, |
| 101 | + the separating character is semicolon (;). |
| 102 | + If this argument is either blank or 0, the entire value of the environment |
| 103 | + variable is returned. |
| 104 | +
|
| 105 | +
|
| 106 | + **RETURNING THE VALUE OF A TITLE TO A PARAMETER** |
| 107 | +
|
| 108 | + If ``FUNC = TITLE``, the command format is ``/INQUIRE,StrArray,TITLE,Title_num``. |
| 109 | + In this context, the value of Title_num can be blank or ``1`` through ``5``. If the |
| 110 | + value is ``1`` or blank, the title is returned. If the value is ``2`` through ``5``, |
| 111 | + a corresponding subtitle is returned (``2`` denoting the first subtitle, and so on). |
| 112 | +
|
| 113 | +
|
| 114 | + **RETURNING INFORMATION ABOUT A FILE TO A PARAMETER** |
| 115 | +
|
| 116 | + The ``/INQUIRE`` command can also return information about specified files |
| 117 | + within the file system. |
| 118 | + For these capabilities, the format is ``/INQUIRE,Parameter,FUNC,Fname, Ext, --``. |
| 119 | + The following defines the fields: |
| 120 | +
|
| 121 | + Parameter: |
| 122 | + Name of the parameter that will hold the returned values. |
| 123 | +
|
| 124 | + Func: |
| 125 | + Specifies the type of file information returned: |
| 126 | +
|
| 127 | + EXIST: |
| 128 | + Returns a ``1`` if the specified file exists, and ``0`` if it does not. |
| 129 | +
|
| 130 | + DATE: |
| 131 | + Returns the date stamp of the specified file in the format ``*yyyymmdd.hhmmss*``. |
| 132 | +
|
| 133 | + SIZE: |
| 134 | + Returns the size of the specified file in MB. |
| 135 | +
|
| 136 | + WRITE: |
| 137 | + Returns the status of the write attribute. A ``0`` denotes no write permission while a ``1`` denotes |
| 138 | + write permission. |
| 139 | +
|
| 140 | + READ: |
| 141 | + Returns the status of the read attribute. A ``0`` denotes no read permission while a ``1`` denotes read |
| 142 | + permission. |
| 143 | +
|
| 144 | + EXEC: |
| 145 | + Returns the status of the execute attribute (this has meaning only on Linux). A ``0`` denotes no |
| 146 | + execute permission while a ``1`` denotes execute permission. |
| 147 | +
|
| 148 | + LINES: |
| 149 | + Returns the number of lines in an ASCII file. |
| 150 | +
|
| 151 | + Fname: |
| 152 | + File name and directory path (248 characters maximum, including the characters needed for the |
| 153 | + directory path). An unspecified directory path defaults to the working directory; in this case, you |
| 154 | + can use all 248 characters for the file name. |
| 155 | +
|
| 156 | + Ext: |
| 157 | + Filename extension (eight-character maximum). |
| 158 | +
|
| 159 | + Examples |
| 160 | + -------- |
| 161 | + Return the MAPDL working directory |
| 162 | + >>> mapdl.inquire('', 'DIRECTORY') |
| 163 | + C:\\Users\\gayuso\\AppData\\Local\\Temp\\ansys_nynvxsaooh |
| 164 | +
|
| 165 | + Or |
| 166 | +
|
| 167 | + >>> mapdl.inquire() |
| 168 | + C:\\Users\\gayuso\\AppData\\Local\\Temp\\ansys_nynvxsaooh |
| 169 | +
|
| 170 | + Return the job name |
| 171 | +
|
| 172 | + >>> mapdl.inquire('', 'JOBNAME') |
| 173 | + file |
| 174 | +
|
| 175 | + Return the result file name |
| 176 | +
|
| 177 | + >>> mapdl.inquire('', 'RSTFILE') |
| 178 | + 'file.rst' |
| 179 | + """ |
| 180 | + return self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}") |
0 commit comments