Changeset 5d1c1f4 in sasview for fittingview/src/sans/perspectives/fitting/models.py
- Timestamp:
- Dec 7, 2011 2:56:35 PM (12 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 8bac371
- Parents:
- a41034c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/models.py
r4ad076b r5d1c1f4 10 10 import time 11 11 import logging 12 12 import py_compile 13 13 from sans.guiframe.events import StatusEvent 14 14 # Explicitly import from the pluginmodel module so that py2exe … … 69 69 return model 70 70 71 72 def _findModels(dir): 73 """ 74 """ 75 # List of plugin objects 76 plugins = {} 77 # Go through files in plug-in directory 78 #always recompile the folder plugin 79 import compileall 71 def find_plugins_dir(): 72 """ 73 Find path of the plugins dir 74 """ 80 75 dir = os.path.abspath(PLUGIN_DIR) 81 76 if not os.path.isdir(dir): … … 85 80 if not os.path.isdir(dir): 86 81 dir = os.path.join(os.path.dirname(os.path.sys.path[0]), PLUGIN_DIR) 82 return dir 83 84 class ReportProblem: 85 def __nonzero__(self): 86 type, value, traceback = sys.exc_info() 87 if type is not None and issubclass(type, py_compile.PyCompileError): 88 print "Problem with", repr(value) 89 raise type, value, traceback 90 return 1 91 92 report_problem = ReportProblem() 93 94 def compile_file(dir): 95 """ 96 Compile a py file 97 """ 98 try: 99 import compileall 100 compileall.compile_dir(dir=dir, ddir=dir, force=1, quiet=report_problem) 101 except: 102 type, value, traceback = sys.exc_info() 103 return value 104 return None 105 106 def _findModels(dir): 107 """ 108 """ 109 # List of plugin objects 110 plugins = {} 111 # Go through files in plug-in directory 112 #always recompile the folder plugin 113 import compileall 114 dir = find_plugins_dir() 87 115 if not os.path.isdir(dir): 88 116 msg = "SansView couldn't locate Model plugin folder." … … 92 120 else: 93 121 log("looking for models in: %s" % str(dir)) 94 compile all.compile_dir(dir=dir, ddir=dir, force=1, quiet=True)122 compile_file(dir) 95 123 logging.info("pluging model dir: %s\n" % str(dir)) 96 124 try: … … 438 466 is_modified = False 439 467 if os.path.isdir(PLUGIN_DIR): 440 temp = os.path.getmtime(PLUGIN_DIR) 468 # getmtime doesn't seem to work well: use getatime 469 temp = os.path.getatime(PLUGIN_DIR) 441 470 if self.last_time_dir_modified != temp: 442 471 is_modified = True … … 460 489 else: 461 490 return {} 462 491 492 463 493 def populate_menu(self, modelmenu, event_owner): 464 494 """
Note: See TracChangeset
for help on using the changeset viewer.