Package user_functions :: Module sys_info
[hide private]
[frames] | no frames]

Source Code for Module user_functions.sys_info

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2011-2016 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2016 Troels Schwartz-Linnet                                   # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """The sys_info user function definitions.""" 
 25   
 26  # Python module imports. 
 27  import dep_check 
 28  if dep_check.wx_module: 
 29      from wx import FD_CHANGE_DIR 
 30  else: 
 31      FD_CHANGE_DIR = -1 
 32  from os import sep 
 33   
 34  # relax module imports. 
 35  from graphics import WIZARD_OXYGEN_PATH 
 36  from info import print_sys_info 
 37  from lib.timing import print_time 
 38  from pipe_control.system import cd, pwd 
 39  from user_functions.data import Uf_info; uf_info = Uf_info() 
 40  from user_functions.objects import Desc_container 
 41   
 42   
 43  # The user function class. 
 44  uf_class = uf_info.add_class('system') 
 45  uf_class.title = "Class containing the OS system related functions." 
 46  uf_class.menu_text = "&system" 
 47  uf_class.gui_icon = "oxygen.actions.help-about" 
 48   
 49   
 50  # The cd user function. 
 51  uf = uf_info.add_uf('system.cd') 
 52  uf.title = "Change the current working directory to the specified path." 
 53  uf.title_short = "Change current working directory." 
 54  uf.display = True 
 55  uf.add_keyarg( 
 56      name = "path", 
 57      py_type = "str", 
 58      arg_type = "dir sel", 
 59      desc_short = "path", 
 60      desc = "The path to the new current working directory.", 
 61      can_be_none = False, 
 62      wiz_filesel_style = FD_CHANGE_DIR 
 63  ) 
 64  # Description. 
 65  uf.desc.append(Desc_container()) 
 66  uf.desc[-1].add_paragraph("The equivalent of python module os.chdir(path).  Change the current working directory to the specified path.") 
 67  uf.desc[-1].add_paragraph("To change the current working directory, type:") 
 68  uf.desc[-1].add_prompt("relax> system.cd(\"/path/to/dir\")") 
 69  uf.backend = cd 
 70  uf.display = False 
 71  uf.menu_text = "&cd" 
 72  uf.gui_icon = "oxygen.places.folder-favorites" 
 73  uf.wizard_size = (700, 400) 
 74  uf.wizard_image = WIZARD_OXYGEN_PATH + 'places' + sep + 'folder-favorites.png' 
 75  uf.wizard_apply_button = False 
 76   
 77   
 78  # The system.pwd user function. 
 79  uf = uf_info.add_uf('system.pwd') 
 80  uf.title = "Display the current working directory." 
 81  uf.title_short = "Display working directory." 
 82  uf.display = True 
 83  # Description. 
 84  uf.desc.append(Desc_container()) 
 85  uf.desc[-1].add_paragraph("This will display the current working directory.") 
 86  uf.desc[-1].add_paragraph("The directory can be changed with the system.cd(path) user function.") 
 87  uf.desc[-1].add_prompt("relax> system.pwd()") 
 88  uf.desc[-1].add_prompt("relax> system.cd(\"/path/to/dir\")") 
 89  uf.backend = pwd 
 90  uf.menu_text = "&pwd" 
 91  uf.gui_icon = "oxygen.places.folder-development" 
 92  uf.wizard_size = (700, 400) 
 93  uf.wizard_image = WIZARD_OXYGEN_PATH + 'places' + sep + 'folder-development.png' 
 94  uf.wizard_apply_button = False 
 95   
 96   
 97  # The sys_info user function. 
 98  uf = uf_info.add_uf('system.sys_info') 
 99  uf.title = "Display all system information relating to this version of relax." 
100  uf.title_short = "Display system information." 
101  uf.display = True 
102  # Description. 
103  uf.desc.append(Desc_container()) 
104  uf.desc[-1].add_paragraph("This will display all of the relax, Python, python package and hardware information currently being used by relax.  This is useful for seeing if all packages are up to date and if the correct software versions are being used.  It is also very useful information for reporting relax bugs.") 
105  uf.backend = print_sys_info 
106  uf.menu_text = "s&ys_info" 
107  uf.gui_icon = "oxygen.actions.help-about" 
108  uf.wizard_size = (700, 400) 
109  uf.wizard_apply_button = False 
110   
111   
112  # The time user function. 
113  uf = uf_info.add_uf('system.time') 
114  uf.title = "Display the current time." 
115  uf.title_short = "Current time." 
116  uf.display = True 
117  # Description. 
118  uf.desc.append(Desc_container()) 
119  uf.desc[-1].add_paragraph("This user function will display the current time which can be useful for timing long calculations by having time information in any saved log files.") 
120  uf.backend = print_time 
121  uf.menu_text = "&time" 
122  uf.gui_icon = "oxygen.actions.chronometer" 
123  uf.wizard_size = (700, 400) 
124  uf.wizard_apply_button = False 
125