Changes in / [083afa1:9c23f40] in sasview
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/sphinx-docs/build_sphinx.py
r751f4bd r01f1e17 6 6 http://sphinx-doc.org/invocation.html 7 7 """ 8 from __future__ import print_function 9 8 10 import subprocess 9 11 import os … … 12 14 import shutil 13 15 import imp 16 14 17 from glob import glob 15 16 18 from distutils.dir_util import copy_tree 17 19 from distutils.util import get_platform … … 55 57 SASMODELS_DEST_BUILDIMG = os.path.join(SASMODELS_DEST_PROLOG, "user", "models", "img") 56 58 57 #if os.path.exists(SASMODELS_SOURCE_PROLOG):58 # print "Found models prolog folder at ", SASMODELS_SOURCE_PROLOG59 #if os.path.exists(SASMODELS_SOURCE_REF_MODELS):60 # print "Found models ref folder at ", SASMODELS_SOURCE_REF_MODELS61 #if os.path.exists(SASMODELS_SOURCE_MODELS):62 # print "Found models folder at ", SASMODELS_SOURCE_MODELS63 #if os.path.exists(SASMODELS_SOURCE_IMG):64 # print "Found img folder at ", SASMODELS_SOURCE_IMG65 #if os.path.exists(SASMODELS_DEST_REF_MODELS):66 # print "Found models ref folder at ", SASMODELS_DEST_REF_MODELS67 #if os.path.exists(SASMODELS_DEST_MODELS):68 # print "Found models folder at ", SASMODELS_DEST_MODELS69 #if os.path.exists(SASMODELS_DEST_IMG):70 # print "Found img folder at ", SASMODELS_DEST_IMG71 #sys.exit()72 59 73 60 SPHINX_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build") … … 88 75 s=open(filename).read() 89 76 if old_string in s: 90 print 'Changing "{old_string}" to "{new_string}"'.format(**locals())77 print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 91 78 s=s.replace(old_string, new_string) 92 79 f=open(filename, 'w') … … 95 82 f.close() 96 83 else: 97 print 'No occurences of "{old_string}" found.'.format(**locals())84 print('No occurences of "{old_string}" found.'.format(**locals())) 98 85 99 86 def _remove_dir(dir_path): 100 87 """Removes the given directory.""" 101 88 if os.path.isdir(dir_path): 102 print "Removing \"%s\"... " % dir_path89 print("Removing \"%s\"... " % dir_path) 103 90 shutil.rmtree(dir_path) 104 91 … … 107 94 Clean the sphinx build directory. 108 95 """ 109 print "=== Cleaning Sphinx Build ==="96 print("=== Cleaning Sphinx Build ===") 110 97 _remove_dir(SASVIEW_DOCS) 111 98 _remove_dir(SPHINX_BUILD) … … 120 107 Copy the source toctrees to new folder for assembling the sphinx-docs 121 108 """ 122 print "=== Copying Source toctrees ==="109 print("=== Copying Source toctrees ===") 123 110 if os.path.exists(SASVIEW_TOC_SOURCE): 124 print "Found docs folder at ", SASVIEW_TOC_SOURCE111 print("Found docs folder at", SASVIEW_TOC_SOURCE) 125 112 shutil.copytree(SASVIEW_TOC_SOURCE, SPHINX_SOURCE) 126 113 … … 141 128 so that Sphinx may pick it up when generating the documentation. 142 129 """ 143 print "=== Retrieve User Docs ==="130 print("=== Retrieve User Docs ===") 144 131 145 132 # Copy documentation files from their "source" to their "destination". … … 148 135 149 136 docs = os.path.abspath(os.path.join(root, dirname)) 150 print "Found docs folder at \"%s\"." % docs137 print("Found docs folder at \"%s\"." % docs) 151 138 152 139 dest_dir_part = os.path.dirname(os.path.relpath(docs, SASVIEW_SRC)) … … 158 145 159 146 # Now pickup testdata_help.rst 160 # print os.path.abspath(SASVIEW_TEST) 161 # print os.path.abspath(SPHINX_SOURCE_TEST) 162 print "=== Including Test Data Docs ===" 147 print("=== Including Test Data Docs ===") 163 148 if os.path.exists(SASVIEW_TEST): 164 print "Found docs folder at ", SASVIEW_TEST149 print("Found docs folder at", SASVIEW_TEST) 165 150 shutil.copytree(SASVIEW_TEST, SPHINX_SOURCE_TEST) 166 151 167 print "=== And the Sasmodels Docs ==="152 print("=== And the Sasmodels Docs ===") 168 153 # Make sure we have the relevant images for the new sasmodels documentation 169 154 # First(!) we'll make a local reference copy for SasView (/new-models will be cleaned each build) 170 155 if os.path.exists(SASMODELS_SOURCE_IMG): 171 print "Found img folder SASMODELS_SOURCE_IMG at ", SASMODELS_SOURCE_IMG156 print("Found img folder SASMODELS_SOURCE_IMG at", SASMODELS_SOURCE_IMG) 172 157 if not os.path.exists(SASMODELS_DEST_IMG): 173 print "Missing docs folder SASMODELS_DEST_IMG at ", SASMODELS_DEST_IMG158 print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 174 159 os.makedirs(SASMODELS_DEST_IMG) 175 print "created SASMODELS_DEST_BUILDIMG at ", SASMODELS_DEST_BUILDIMG 176 else: print "Found img folder SASMODELS_DEST_IMG at ", SASMODELS_DEST_IMG 177 print "Copying sasmodels model image files..." 160 print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG) 161 else: 162 print("Found img folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 163 print("Copying sasmodels model image files...") 178 164 for files in os.listdir(SASMODELS_SOURCE_IMG): 179 165 fromhere=os.path.join(SASMODELS_SOURCE_IMG,files) 180 166 tohere=os.path.join(SASMODELS_DEST_IMG,files) 181 167 shutil.copy(fromhere,tohere) 182 else: print "cannot find SASMODELS_SOURCE_IMG", SASMODELS_SOURCE_IMG 168 else: 169 print("no source directory",SASMODELS_SOURCE_IMG,"was found") 183 170 184 171 if os.path.exists(SASMODELS_SOURCE_AUTOIMG): 185 print "Found img folder SASMODELS_SOURCE_AUTOIMG at ", SASMODELS_SOURCE_AUTOIMG172 print("Found img folder SASMODELS_SOURCE_AUTOIMG at", SASMODELS_SOURCE_AUTOIMG) 186 173 if not os.path.exists(SASMODELS_DEST_IMG): 187 print "Missing docs folder SASMODELS_DEST_IMG at ", SASMODELS_DEST_IMG174 print("Missing docs folder SASMODELS_DEST_IMG at", SASMODELS_DEST_IMG) 188 175 os.makedirs(SASMODELS_DEST_BUILDIMG) 189 print "created SASMODELS_DEST_BUILDIMG at ", SASMODELS_DEST_BUILDIMG190 print "Copying sasmodels model auto-generated image files..."176 print("created SASMODELS_DEST_BUILDIMG at", SASMODELS_DEST_BUILDIMG) 177 print("Copying sasmodels model auto-generated image files...") 191 178 for files in os.listdir(SASMODELS_SOURCE_AUTOIMG): 192 179 fromhere=os.path.join(SASMODELS_SOURCE_AUTOIMG,files) 193 180 tohere=os.path.join(SASMODELS_DEST_IMG,files) 194 181 shutil.copy(fromhere,tohere) 195 else: print "no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found" 182 else: 183 print("no source directory",SASMODELS_SOURCE_AUTOIMG ,"was found") 196 184 197 185 # And the rst prolog with the unit substitutions 198 186 if os.path.exists(SASMODELS_SOURCE_PROLOG): 199 print "Found prolog folder SASMODELS_SOURCE_PROLOG at ", SASMODELS_SOURCE_PROLOG187 print("Found prolog folder SASMODELS_SOURCE_PROLOG at", SASMODELS_SOURCE_PROLOG) 200 188 if os.path.exists(SASMODELS_DEST_PROLOG): 201 print "Found docs folder SASMODELS_DEST_PROLOG at ", SASMODELS_DEST_PROLOG202 print "Copying sasmodels rst_prolog file..."189 print("Found docs folder SASMODELS_DEST_PROLOG at", SASMODELS_DEST_PROLOG) 190 print("Copying sasmodels rst_prolog file...") 203 191 for files in os.listdir(SASMODELS_SOURCE_PROLOG): 204 192 if files.startswith("rst"): … … 206 194 tohere=os.path.join(SASMODELS_DEST_PROLOG,files) 207 195 shutil.copy(fromhere,tohere) 196 else: 197 print("no source directory",SASMODELS_SOURCE_PROLOG, "was found") 208 198 209 199 if os.path.exists(SASMODELS_SOURCE_GPU): 210 print "Found docs folder SASMODELS_SOURCE_GPU at ", SASMODELS_SOURCE_GPU200 print("Found docs folder SASMODELS_SOURCE_GPU at", SASMODELS_SOURCE_GPU) 211 201 if os.path.exists(SPHINX_SOURCE_USER): 212 print "Found docs folder SPHINX_SOURCE_USER at ", SPHINX_SOURCE_USER213 print "Copying sasmodels gpu files..."202 print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER) 203 print("Copying sasmodels gpu files...") 214 204 for files in os.listdir(SASMODELS_SOURCE_GPU): 215 205 if files.endswith(".rst"): … … 217 207 tohere=os.path.join(SPHINX_SOURCE_USER,files) 218 208 shutil.copy(fromhere,tohere) 209 else: 210 print("no source directory",SASMODELS_SOURCE_GPU,"was found") 219 211 220 212 if os.path.exists(SASMODELS_SOURCE_SESANS): 221 print "Found docs folder SASMODELS_SOURCE_SESANS at ", SASMODELS_SOURCE_SESANS213 print("Found docs folder SASMODELS_SOURCE_SESANS at", SASMODELS_SOURCE_SESANS) 222 214 if os.path.exists(SPHINX_SOURCE_USER): 223 print "Found docs folder SPHINX_SOURCE_USER at ", SPHINX_SOURCE_USER224 print "Copying sasmodels sesans files..."215 print("Found docs folder SPHINX_SOURCE_USER at", SPHINX_SOURCE_USER) 216 print("Copying sasmodels sesans files...") 225 217 for files in os.listdir(SASMODELS_SOURCE_SESANS): 226 218 if files.endswith(".rst"): … … 228 220 tohere=os.path.join(SPHINX_SOURCE_USER,files) 229 221 shutil.copy(fromhere,tohere) 222 else: 223 print("no source directory",SASMODELS_SOURCE_SESANS,"was found") 230 224 231 225 if os.path.exists(SASMODELS_SOURCE_MAGNETISM): 232 print "Found docs folder SASMODELS_SOURCE_MAGNETISM at ", SASMODELS_SOURCE_MAGNETISM226 print("Found docs folder SASMODELS_SOURCE_MAGNETISM at", SASMODELS_SOURCE_MAGNETISM) 233 227 if os.path.exists(SASMODELS_DEST_REF_MODELS): 234 print "Found docs folder SASMODELS_DEST_REF_MODELS at ", SASMODELS_DEST_REF_MODELS235 print "Copying sasmodels model toctree files..."228 print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS) 229 print("Copying sasmodels model toctree files...") 236 230 for files in os.listdir(SASMODELS_SOURCE_MAGNETISM): 237 231 if files.endswith(".rst"): … … 239 233 tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files) 240 234 shutil.copy(fromhere,tohere) 235 else: 236 print("no source directory",SASMODELS_SOURCE_MAGNETISM,"was found") 241 237 242 238 if os.path.exists(SASMODELS_SOURCE_MAGIMG): 243 print "Found img folder SASMODELS_SOURCE_MAGIMG at ", SASMODELS_SOURCE_MAGIMG239 print("Found img folder SASMODELS_SOURCE_MAGIMG at", SASMODELS_SOURCE_MAGIMG) 244 240 if not os.path.exists(SASMODELS_DEST_MAGIMG): 245 print "Missing img folder SASMODELS_DEST_MAGIMG at ", SASMODELS_DEST_MAGIMG241 print("Missing img folder SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG) 246 242 os.makedirs(SASMODELS_DEST_MAGIMG) 247 print "created SASMODELS_DEST_MAGIMG at ", SASMODELS_DEST_MAGIMG248 print "Copying sasmodels mag image files..."243 print("created SASMODELS_DEST_MAGIMG at", SASMODELS_DEST_MAGIMG) 244 print("Copying sasmodels mag image files...") 249 245 for files in os.listdir(SASMODELS_SOURCE_MAGIMG): 250 246 fromhere=os.path.join(SASMODELS_SOURCE_MAGIMG,files) 251 247 tohere=os.path.join(SASMODELS_DEST_MAGIMG,files) 252 248 shutil.copy(fromhere,tohere) 253 else: print "no source directory",SASMODELS_SOURCE_MAGIMG ,"was found" 249 else: 250 print("no source directory",SASMODELS_SOURCE_MAGIMG ,"was found") 254 251 255 252 if os.path.exists(SASMODELS_SOURCE_SESANSIMG): 256 print "Found img folder SASMODELS_SOURCE_SESANSIMG at ", SASMODELS_SOURCE_SESANSIMG253 print("Found img folder SASMODELS_SOURCE_SESANSIMG at", SASMODELS_SOURCE_SESANSIMG) 257 254 if not os.path.exists(SASMODELS_DEST_SESANSIMG): 258 print "Missing img folder SASMODELS_DEST_SESANSIMG at ", SASMODELS_DEST_SESANSIMG255 print("Missing img folder SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG) 259 256 os.makedirs(SASMODELS_DEST_SESANSIMG) 260 print "created SASMODELS_DEST_SESANSIMG at ", SASMODELS_DEST_SESANSIMG261 print "Copying sasmodels sesans image files..."257 print("created SASMODELS_DEST_SESANSIMG at", SASMODELS_DEST_SESANSIMG) 258 print("Copying sasmodels sesans image files...") 262 259 for files in os.listdir(SASMODELS_SOURCE_SESANSIMG): 263 260 fromhere=os.path.join(SASMODELS_SOURCE_SESANSIMG,files) 264 261 tohere=os.path.join(SASMODELS_DEST_SESANSIMG,files) 265 262 shutil.copy(fromhere,tohere) 266 else: print "no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found" 263 else: 264 print("no source directory",SASMODELS_SOURCE_SESANSIMG ,"was found") 267 265 268 266 if os.path.exists(SASMODELS_SOURCE_REF_MODELS): 269 print "Found docs folder SASMODELS_SOURCE_REF_MODELS at ", SASMODELS_SOURCE_REF_MODELS267 print("Found docs folder SASMODELS_SOURCE_REF_MODELS at", SASMODELS_SOURCE_REF_MODELS) 270 268 if os.path.exists(SASMODELS_DEST_REF_MODELS): 271 print "Found docs folder SASMODELS_DEST_REF_MODELS at ", SASMODELS_DEST_REF_MODELS272 print "Copying sasmodels model toctree files..."269 print("Found docs folder SASMODELS_DEST_REF_MODELS at", SASMODELS_DEST_REF_MODELS) 270 print("Copying sasmodels model toctree files...") 273 271 for files in os.listdir(SASMODELS_SOURCE_REF_MODELS): 274 272 if files.endswith(".rst"): … … 276 274 tohere=os.path.join(SASMODELS_DEST_REF_MODELS,files) 277 275 shutil.copy(fromhere,tohere) 278 # But need to change the path to the model docs in the tocs 279 for files in os.listdir(SASMODELS_DEST_REF_MODELS): 280 # print files 281 if files.startswith("shape"): 282 print "Changing toc paths in", files 283 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 284 if files.startswith("sphere"): 285 print "Changing toc paths in", files 286 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 287 if files.startswith("custom"): 288 print "Changing toc paths in", files 289 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 290 if files.startswith("structure"): 291 print "Changing toc paths in", files 292 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 276 # But need to change the path to the model docs in the tocs 277 for files in os.listdir(SASMODELS_DEST_REF_MODELS): 278 # print files 279 if files.startswith("shape"): 280 print("Changing toc paths in", files) 281 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 282 if files.startswith("sphere"): 283 print("Changing toc paths in", files) 284 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 285 if files.startswith("custom"): 286 print("Changing toc paths in", files) 287 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 288 if files.startswith("structure"): 289 print("Changing toc paths in", files) 290 inplace_change(os.path.join(SASMODELS_DEST_REF_MODELS,files), "../../model/", "models/") 291 else: 292 print("no source directory",SASMODELS_SOURCE_REF_MODELS," was found") 293 293 294 294 if os.path.exists(SASMODELS_SOURCE_MODELS): 295 print "Found docs folder SASMODELS_SOURCE_MODELS at ", SASMODELS_SOURCE_MODELS295 print("Found docs folder SASMODELS_SOURCE_MODELS at", SASMODELS_SOURCE_MODELS) 296 296 if os.path.exists(SASMODELS_DEST_MODELS): 297 print "Found docs folder SASMODELS_DEST_MODELS at ", SASMODELS_DEST_MODELS298 print "Copying sasmodels model files..."297 print("Found docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 298 print("Copying sasmodels model files...") 299 299 for files in os.listdir(SASMODELS_SOURCE_MODELS): 300 300 if files.endswith(".rst"): … … 303 303 shutil.copy(fromhere,tohere) 304 304 else: 305 print "Missing docs folder SASMODELS_DEST_MODELS at ", SASMODELS_DEST_MODELS305 print("Missing docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 306 306 os.makedirs(SASMODELS_DEST_MODELS) 307 307 if not os.path.exists(SASMODELS_DEST_BUILDIMG): 308 308 os.makedirs(SASMODELS_DEST_BUILDIMG) 309 print "Created docs folder SASMODELS_DEST_MODELS at ", SASMODELS_DEST_MODELS310 print "Copying model files for build..."309 print("Created docs folder SASMODELS_DEST_MODELS at", SASMODELS_DEST_MODELS) 310 print("Copying model files for build...") 311 311 for files in os.listdir(SASMODELS_SOURCE_MODELS): 312 312 if files.endswith(".rst"): … … 315 315 shutil.copy(fromhere,tohere) 316 316 # No choice but to do this because model files are all coded for images in /models/img 317 print "Copying image files for build..."317 print("Copying image files for build...") 318 318 for files in os.listdir(SASMODELS_DEST_IMG): 319 319 fromhere=os.path.join(SASMODELS_DEST_IMG,files) 320 320 tohere=os.path.join(SASMODELS_DEST_BUILDIMG,files) 321 321 shutil.copy(fromhere,tohere) 322 else: 323 print("no source directory",SASMODELS_SOURCE_MODELS,"was found.") 324 print("!!!!NO MODEL DOCS WILL BE BUILT!!!!") 322 325 323 326 … … 327 330 """ 328 331 if os.path.exists(BUMPS_DOCS): 329 print "=== Retrieve BUMPS Docs ==="332 print("=== Retrieve BUMPS Docs ===") 330 333 filenames = [os.path.join(BUMPS_DOCS, "optimizer.rst")] 331 334 filenames += glob(os.path.join(BUMPS_DOCS, "dream-*.png")) 332 335 filenames += glob(os.path.join(BUMPS_DOCS, "fit-*.png")) 333 336 for f in filenames: 334 print "Copying file", f337 print("Copying file", f) 335 338 shutil.copy(f, BUMPS_TARGET) 336 339 else: 337 print """ 338 *** Error *** missing directory %s 340 print(""" 341 ======= Error ======= 342 missing directory %s 339 343 The documentation will not include the optimizer selection section. 340 344 Checkout the bumps source tree and rebuild the docs. 341 342 343 """ % BUMPS_DOCS 345 """ % BUMPS_DOCS) 344 346 345 347 def apidoc(): … … 348 350 in the SasView build directory. 349 351 """ 350 print "=== Generate API Rest Files ==="352 print("=== Generate API Rest Files ===") 351 353 352 354 # Clean directory before generating a new version. … … 362 364 Runs sphinx-build. Reads in all .rst files and spits out the final html. 363 365 """ 364 print "=== Build HTML Docs from Rest Files ==="366 print("=== Build HTML Docs from Rest Files ===") 365 367 subprocess.call(["sphinx-build", 366 368 "-b", "html", # Builder name. TODO: accept as arg to setup.py. … … 369 371 os.path.join(SPHINX_BUILD, "html")]) 370 372 371 print "=== Copy HTML Docs to Build Directory ==="373 print("=== Copy HTML Docs to Build Directory ===") 372 374 html = os.path.join(SPHINX_BUILD, "html") 373 375 copy_tree(html, SASVIEW_DOCS) … … 381 383 build() 382 384 383 print "=== Done ==="385 print("=== Done ===") 384 386 385 387 if __name__ == "__main__": -
run.py
r64ca561 rf36e01f 1 # -*- coding: utf-8 -*- 1 2 #!/usr/bin/env python 3 2 4 """ 3 5 Run sasview in place. This allows sasview to use the python … … 14 16 """ 15 17 18 import imp 16 19 import os 17 20 import sys 18 import imp19 import logging20 import logging.config21 22 21 from contextlib import contextmanager 23 from os.path import abspath, dirname, join as joinpath 22 from os.path import join as joinpath 23 from os.path import abspath, dirname 24 24 25 25 26 LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sasview/logging.ini')27 logging.config.fileConfig(LOGGER_CONFIG_FILE, disable_existing_loggers=True)28 logger = logging.getLogger(__name__)29 30 def update_all_logs_to_debug(logger):31 '''32 This updates all loggers and respective handlers to DEBUG33 '''34 for handler in logger.handlers or logger.parent.handlers:35 handler.setLevel(logging.DEBUG)36 for name,_ in logging.Logger.manager.loggerDict.items():37 logging.getLogger(name).setLevel(logging.DEBUG)38 39 26 def addpath(path): 40 27 """ … … 50 37 sys.path.insert(0, path) 51 38 39 52 40 @contextmanager 53 41 def cd(path): … … 60 48 os.chdir(old_dir) 61 49 50 62 51 def import_package(modname, path): 63 52 """Import a package into a particular point in the python namespace""" 64 mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py')))53 mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py'))) 65 54 sys.modules[modname] = mod 66 55 mod.__path__ = [abspath(path)] 67 56 return mod 57 68 58 69 59 def import_dll(modname, build_path): … … 72 62 ext = sysconfig.get_config_var('SO') 73 63 # build_path comes from context 74 path = joinpath(build_path, *modname.split('.')) +ext75 # print "importing", modname, "from", path64 path = joinpath(build_path, *modname.split('.')) + ext 65 # print "importing", modname, "from", path 76 66 return imp.load_dynamic(modname, path) 67 77 68 78 69 def prepare(): … … 86 77 from distutils.util import get_platform 87 78 root = abspath(dirname(__file__)) 88 platform = '%s-%s' %(get_platform(),sys.version[:3])89 build_path = joinpath(root, 'build', 'lib.'+platform)79 platform = '%s-%s' % (get_platform(), sys.version[:3]) 80 build_path = joinpath(root, 'build', 'lib.' + platform) 90 81 91 82 # Notify the help menu that the Sphinx documentation is in a different … … 98 89 #if not os.path.exists(mplconfig): os.mkdir(mplconfig) 99 90 #import matplotlib 100 # matplotlib.use('Agg')101 # print matplotlib.__file__91 # matplotlib.use('Agg') 92 # print matplotlib.__file__ 102 93 #import pylab; pylab.hold(False) 103 94 # add periodictable to the path 104 try: import periodictable 105 except: addpath(joinpath(root, '..','periodictable')) 95 try: 96 import periodictable 97 except: 98 addpath(joinpath(root, '..', 'periodictable')) 106 99 107 try: import bumps 108 except: addpath(joinpath(root, '..','bumps')) 100 try: 101 import bumps 102 except: 103 addpath(joinpath(root, '..', 'bumps')) 109 104 110 105 # select wx version … … 126 121 # be better to just store the package in src/sas/sasview. 127 122 import sas 128 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview'))123 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview')) 129 124 130 125 # The sas.models package Compiled Model files should be pulled in from the build directory even though … … 135 130 import sas.sascalc.pr 136 131 sas.sascalc.pr.core = import_package('sas.sascalc.pr.core', 137 joinpath(build_path, 'sas', 'sascalc', 'pr', 'core'))132 joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 138 133 139 134 # Compiled modules need to be pulled from the build directory. … … 141 136 import sas.sascalc.file_converter 142 137 sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core', 143 joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))138 joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core')) 144 139 145 140 # Compiled modules need to be pulled from the build directory. … … 147 142 import sas.sascalc.calculator 148 143 sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core', 149 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core'))144 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 150 145 151 146 sys.path.append(build_path) 152 147 153 #print "\n".join(sys.path) 148 # print "\n".join(sys.path) 149 154 150 155 151 if __name__ == "__main__": 156 update_all_logs_to_debug(logger) 152 # Need to add absolute path before actual prepare call, 153 # so logging can be done during initialization process too 154 root = abspath(dirname(__file__)) 155 addpath(joinpath(root, 'sasview')) 156 from logger_config import SetupLogger 157 logger = SetupLogger(__name__).config_development() 158 159 logger.debug("Starting SASVIEW in debug mode.") 157 160 prepare() 158 161 from sas.sasview.sasview import run 159 162 run() 160 163 logger.debug("Ending SASVIEW in debug mode.") -
sasview/logging.ini
r64ca561 rfc22533 16 16 17 17 [formatter_detailed] 18 format=%(asctime)s:%(name)s:%(levelname)s: %(lineno)d: %(message)s 18 #format=%(asctime)s : %(levelname)s : %(name)s: %(lineno)d: %(message)s 19 format=%(asctime)s : %(levelname)s : %(name)s (%(filename)s:%(lineno)s) :: %(message)s 19 20 20 21 ############################################################################### … … 27 28 class=logging.StreamHandler 28 29 formatter=simple 29 level= INFO30 level=WARNING 30 31 args=tuple() 31 32 32 33 [handler_log_file] 33 34 class=logging.FileHandler 34 level= INFO35 level=DEBUG 35 36 formatter=detailed 36 37 args=(os.path.join(os.path.expanduser("~"),'sasview.log'),"a") … … 43 44 44 45 [logger_root] 45 level= INFO46 level=DEBUG 46 47 formatter=default 47 48 handlers=console,log_file … … 60 61 61 62 [logger_sasgui] 62 level= INFO63 level=DEBUG 63 64 qualname=sas.sasgui 64 65 handlers=console,log_file -
sasview/sasview.py
r3608cd1 rf36e01f 1 # -*- coding: utf-8 -*- 1 2 """ 2 3 Base module for loading and running the main SasView application. 3 4 """ 4 5 ################################################################################ 5 # This software was developed by the University of Tennessee as part of the6 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE)7 # project funded by the US National Science Foundation.6 # This software was developed by the University of Tennessee as part of the 7 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 8 # project funded by the US National Science Foundation. 8 9 # 9 # See the license text in license.txt10 # See the license text in license.txt 10 11 # 11 # copyright 2009, University of Tennessee12 # copyright 2009, University of Tennessee 12 13 ################################################################################ 13 14 import os 15 import os.path 14 16 import sys 15 import logging16 import logging.config17 17 import traceback 18 18 19 logger = logging.getLogger(__name__) 20 if not logger.root.handlers: 21 LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'logging.ini') 22 logging.config.fileConfig(LOGGER_CONFIG_FILE, disable_existing_loggers=False) 23 logging.captureWarnings(True) 19 from sas.sasview.logger_config import SetupLogger 20 21 logger = SetupLogger(__name__).config_production() 22 24 23 25 24 # Log the start of the session … … 55 54 import wxcruft 56 55 wxcruft.call_later_fix() 57 # wxcruft.trace_new_id()56 # wxcruft.trace_new_id() 58 57 59 # Always use private .matplotlib setup to avoid conflicts with other60 # uses of matplotlib61 # Have to check if .sasview exists first58 # Always use private .matplotlib setup to avoid conflicts with other 59 # uses of matplotlib 60 # Have to check if .sasview exists first 62 61 sasdir = os.path.join(os.path.expanduser("~"),'.sasview') 63 62 if not os.path.exists(sasdir): … … 72 71 from sas.sasgui.guiframe.gui_style import GUIFRAME 73 72 from welcome_panel import WelcomePanel 74 # For py2exe, import config here 75 import local_config 73 76 74 PLUGIN_MODEL_DIR = 'plugin_models' 77 75 APP_NAME = 'SasView' … … 87 85 """ 88 86 """ 89 # from gui_manager import ViewApp87 # from gui_manager import ViewApp 90 88 self.gui = gui_manager.SasViewApp(0) 91 89 # Set the application manager for the GUI … … 116 114 logger.error(traceback.format_exc()) 117 115 118 # Invariant perspective116 # Invariant perspective 119 117 try: 120 118 import sas.sasgui.perspectives.invariant as module … … 134 132 logger.error("Unable to load corfunc module") 135 133 136 # Calculator perspective134 # Calculator perspective 137 135 try: 138 136 import sas.sasgui.perspectives.calculator as module … … 153 151 APP_NAME) 154 152 logger.error(traceback.format_exc()) 155 156 153 157 154 # Add welcome page … … 174 171 if len(sys.argv) > 1: 175 172 ## Run sasview as an interactive python interpreter 176 # if sys.argv[1] == "-i":173 # if sys.argv[1] == "-i": 177 174 # sys.argv = ["ipython", "--pylab"] 178 175 # from IPython import start_ipython … … 188 185 SasView() 189 186 187 190 188 if __name__ == "__main__": 191 189 run() -
sasview/setup_exe.py
r8b645cc rf36e01f 62 62 sys.argv.remove('--extrapath') 63 63 except: 64 print 65 sys.exc_value 64 print("Error processing extra python path needed to build SasView\n %s" % \ 65 sys.exc_value) 66 66 67 67 … … 83 83 modulefinder.AddPackagePath(win32_folder, p) 84 84 for extra in ["win32com.shell", "win32com.adsi", "win32com.axcontrol", 85 "win32com.axscript", "win32com.bits", "win32com.ifilter", 86 "win32com.internet", "win32com.mapi", "win32com.propsys", 87 "win32com.taskscheduler"]: 88 89 __import__(extra) 90 m = sys.modules[extra] 91 for p in m.__path__[1:]: 92 modulefinder.AddPackagePath(extra, p) 85 "win32com.axscript", "win32com.bits", "win32com.ifilter", 86 "win32com.internet", "win32com.mapi", "win32com.propsys", 87 "win32com.taskscheduler"]: 88 __import__(extra) 89 m = sys.modules[extra] 90 for p in m.__path__[1:]: 91 modulefinder.AddPackagePath(extra, p) 93 92 94 93 except ImportError: … … 167 166 self.copyright = "copyright 2009 - 2016" 168 167 self.name = "SasView" 169 168 170 169 # 171 170 # Adapted from http://www.py2exe.org/index.cgi/MatPlotLib … … 236 235 data_files.append(('config', [f])) 237 236 f = 'local_config.py' 237 if os.path.isfile(f): 238 data_files.append(('.', [f])) 239 240 f = 'logging.ini' 238 241 if os.path.isfile(f): 239 242 data_files.append(('.', [f])) … … 337 340 ]) 338 341 packages.append('periodictable.core') # not found automatically 339 # packages.append('IPython')342 # packages.append('IPython') 340 343 includes = ['site', 'lxml._elementpath', 'lxml.etree'] 341 344 … … 370 373 other_resources = [(24, 1, manifest)], 371 374 dest_base = "SasView" 372 375 ) 373 376 374 377 # bundle_option = 2 -
sasview/setup_mac.py
r235f514 rcfa88ee 50 50 #CANSAxml reader data files 51 51 RESOURCES_FILES.append(os.path.join(sas.sascalc.dataloader.readers.get_data_path(),'defaults.json')) 52 53 DATA_FILES.append('logging.ini') 52 54 53 55 # Locate libxml2 library -
setup.py
rf3bf622 r14bb7a4 1 # -*- coding: utf-8 -*- 2 #!/usr/bin/env python 3 1 4 """ 2 5 Setup for SasView 3 #TODO: Add checks to see that all the dependencies are on the system6 TODO: Add checks to see that all the dependencies are on the system 4 7 """ 8 9 import os 10 import subprocess 11 import shutil 5 12 import sys 6 import os7 import shutil8 from setuptools import setup, Extension9 13 from distutils.command.build_ext import build_ext 10 14 from distutils.core import Command 15 11 16 import numpy as np 17 from setuptools import Extension, setup 12 18 13 19 # Manage version number ###################################### 14 20 import sasview 21 15 22 VERSION = sasview.__version__ 16 23 ############################################################## … … 25 32 # except when there is no such file 26 33 # Todo : make this list generic 27 # plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py',34 # plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 28 35 # 'sum_Ap1_1_Ap2.py', 'sum_p1_p2.py', 29 36 # 'testmodel_2.py', 'testmodel.py', … … 35 42 SASVIEW_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build") 36 43 37 sas_dir = os.path.join(os.path.expanduser("~"), '.sasview')44 sas_dir = os.path.join(os.path.expanduser("~"), '.sasview') 38 45 if os.path.isdir(sas_dir): 39 46 f_path = os.path.join(sas_dir, "sasview.log") … … 47 54 os.remove(f_path) 48 55 #f_path = os.path.join(sas_dir, 'plugin_models') 49 # if os.path.isdir(f_path):56 # if os.path.isdir(f_path): 50 57 # for f in os.listdir(f_path): 51 58 # if f in plugin_model_list: … … 53 60 # os.remove(file_path) 54 61 if os.path.exists(SASVIEW_BUILD): 55 print("Removing existing build directory", SASVIEW_BUILD, "for a clean build") 62 print("Removing existing build directory", 63 SASVIEW_BUILD, "for a clean build") 56 64 shutil.rmtree(SASVIEW_BUILD) 57 65 … … 63 71 enable_openmp = False 64 72 65 if sys.platform == 'darwin':73 if sys.platform == 'darwin': 66 74 if not is_64bits: 67 75 # Disable OpenMP … … 77 85 78 86 # Options to enable OpenMP 79 copt = 80 'mingw32': ['-fopenmp'],81 'unix': ['-fopenmp']}82 lopt = 83 'mingw32': ['-fopenmp'],84 'unix': ['-lgomp']}87 copt = {'msvc': ['/openmp'], 88 'mingw32': ['-fopenmp'], 89 'unix': ['-fopenmp']} 90 lopt = {'msvc': ['/MANIFEST'], 91 'mingw32': ['-fopenmp'], 92 'unix': ['-lgomp']} 85 93 86 94 # Platform-specific link options 87 platform_lopt = {'msvc' 95 platform_lopt = {'msvc': ['/MANIFEST']} 88 96 platform_copt = {} 89 97 90 98 # Set copts to get compile working on OS X >= 10.9 using clang 91 if sys.platform == 'darwin':99 if sys.platform == 'darwin': 92 100 try: 93 101 darwin_ver = int(os.uname()[2].split('.')[0]) 94 102 if darwin_ver >= 13 and darwin_ver < 14: 95 platform_copt = {'unix' : ['-Wno-error=unused-command-line-argument-hard-error-in-future']} 103 platform_copt = { 104 'unix': ['-Wno-error=unused-command-line-argument-hard-error-in-future']} 96 105 except: 97 106 print("PROBLEM determining Darwin version") 107 98 108 99 109 class DisableOpenMPCommand(Command): … … 114 124 pass 115 125 116 class build_ext_subclass( build_ext ): 126 127 class build_ext_subclass(build_ext): 117 128 def build_extensions(self): 118 129 # Get 64-bitness … … 124 135 if c in copt: 125 136 for e in self.extensions: 126 e.extra_compile_args = copt[ c]137 e.extra_compile_args = copt[c] 127 138 if c in lopt: 128 139 for e in self.extensions: 129 e.extra_link_args = lopt[ c]140 e.extra_link_args = lopt[c] 130 141 131 142 # Platform-specific build options 132 143 if c in platform_lopt: 133 144 for e in self.extensions: 134 e.extra_link_args = platform_lopt[ c]145 e.extra_link_args = platform_lopt[c] 135 146 136 147 if c in platform_copt: 137 148 for e in self.extensions: 138 e.extra_compile_args = platform_copt[ c ] 139 149 e.extra_compile_args = platform_copt[c] 140 150 141 151 build_ext.build_extensions(self) 152 142 153 143 154 class BuildSphinxCommand(Command): … … 152 163 153 164 def run(self): 165 ''' First builds the sasmodels documentation if the directory 166 is present. Then builds the sasview docs. 167 ''' 168 ### AJJ - Add code for building sasmodels docs here: 169 # check for doc path 170 SASMODELS_DOCPATH = os.path.abspath(os.path.join(os.getcwd(), '..', 'sasmodels', 'doc')) 171 print("========= check for sasmodels at", SASMODELS_DOCPATH, "============") 172 if os.path.exists(SASMODELS_DOCPATH): 173 if os.path.isdir(SASMODELS_DOCPATH): 174 # if available, build sasmodels docs 175 print("============= Building sasmodels model documentation ===============") 176 smdocbuild = subprocess.call(["make", "-C", SASMODELS_DOCPATH, "html"]) 177 else: 178 # if not available warning message 179 print("== !!WARNING!! sasmodels directory not found. Cannot build model docs. ==") 180 181 #Now build sasview (+sasmodels) docs 154 182 sys.path.append("docs/sphinx-docs") 155 183 import build_sphinx 156 184 build_sphinx.rebuild() 157 185 186 158 187 # sas module 159 188 package_dir["sas"] = os.path.join("src", "sas") … … 169 198 170 199 # sas.sascalc.invariant 171 package_dir["sas.sascalc.invariant"] = os.path.join("src", "sas", "sascalc", "invariant") 200 package_dir["sas.sascalc.invariant"] = os.path.join( 201 "src", "sas", "sascalc", "invariant") 172 202 packages.extend(["sas.sascalc.invariant"]) 173 203 … … 175 205 guiframe_path = os.path.join("src", "sas", "sasgui", "guiframe") 176 206 package_dir["sas.sasgui.guiframe"] = guiframe_path 177 package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join(os.path.join(guiframe_path, "local_perspectives")) 207 package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join( 208 os.path.join(guiframe_path, "local_perspectives")) 178 209 package_data["sas.sasgui.guiframe"] = ['images/*', 'media/*'] 179 packages.extend(["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) 210 packages.extend( 211 ["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) 180 212 # build local plugin 181 213 for d in os.listdir(os.path.join(guiframe_path, "local_perspectives")): 182 if d not in ['.svn', '__init__.py', '__init__.pyc']:214 if d not in ['.svn', '__init__.py', '__init__.pyc']: 183 215 package_name = "sas.sasgui.guiframe.local_perspectives." + d 184 216 packages.append(package_name) 185 package_dir[package_name] = os.path.join(guiframe_path, "local_perspectives", d) 217 package_dir[package_name] = os.path.join( 218 guiframe_path, "local_perspectives", d) 186 219 187 220 # sas.sascalc.dataloader 188 package_dir["sas.sascalc.dataloader"] = os.path.join("src", "sas", "sascalc", "dataloader") 189 package_data["sas.sascalc.dataloader.readers"] = ['defaults.json','schema/*.xsd'] 190 packages.extend(["sas.sascalc.dataloader","sas.sascalc.dataloader.readers","sas.sascalc.dataloader.readers.schema"]) 221 package_dir["sas.sascalc.dataloader"] = os.path.join( 222 "src", "sas", "sascalc", "dataloader") 223 package_data["sas.sascalc.dataloader.readers"] = [ 224 'defaults.json', 'schema/*.xsd'] 225 packages.extend(["sas.sascalc.dataloader", "sas.sascalc.dataloader.readers", 226 "sas.sascalc.dataloader.readers.schema"]) 227 191 228 192 229 # sas.sascalc.calculator 193 230 gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions") 194 231 package_dir["sas.sascalc.calculator.core"] = gen_dir 195 package_dir["sas.sascalc.calculator"] = os.path.join("src", "sas", "sascalc", "calculator") 196 packages.extend(["sas.sascalc.calculator","sas.sascalc.calculator.core"]) 197 ext_modules.append( Extension("sas.sascalc.calculator.core.sld2i", 198 sources = [ 199 os.path.join(gen_dir, "sld2i_module.cpp"), 200 os.path.join(gen_dir, "sld2i.cpp"), 201 os.path.join(gen_dir, "libfunc.c"), 202 os.path.join(gen_dir, "librefl.c"), 203 ], 204 include_dirs=[gen_dir], 205 ) 206 ) 232 package_dir["sas.sascalc.calculator"] = os.path.join( 233 "src", "sas", "sascalc", "calculator") 234 packages.extend(["sas.sascalc.calculator", "sas.sascalc.calculator.core"]) 235 ext_modules.append(Extension("sas.sascalc.calculator.core.sld2i", 236 sources=[ 237 os.path.join(gen_dir, "sld2i_module.cpp"), 238 os.path.join(gen_dir, "sld2i.cpp"), 239 os.path.join(gen_dir, "libfunc.c"), 240 os.path.join(gen_dir, "librefl.c"), 241 ], 242 include_dirs=[gen_dir], 243 ) 244 ) 207 245 208 246 # sas.sascalc.pr 209 srcdir 247 srcdir = os.path.join("src", "sas", "sascalc", "pr", "c_extensions") 210 248 package_dir["sas.sascalc.pr.core"] = srcdir 211 package_dir["sas.sascalc.pr"] = os.path.join("src","sas", "sascalc", "pr") 212 packages.extend(["sas.sascalc.pr","sas.sascalc.pr.core"]) 213 ext_modules.append( Extension("sas.sascalc.pr.core.pr_inversion", 214 sources = [os.path.join(srcdir, "Cinvertor.c"), 215 os.path.join(srcdir, "invertor.c"), 216 ], 217 include_dirs=[], 218 ) ) 249 package_dir["sas.sascalc.pr"] = os.path.join("src", "sas", "sascalc", "pr") 250 packages.extend(["sas.sascalc.pr", "sas.sascalc.pr.core"]) 251 ext_modules.append(Extension("sas.sascalc.pr.core.pr_inversion", 252 sources=[os.path.join(srcdir, "Cinvertor.c"), 253 os.path.join(srcdir, "invertor.c"), 254 ], 255 include_dirs=[], 256 )) 257 219 258 220 259 # sas.sascalc.file_converter 221 260 mydir = os.path.join("src", "sas", "sascalc", "file_converter", "c_ext") 222 261 package_dir["sas.sascalc.file_converter.core"] = mydir 223 package_dir["sas.sascalc.file_converter"] = os.path.join("src","sas", "sascalc", "file_converter") 224 packages.extend(["sas.sascalc.file_converter","sas.sascalc.file_converter.core"]) 225 ext_modules.append( Extension("sas.sascalc.file_converter.core.bsl_loader", 226 sources = [os.path.join(mydir, "bsl_loader.c")], 227 include_dirs=[np.get_include()], 228 ) ) 229 230 #sas.sascalc.corfunc 231 package_dir["sas.sascalc.corfunc"] = os.path.join("src", "sas", "sascalc", "corfunc") 262 package_dir["sas.sascalc.file_converter"] = os.path.join( 263 "src", "sas", "sascalc", "file_converter") 264 packages.extend(["sas.sascalc.file_converter", 265 "sas.sascalc.file_converter.core"]) 266 ext_modules.append(Extension("sas.sascalc.file_converter.core.bsl_loader", 267 sources=[os.path.join(mydir, "bsl_loader.c")], 268 include_dirs=[np.get_include()], 269 )) 270 271 # sas.sascalc.corfunc 272 package_dir["sas.sascalc.corfunc"] = os.path.join( 273 "src", "sas", "sascalc", "corfunc") 274 232 275 packages.extend(["sas.sascalc.corfunc"]) 233 276 … … 237 280 238 281 # Perspectives 239 package_dir["sas.sasgui.perspectives"] = os.path.join("src", "sas", "sasgui", "perspectives") 240 package_dir["sas.sasgui.perspectives.pr"] = os.path.join("src", "sas", "sasgui", "perspectives", "pr") 241 packages.extend(["sas.sasgui.perspectives","sas.sasgui.perspectives.pr"]) 282 package_dir["sas.sasgui.perspectives"] = os.path.join( 283 "src", "sas", "sasgui", "perspectives") 284 package_dir["sas.sasgui.perspectives.pr"] = os.path.join( 285 "src", "sas", "sasgui", "perspectives", "pr") 286 packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.pr"]) 242 287 package_data["sas.sasgui.perspectives.pr"] = ['media/*'] 243 288 244 package_dir["sas.sasgui.perspectives.invariant"] = os.path.join("src", "sas", "sasgui", "perspectives", "invariant") 289 package_dir["sas.sasgui.perspectives.invariant"] = os.path.join( 290 "src", "sas", "sasgui", "perspectives", "invariant") 245 291 packages.extend(["sas.sasgui.perspectives.invariant"]) 246 package_data['sas.sasgui.perspectives.invariant'] = [os.path.join("media",'*')] 247 248 package_dir["sas.sasgui.perspectives.fitting"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting") 249 package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 250 packages.extend(["sas.sasgui.perspectives.fitting", "sas.sasgui.perspectives.fitting.plugin_models"]) 251 package_data['sas.sasgui.perspectives.fitting'] = ['media/*', 'plugin_models/*'] 252 253 packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.calculator"]) 292 package_data['sas.sasgui.perspectives.invariant'] = [ 293 os.path.join("media", '*')] 294 295 package_dir["sas.sasgui.perspectives.fitting"] = os.path.join( 296 "src", "sas", "sasgui", "perspectives", "fitting") 297 package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join( 298 "src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 299 packages.extend(["sas.sasgui.perspectives.fitting", 300 "sas.sasgui.perspectives.fitting.plugin_models"]) 301 package_data['sas.sasgui.perspectives.fitting'] = [ 302 'media/*', 'plugin_models/*'] 303 304 packages.extend(["sas.sasgui.perspectives", 305 "sas.sasgui.perspectives.calculator"]) 254 306 package_data['sas.sasgui.perspectives.calculator'] = ['images/*', 'media/*'] 255 307 256 package_dir["sas.sasgui.perspectives.corfunc"] = os.path.join("src", "sas", "sasgui", "perspectives", "corfunc") 308 package_dir["sas.sasgui.perspectives.corfunc"] = os.path.join( 309 "src", "sas", "sasgui", "perspectives", "corfunc") 257 310 packages.extend(["sas.sasgui.perspectives.corfunc"]) 258 311 package_data['sas.sasgui.perspectives.corfunc'] = ['media/*'] 259 312 260 package_dir["sas.sasgui.perspectives.file_converter"] = os.path.join("src", "sas", "sasgui", "perspectives", "file_converter") 313 package_dir["sas.sasgui.perspectives.file_converter"] = os.path.join( 314 "src", "sas", "sasgui", "perspectives", "file_converter") 261 315 packages.extend(["sas.sasgui.perspectives.file_converter"]) 262 316 package_data['sas.sasgui.perspectives.file_converter'] = ['media/*'] 263 317 264 318 # Data util 265 package_dir["sas.sascalc.data_util"] = os.path.join("src", "sas", "sascalc", "data_util") 319 package_dir["sas.sascalc.data_util"] = os.path.join( 320 "src", "sas", "sascalc", "data_util") 266 321 packages.append("sas.sascalc.data_util") 267 322 268 323 # Plottools 269 package_dir["sas.sasgui.plottools"] = os.path.join("src", "sas", "sasgui", "plottools") 324 package_dir["sas.sasgui.plottools"] = os.path.join( 325 "src", "sas", "sasgui", "plottools") 270 326 packages.append("sas.sasgui.plottools") 271 327 … … 275 331 276 332 EXTENSIONS = [".c", ".cpp"] 333 277 334 278 335 def append_file(file_list, dir_path): … … 294 351 file_list.append(os.path.join(sub_dir, new_f)) 295 352 353 296 354 # Comment out the following to avoid rebuilding all the models 297 355 file_sources = [] 298 356 append_file(file_sources, gen_dir) 299 357 300 # Wojtek's hacky way to add doc files while bundling egg301 # def add_doc_files(directory):358 # Wojtek's hacky way to add doc files while bundling egg 359 # def add_doc_files(directory): 302 360 # paths = [] 303 361 # for (path, directories, filenames) in os.walk(directory): … … 312 370 package_data['sas.sasview'] = ['images/*', 313 371 'media/*', 372 'logging.ini', 314 373 'test/*.txt', 315 374 'test/1d_data/*', … … 331 390 'lxml', 'h5py', 332 391 333 # #The following dependecies won't install automatically, so assume them334 # #The numbers should be bumped up for matplotlib and wxPython as well.392 # The following dependecies won't install automatically, so assume them 393 # The numbers should be bumped up for matplotlib and wxPython as well. 335 394 # 'numpy>=1.4.1', 'scipy>=0.7.2', 'matplotlib>=0.99.1.1', 336 395 # 'wxPython>=2.8.11', 'pil', 337 338 339 if os.name =='nt':396 ] 397 398 if os.name == 'nt': 340 399 required.extend(['html5lib', 'reportlab']) 341 400 else: … … 346 405 setup( 347 406 name="sasview", 348 version =VERSION,349 description ="SasView application",350 author ="SasView Team",351 author_email ="developers@sasview.org",352 url ="http://sasview.org",353 license ="PSF",354 keywords ="small-angle x-ray and neutron scattering analysis",355 download_url ="https://github.com/SasView/sasview.git",356 package_dir =package_dir,357 packages =packages,358 package_data =package_data,359 ext_modules =ext_modules,360 install_requires =required,361 zip_safe =False,362 entry_points ={363 'console_scripts':[364 365 366 367 cmdclass ={'build_ext': build_ext_subclass,368 369 370 407 version=VERSION, 408 description="SasView application", 409 author="SasView Team", 410 author_email="developers@sasview.org", 411 url="http://sasview.org", 412 license="PSF", 413 keywords="small-angle x-ray and neutron scattering analysis", 414 download_url="https://github.com/SasView/sasview.git", 415 package_dir=package_dir, 416 packages=packages, 417 package_data=package_data, 418 ext_modules=ext_modules, 419 install_requires=required, 420 zip_safe=False, 421 entry_points={ 422 'console_scripts': [ 423 "sasview = sas.sasview.sasview:run", 424 ] 425 }, 426 cmdclass={'build_ext': build_ext_subclass, 427 'docs': BuildSphinxCommand, 428 'disable_openmp': DisableOpenMPCommand} 429 ) -
src/sas/sasgui/guiframe/gui_manager.py
r49165488 r38beeab 77 77 # clean all these module variables and put them into a config class 78 78 # that can be passed by sasview.py. 79 logger. info(sys.executable)80 logger. info(str(sys.argv))79 logger.debug(sys.executable) 80 logger.debug(str(sys.argv)) 81 81 from sas import sasview as sasview 82 82 app_path = os.path.dirname(sasview.__file__) 83 logger. info("Using application path: %s", app_path)83 logger.debug("Using application path: %s", app_path) 84 84 return app_path 85 85 … … 109 109 if fObj is not None: 110 110 fObj.close() 111 logger. info("GuiManager loaded %s/%s" % (path, file))111 logger.debug("GuiManager loaded %s/%s" % (path, file)) 112 112 return config_module 113 113 … … 126 126 # Didn't find local config, load the default 127 127 import sas.sasgui.guiframe.config as config 128 logger. info("using default local_config")128 logger.debug("using default local_config") 129 129 else: 130 logger. info("found local_config in %s" % os.getcwd())130 logger.debug("found local_config in %s" % os.getcwd()) 131 131 else: 132 logger. info("found local_config in %s" % PATH_APP)132 logger.debug("found local_config in %s" % PATH_APP) 133 133 134 134 from sas.sasgui.guiframe.customdir import SetupCustom … … 139 139 if custom_config is None: 140 140 msgConfig = "Custom_config file was not imported" 141 logger. info(msgConfig)141 logger.debug(msgConfig) 142 142 else: 143 logger. info("using custom_config in %s" % os.getcwd())143 logger.debug("using custom_config in %s" % os.getcwd()) 144 144 else: 145 logger. info("using custom_config from %s" % c_conf_dir)145 logger.debug("using custom_config from %s" % c_conf_dir) 146 146 147 147 # read some constants from config … … 2156 2156 if response is not None: 2157 2157 try: 2158 #2159 2158 content = response.read().strip() 2160 logger.info("Connected to www.sasview.org. Latest version: %s" 2161 % (content)) 2159 logger.info("Connected to www.sasview.org. Latest version: %s", content) 2162 2160 version_info = json.loads(content) 2163 2161 except: -
src/sas/sasgui/perspectives/calculator/sld_panel.py
r7432acb rfe09e9b 60 60 # Object that receive status event 61 61 self.base = base 62 self.wavelength = WAVELENGTH 62 self.neutron_wavelength = WAVELENGTH 63 self.xray_source_input = WAVELENGTH 63 64 self.parent = parent 64 65 #layout attribute … … 67 68 self.compound = "" 68 69 self.density = "" 69 self.wavelength_ctl = None 70 self.neutron_wavelength_ctl = None 71 self.xray_source_input_ctl = None 72 self.xray_cbox = None 70 73 self.neutron_sld_real_ctl = None 71 74 self.neutron_sld_im_ctl = None 72 self.mo_ka_sld_real_ctl = None 73 self.mo_ka_sld_im_ctl = None 74 self.cu_ka_sld_real_ctl = None 75 self.cu_ka_sld_im_ctl = None 75 self.xray_sld_real_ctl = None 76 self.xray_sld_im_ctl = None 76 77 self.neutron_abs_ctl = None 77 78 self.neutron_inc_ctl = None 78 79 self.neutron_length_ctl = None 79 80 self.button_calculate = None 81 self.xray_source = None 80 82 #Draw the panel 81 83 self._do_layout() 82 84 self.SetAutoLayout(True) 83 85 self.Layout() 86 self.fill_xray_cbox() 84 87 85 88 def _do_layout(self): … … 108 111 self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 109 112 unit_density_txt = wx.StaticText(self, -1, unit_density) 110 wavelength_txt = wx.StaticText(self, -1, 'Wavelength ') 111 self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 112 self.wavelength_ctl.SetValue(str(self.wavelength)) 113 unit_a_txt = wx.StaticText(self, -1, unit_a) 113 neutron_wavelength_txt = wx.StaticText(self, -1, 'Neutron wavelength') 114 self.neutron_wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 115 self.neutron_wavelength_ctl.SetValue(str(self.neutron_wavelength)) 116 self.xray_source_input_txt = wx.StaticText(self, -1, 'X-ray wavelength') 117 self.xray_source_input_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 118 self.xray_source_input_ctl.SetValue(str(self.xray_source_input)) 119 neutron_unit_a_txt = wx.StaticText(self, -1, unit_a) 120 121 self.xray_cbox = wx.ComboBox(self, -1, size=(70, 20), style=wx.CB_READONLY) 122 xray_cbox_tip = "Select an element, wavelength or energy" 123 self.xray_cbox.SetToolTipString(xray_cbox_tip) 124 wx.EVT_COMBOBOX(self.xray_cbox, -1, self.on_select_xray) 125 114 126 iy = 0 115 127 ix = 0 … … 131 143 iy += 1 132 144 ix = 0 133 sizer_input.Add(wavelength_txt, (iy, ix), (1, 1), 134 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 135 ix += 1 136 sizer_input.Add(self.wavelength_ctl, (iy, ix), (1, 1), 137 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 138 ix += 1 139 sizer_input.Add(unit_a_txt, (iy, ix), (1, 1), 145 sizer_input.Add(neutron_wavelength_txt, (iy, ix), (1, 1), 146 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 147 ix += 1 148 sizer_input.Add(self.neutron_wavelength_ctl, (iy, ix), (1, 1), 149 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 150 ix += 1 151 sizer_input.Add(neutron_unit_a_txt, (iy, ix), (1, 1), 152 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 153 iy += 1 154 ix = 0 155 sizer_input.Add(self.xray_source_input_txt, (iy, ix), (1, 1), 156 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 157 ix += 1 158 sizer_input.Add(self.xray_source_input_ctl, (iy, ix), (1, 1), 159 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 160 ix += 1 161 sizer_input.Add(self.xray_cbox, (iy, ix), (1, 1), 140 162 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 141 163 boxsizer1.Add(sizer_input) … … 151 173 size=(_BOX_WIDTH, -1)) 152 174 self.neutron_sld_real_ctl.SetEditable(False) 153 self.neutron_sld_real_ctl.SetToolTipString("Neutron SLD real .")175 self.neutron_sld_real_ctl.SetToolTipString("Neutron SLD real") 154 176 self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, 155 177 size=(_BOX_WIDTH, -1)) 156 178 self.neutron_sld_im_ctl.SetEditable(False) 157 self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary .")179 self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary") 158 180 neutron_sld_units_txt = wx.StaticText(self, -1, unit_sld) 159 181 160 cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu KaSLD')161 self. cu_ka_sld_real_ctl = wx.TextCtrl(self, -1,182 xray_sld_txt = wx.StaticText(self, -1, 'X-ray SLD') 183 self.xray_sld_real_ctl = wx.TextCtrl(self, -1, 162 184 size=(_BOX_WIDTH, -1)) 163 self. cu_ka_sld_real_ctl.SetEditable(False)164 self. cu_ka_sld_real_ctl.SetToolTipString("Cu Ka SLD real.")165 self. cu_ka_sld_im_ctl = wx.TextCtrl(self, -1,185 self.xray_sld_real_ctl.SetEditable(False) 186 self.xray_sld_real_ctl.SetToolTipString("X-ray SLD real") 187 self.xray_sld_im_ctl = wx.TextCtrl(self, -1, 166 188 size=(_BOX_WIDTH, -1)) 167 self.cu_ka_sld_im_ctl.SetEditable(False) 168 self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.") 169 cu_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) 170 171 mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') 172 self.mo_ka_sld_real_ctl = wx.TextCtrl(self, -1, 173 size=(_BOX_WIDTH, -1)) 174 self.mo_ka_sld_real_ctl.SetEditable(False) 175 self.mo_ka_sld_real_ctl.SetToolTipString("Mo Ka SLD real.") 176 self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, 177 size=(_BOX_WIDTH, -1)) 178 self.mo_ka_sld_im_ctl.SetEditable(False) 179 self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD imaginary.") 180 mo_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) 189 self.xray_sld_im_ctl.SetEditable(False) 190 self.xray_sld_im_ctl.SetToolTipString("X-ray SLD imaginary") 191 xray_sld_units_txt = wx.StaticText(self, -1, unit_sld) 181 192 182 193 neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs') … … 219 230 iy += 1 220 231 ix = 0 221 sizer_output.Add( cu_ka_sld_txt, (iy, ix), (1, 1),222 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 223 ix += 1 224 sizer_output.Add(self. cu_ka_sld_real_ctl, (iy, ix), (1, 1),232 sizer_output.Add(xray_sld_txt, (iy, ix), (1, 1), 233 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 234 ix += 1 235 sizer_output.Add(self.xray_sld_real_ctl, (iy, ix), (1, 1), 225 236 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 226 237 ix += 1 … … 228 239 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 229 240 ix += 1 230 sizer_output.Add(self. cu_ka_sld_im_ctl,241 sizer_output.Add(self.xray_sld_im_ctl, 231 242 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 232 243 ix += 1 233 sizer_output.Add(cu_ka_sld_units_txt, 234 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 235 iy += 1 236 ix = 0 237 sizer_output.Add(mo_ka_sld_txt, (iy, ix), (1, 1), 238 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 239 ix += 1 240 sizer_output.Add(self.mo_ka_sld_real_ctl, (iy, ix), (1, 1), 241 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 242 ix += 1 243 sizer_output.Add(wx.StaticText(self, -1, i_complex), 244 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 245 ix += 1 246 sizer_output.Add(self.mo_ka_sld_im_ctl, 247 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 248 ix += 1 249 sizer_output.Add(mo_ka_sld_units_txt, 244 sizer_output.Add(xray_sld_units_txt, 250 245 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 251 246 iy += 1 … … 310 305 self.SetSizer(vbox) 311 306 307 def fill_xray_cbox(self): 308 """ 309 fill the x-ray combobox with the sources 310 """ 311 source_list = ['[A]', '[keV]', 'Element'] 312 for source in source_list: 313 pos = self.xray_cbox.Append(str(source)) 314 self.xray_cbox.SetClientData(pos, str(source.strip())) 315 self.xray_cbox.SetSelection(0) 316 self.xray_source = source_list[0] 317 318 def on_select_xray(self, event=None): 319 """ 320 On Selecting a source 321 """ 322 item = event.GetEventObject() 323 self.xray_source = item.GetValue().strip() 324 325 if self.xray_source == "[A]": 326 self.xray_source_input_txt.SetLabel("X-ray wavelength") 327 elif self.xray_source == "[keV]": 328 self.xray_source_input_txt.SetLabel("X-ray energy") 329 elif self.xray_source == "Element": 330 self.xray_source_input_txt.SetLabel("X-ray source") 331 312 332 def on_help(self, event): 313 333 """ … … 363 383 msg += "Error for Density value :expect float" 364 384 365 self.wavelength = self.wavelength_ctl.GetValue() 366 if str(self.wavelength).lstrip().rstrip() == "": 367 self.wavelength = WAVELENGTH 368 self.wavelength_ctl.SetValue(str(WAVELENGTH)) 369 self.wavelength_ctl.SetBackgroundColour(wx.WHITE) 370 self.wavelength_ctl.Refresh() 385 self.neutron_wavelength = self.neutron_wavelength_ctl.GetValue() 386 self.xray_source_input = self.xray_source_input_ctl.GetValue() 387 388 if str(self.neutron_wavelength).lstrip().rstrip() == "": 389 self.neutron_wavelength = WAVELENGTH 390 self.neutron_wavelength_ctl.SetValue(str(WAVELENGTH)) 391 self.neutron_wavelength_ctl.SetBackgroundColour(wx.WHITE) 392 self.neutron_wavelength_ctl.Refresh() 371 393 msg += "Default value for wavelength is 6.0" 372 394 else: 373 if check_float(self. wavelength_ctl):374 self. wavelength = float(self.wavelength)395 if check_float(self.neutron_wavelength_ctl): 396 self.neutron_wavelength = float(self.neutron_wavelength) 375 397 else: 376 398 flag = False 377 399 msg += "Error for wavelength value :expect float" 400 401 if str(self.xray_source_input).lstrip().rstrip() == "": 402 self.xray_source_input = WAVELENGTH 403 self.xray_source_input_ctl.SetValue(str(WAVELENGTH)) 404 self.xray_source_input_ctl.SetBackgroundColour(wx.WHITE) 405 self.xray_source_input_ctl.Refresh() 406 msg += "Default value for wavelength is 6.0" 407 else: 408 if (self.xray_source == '[A]') or (self.xray_source == '[keV]'): 409 if check_float(self.xray_source_input_ctl): 410 self.xray_source_input = float(self.xray_source_input) 411 else: 412 flag = False 413 msg += "Error for wavelength value :expect float" 414 elif (self.xray_source == 'Element'): 415 try: 416 import periodictable 417 exec("periodictable." + self.xray_source_input) 418 except AttributeError: 419 flag = False 420 msg += "X-ray element supplied isn't in the database" 421 422 378 423 379 424 self.compound = self.compound_ctl.GetValue().lstrip().rstrip() … … 410 455 return xray_sld_from_atoms(atom, density=density, energy=energy) 411 456 412 413 457 def calculateSld(self, event): 414 458 """ … … 430 474 length = neutron_scattering(compound=self.compound, 431 475 density=self.density, 432 wavelength=self.wavelength) 433 cu_real, cu_im = self.calculate_sld_helper(element="Cu", 434 density=self.density, 435 molecule_formula=self.sld_formula) 436 mo_real, mo_im = self.calculate_sld_helper(element="Mo", 437 density=self.density, 438 molecule_formula=self.sld_formula) 476 wavelength=self.neutron_wavelength) 477 if self.xray_source == "[A]": 478 energy = xray_energy(self.xray_source_input) 479 xray_real, xray_im = xray_sld_from_atoms(self.sld_formula.atoms, 480 density=self.density, 481 energy=energy) 482 elif self.xray_source == "[keV]": 483 xray_real, xray_im = xray_sld_from_atoms(self.sld_formula.atoms, 484 density=self.density, 485 energy=self.xray_source_input) 486 elif self.xray_source == "Element": 487 xray_real, xray_im = self.calculate_sld_helper(element=self.xray_source_input, 488 density=self.density, 489 molecule_formula=self.sld_formula) 439 490 # set neutron sld values 440 491 val = format_number(sld_real * _SCALE) … … 443 494 self.neutron_sld_im_ctl.SetValue(val) 444 495 # Compute the Cu SLD 445 self.cu_ka_sld_real_ctl.SetValue(format_number(cu_real * _SCALE)) 446 val = format_number(math.fabs(cu_im) * _SCALE) 447 self.cu_ka_sld_im_ctl.SetValue(val) 448 # Compute the Mo SLD 449 self.mo_ka_sld_real_ctl.SetValue(format_number(mo_real * _SCALE)) 450 val = format_number(math.fabs(mo_im) * _SCALE) 451 self.mo_ka_sld_im_ctl.SetValue(val) 496 self.xray_sld_real_ctl.SetValue(format_number(xray_real * _SCALE)) 497 val = format_number(math.fabs(xray_im) * _SCALE) 498 self.xray_sld_im_ctl.SetValue(val) 452 499 # set incoherence and absorption 453 500 self.neutron_inc_ctl.SetValue(format_number(incoh)) … … 456 503 self.neutron_length_ctl.SetValue(format_number(length)) 457 504 # display wavelength 458 self.wavelength_ctl.SetValue(str(self.wavelength)) 505 #self.wavelength_ctl.SetValue(str(self.wavelength)) 506 #self.wavelength_ctl.SetValue(str(self.wavelength)) 459 507 except: 460 508 if self.base is not None: … … 470 518 self.neutron_sld_real_ctl.SetValue("") 471 519 self.neutron_sld_im_ctl.SetValue("") 472 self.mo_ka_sld_real_ctl.SetValue("") 473 self.mo_ka_sld_im_ctl.SetValue("") 474 self.cu_ka_sld_real_ctl.SetValue("") 475 self.cu_ka_sld_im_ctl.SetValue("") 520 self.xray_sld_real_ctl.SetValue("") 521 self.xray_sld_im_ctl.SetValue("") 476 522 self.neutron_abs_ctl.SetValue("") 477 523 self.neutron_inc_ctl.SetValue("")
Note: See TracChangeset
for help on using the changeset viewer.