Skip to content

Commit

Permalink
Merge branch 'master' into feature/10706_indirect_python_refactor
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectResolution.py

Refs #10706
  • Loading branch information
DanNixon committed Feb 17, 2015
2 parents b030a92 + a6a5947 commit 19a0db5
Show file tree
Hide file tree
Showing 66 changed files with 4,179 additions and 1,098 deletions.
10 changes: 5 additions & 5 deletions Code/Mantid/CMakeLists.txt
Expand Up @@ -197,8 +197,8 @@ if ( ENABLE_CPACK )

set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},poco-crypto,poco-data,poco-mysql,poco-sqlite,poco-odbc,poco-util,poco-xml,poco-zip,poco-net,poco-netssl,poco-foundation,PyQt4,sip" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},python-ipython >= 1.1.0" )
# scipy & matplotlib
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},scipy,python-matplotlib" )
# scipy, matplotlib, psutil
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},scipy,python-matplotlib,python-psutil" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},mxml,hdf,hdf5,jsoncpp" )

if( "${UNIX_CODENAME}" MATCHES "Santiago" )
Expand Down Expand Up @@ -226,19 +226,19 @@ if ( ENABLE_CPACK )
set ( PERFTOOLS_DEB_PACKAGE "libgoogle-perftools0 (>= 1.7)" )
if( "${UNIX_CODENAME}" MATCHES "lucid" )
list ( APPEND DEPENDS_LIST ",libqscintilla2-5,"
"libopencascade-foundation-6.3.0 (>= 6.3.0),libopencascade-modeling-6.3.0 (>= 6.3.0),"
"libopencascade-foundation-6.3.0 (>= 6.3.0),libopencascade-modeling-6.3.0 (>= 6.3.0),python-psutil,"
"libmuparser0,libpocofoundation9,libpocoutil9,libpoconet9,libpoconetssl9,libpococrypto9,libpocoxml9" )
elseif( "${UNIX_CODENAME}" MATCHES "precise" )
list ( APPEND DEPENDS_LIST ",libqscintilla2-8,"
"libopencascade-foundation-6.5.0 (>= 6.5.0),libopencascade-modeling-6.5.0 (>= 6.5.0),"
"libmuparser0debian1,"
"ipython-qtconsole (>= 1.1),python-matplotlib,python-scipy,"
"ipython-qtconsole (>= 1.1),python-matplotlib,python-scipy,python-psutil,"
"libpocofoundation9,libpocoutil9,libpoconet9,libpoconetssl9,libpococrypto9,libpocoxml9")
elseif( "${UNIX_CODENAME}" STREQUAL "trusty" )
list ( APPEND DEPENDS_LIST ",libqscintilla2-11,"
"liboce-foundation8,liboce-modeling8,"
"libmuparser2,"
"ipython-qtconsole (>= 1.1),python-matplotlib,python-scipy,"
"ipython-qtconsole (>= 1.1),python-matplotlib,python-scipy,python-psutil,"
"libpocofoundation11,libpocoutil11,libpoconet11,libpoconetssl11,libpococrypto11,libpocoxml11")
set ( PERFTOOLS_DEB_PACKAGE "libgoogle-perftools4 (>= 1.7)" )
else()
Expand Down
Expand Up @@ -19,7 +19,8 @@ def PyInit(self):
self.declareProperty(WorkspaceProperty('OutputWorkspace', '',
optional=PropertyMode.Optional,
direction=Direction.Output),
doc='Output resolution workspace (if left blank a name will be gernerated automatically)')
doc='Output resolution workspace (if left blank a name will '
'be gernerated automatically)')

self.declareProperty(name='Instrument', defaultValue='',
validator=StringListValidator(['IRIS', 'OSIRIS', 'TOSCA']),
Expand All @@ -40,8 +41,6 @@ def PyInit(self):
doc='Rebinning parameters (min,width,max)')
self.declareProperty(name='ScaleFactor', defaultValue=1.0,
doc='Factor to scale resolution curve by')
self.declareProperty(name='Smooth', defaultValue=False,
doc='Apply WienerSmooth to resolution')

self.declareProperty(name='Plot', defaultValue=False, doc='Plot resolution curve')
self.declareProperty(name='Save', defaultValue=False,
Expand Down Expand Up @@ -77,11 +76,6 @@ def PyExec(self):

Rebin(InputWorkspace=self._out_ws, OutputWorkspace=self._out_ws, Params=self._rebin_string)

if self._smooth:
WienerSmooth(InputWorkspace=self._out_ws, OutputWorkspace='__smooth_temp')
CopyLogs(InputWorkspace=self._out_ws, OutputWorkspace='__smooth_temp')
RenameWorkspace(InputWorkspace='__smooth_temp', OutputWorkspace=self._out_ws)

self._post_process()
self.setProperty('OutputWorkspace', self._out_ws)

Expand All @@ -104,7 +98,6 @@ def _setup(self):
self._background = self.getProperty('BackgroundRange').value
self._rebin_string = self.getProperty('RebinParam').value
self._scale_factor = self.getProperty('ScaleFactor').value
self._smooth = self.getProperty('Smooth').value

self._plot = self.getProperty('Plot').value
self._save = self.getProperty('Save').value
Expand All @@ -122,9 +115,6 @@ def _post_process(self):
AddSampleLog(Workspace=self._out_ws, LogName='scale_factor',
LogType='Number', LogText=str(self._scale_factor))

AddSampleLog(Workspace=self._out_ws, LogName='res_smoothing_applied',
LogType='String', LogText=str(self._smooth))

AddSampleLog(Workspace=self._out_ws, LogName='back_start',
LogType='Number', LogText=str(self._background[0]))
AddSampleLog(Workspace=self._out_ws, LogName='back_end',
Expand Down
24 changes: 21 additions & 3 deletions Code/Mantid/MantidPlot/CMakeLists.txt
Expand Up @@ -880,14 +880,29 @@ copy_files_to_dir ( "${IPY_FILES}"
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/ipython_widget
IPYTHON_INSTALL_FILES )

# SysMon scripts
set( SYSMON_FILES
__init__.py
_version.py
config.py
sysmon.py
sysmon_tools.py
ui_sysmon.py
ui_sysmon.ui
)
copy_files_to_dir ( "${SYSMON_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}/SysMon
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/SysMon
SYSMON_INSTALL_FILES )

###########################################################################
# MantidPlot executable
###########################################################################

add_executable ( MantidPlot ${WIN_CONSOLE} MACOSX_BUNDLE ${ALL_SRC} src/main.cpp
${INC_FILES} ${QTIPLOT_C_SRC} ${UI_HDRS}
${RES_FILES} ${MANTID_RC_FILE}
${PYTHON_INSTALL_FILES} ${MTDPLOT_INSTALL_FILES} ${CONFIG_RESET_SCRIPT_FILE} ${MTDPLOT_FUTURE_INSTALL_FILES} ${IPYTHON_INSTALL_FILES}
${PYTHON_INSTALL_FILES} ${MTDPLOT_INSTALL_FILES} ${CONFIG_RESET_SCRIPT_FILE} ${MTDPLOT_FUTURE_INSTALL_FILES} ${IPYTHON_INSTALL_FILES} ${SYSMON_INSTALL_FILES}
)

# Library dependencies
Expand Down Expand Up @@ -1035,18 +1050,21 @@ endforeach()
foreach(PY_FILE ${IPY_FILES} )
install ( FILES ipython_widget/${PY_FILE} DESTINATION ${BIN_DIR}/ipython_widget )
endforeach()
foreach(PY_FILE ${SYSMON_FILES} )
install ( FILES SysMon/${PY_FILE} DESTINATION ${BIN_DIR}/SysMon )
endforeach()
install ( FILES ${CONFIG_RESET_SCRIPT} DESTINATION ${BIN_DIR} )

# file make_package.rb contains hard-coded path to the libraries
# this causes fail of the installation with macports
# therefore MACPORTS option is introduced
if ( APPLE )
if (OSX_VERSION VERSION_LESS 10.9 OR MACPORTS)
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/FixBundle.cmake.in
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/FixBundle.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake
@ONLY )

install ( SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake )
install ( SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake )
else ()
install ( FILES make_package.rb DESTINATION MantidPlot.app/ )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/FixMavericksBundle.cmake.in
Expand Down
25 changes: 25 additions & 0 deletions Code/Mantid/MantidPlot/SysMon/README.md
@@ -0,0 +1,25 @@
SysMon
======

Python qt system monitor which utilizes the Python psutil and platform modules to provide system information for display.

This application has been adapted to work with psutil version 1 and version 2 modules as there are some command syntax changes between these two versions.

The SysMon user interface has been divided into a main window which imports the tabs to make a standalone application, or the tabs can be imported into other applications as a QWidget. Thus there are separate .ui files corresponding to each.

The code which imports the tabs into the main program resides in SysMon.pyw. This is where to look to see how to include the tabs into your own application. All files except SysMon.pyw and ui_sysmonMainWindow.* will be required when tabs are incorporated in other applications.

The following command line arguments have been added:
--help to print out the help message.
--nompl to run the application minus matplotlib in support of the current MantidPlot (removes those tabs requiring matplotlib).
--custom to enable the custom menubar item in the standalone application (currently supports checking Matlab license status on SNS analysis computers).

To run as a standalone application via the corresponding command lines:
*Change to the folder containing the Sysmon software, then:
*DOS: python SysMon.pyw
*Linux: ./SysMon.pyw

The standalone application been tested on Windows and RHEL Linux, but not on Mac yet.

Note that configuration and global constants and variables now reside in config.py.

114 changes: 114 additions & 0 deletions Code/Mantid/MantidPlot/SysMon/SysMon.pyw
@@ -0,0 +1,114 @@
#!/usr/bin/python
"""
SysMon.pyw
Initial application development 03Sep14 by S. Miller
The application utilizes the psutil and platform python modules to provide system information
for display via text fields, a table and Matplotlib plots.
The application utilizes a timer with user selectable timer intervals to update information
provided to the application.
"""
import config
import sys

__version__="unknown"
try:
from _version import __version__
except ImportError:
#_version.py file not found - version not known in this case so use
#the default previously given.
pass

#parse args - doing it here as config structure needs to be filled prior to importing sysmon
if ['--nompl'] == [s for s in sys.argv if '--nompl' in s]:
#case to not use matplotlib
config.nompl=True
else:
#case to use matplotlib (default case)
config.nompl=False

if ['--help'] == [s for s in sys.argv if '--help' in s]:
print "SysMon Help"
print "--help - this message"
print "--nompl - flag to disable using matplotlib, also disables History and Users tabs"
print "--custom: - flag to use facility specific options"
sys.exit()

if ['--custom'] == [s for s in sys.argv if '--custom' in s]:
config.custom=True

from PyQt4 import QtGui

from ui_sysmonMainWindow import *
#from ui_sysmonTabs import *
from sysmon import *

class SysMonMainWindow(QtGui.QMainWindow):

def __init__(self, parent=None):
#setup main window
QtGui.QMainWindow.__init__(self, parent)
self.setWindowTitle("System Status")
self.ui = Ui_MainWindow() #defined from ui_sysmon.py
self.ui.setupUi(self)
#setup tabs - class imported from sysmon.py
self.sysmontabs=SysMon(self)
self.setCentralWidget(self.sysmontabs)

#setup menu bar actions
self.connect(self.ui.actionExit, QtCore.SIGNAL('triggered()'), self.confirmExit) #define function to confirm and perform exit
self.connect(self.ui.actionAbout, QtCore.SIGNAL('triggered()'), self.About)
self.connect(self.ui.actionCheck_Matlab_Licenses, QtCore.SIGNAL('triggered()'), self.updateMatlab)

#check if custom menu bar enabled via command line flag --custom and if not, remove it as it's built by default from Qt
if not(config.custom):
self.ui.menubar.removeAction(self.ui.menuCustom.menuAction())


#define methods for menu bar options
def confirmExit(self):
reply = QtGui.QMessageBox.question(self, 'Message',
"Are you sure to quit?", QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)

if reply == QtGui.QMessageBox.Yes:
#close application
self.close()
else:
#do nothing and return
pass

def About(self):
dialog=QtGui.QMessageBox(self)
dialog.setText("PyQt4 System Monitoring Application "+__version__)
info='Application Info: \n\r * Changing the Update Rate Clears plots \n\r * It may take one full new update cycle for changes to take effect \n\r * Update rate shown in History plot xaxis label \n\r * Process tab CPU percentage can be greater than 100 when more than a single core is involved'
dialog.setDetailedText(info) #give full info in detailed text
dialog.exec_()

def updateMatlab(self):
#run license server command to extract license info
info=commands.getstatusoutput(config.matlabchk)
info=str(info[1]) #seem to need to make this a string for Linux to work properly
#test if info string contains MATLAB info
if info.find("MATLAB") < 0:
#case where no license server found
outstr="No Matlab License Server Found to Check"
else:
indx0=info.find("Users of MATLAB:")
indx1=info.find("licenses in use")
if indx0 > -1 and indx1 > -1:
outstr=info[indx0:indx1+15+1]
else:
outstr="Unable to determine Matlab license information"
dialog=QtGui.QMessageBox(self)
#print "outstr: "+outstr
dialog.setText(outstr)
dialog.setDetailedText(info) #give full info in detailed text
dialog.exec_()

if __name__=="__main__":
app = QtGui.QApplication(sys.argv)
sysmon = SysMonMainWindow()
sysmon.show()

sys.exit(app.exec_())
Empty file.
4 changes: 4 additions & 0 deletions Code/Mantid/MantidPlot/SysMon/_version.py
@@ -0,0 +1,4 @@
#File to identify the current version of the software
#Note that this file must be manually updated to contain the same
#version number as the git tag for the check-in.
__version__="v0.29"
20 changes: 20 additions & 0 deletions Code/Mantid/MantidPlot/SysMon/config.py
@@ -0,0 +1,20 @@

#global definitions for constants and variables

#Tab indices - based upon the order of the tabs as built via Qt and these must be the same as the Qt GUI.
SYST_TAB=0
HIST_TAB=1
PROC_TAB=2
USER_TAB=3
OPTS_TAB=4

#Global Variables:
psutilVer=0 #flag for the version of psutil being used
nompl=False #Flag to indicate if using matplotlib - True, then do not use plots, False, then try to use matplotlib plots
mplLoaded=False #flag for matplotlib loading
custom=False #flag to indicate if the custom interface is to be used (usually not)
matlabchk='lmstat -S -c 27010@licenses1.sns.gov' #text command to status the Matlab license server (only for custom mode with SysMon.pyw)
basefontsize=9 #basic font size when GUI is at minimum size
fscl=0.5 #scale factor for font size change with GUI resizing - less than one, font size slower than GUI size change, and greater than one font size faster than GUI size change
pltFont=9 #initial font size for matplotlib plots
linewidth=1 #initial line widths for matplotlib plots

0 comments on commit 19a0db5

Please sign in to comment.