- Timestamp:
- Apr 1, 2015 12:57:33 PM (10 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:
- 5f0be1f
- Parents:
- c4a7660
- Location:
- src/sas
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/gui_manager.py
r091e71a2 r415fb82 897 897 # Go through files in panels directory 898 898 try: 899 file_list = os.listdir(dir) 899 if os.path.isdir(dir): 900 file_list = os.listdir(dir) 901 else: 902 file_list = [] 900 903 ## the default panel is the panel is the last plugin added 901 904 for item in file_list: … … 2019 2022 Quit the application 2020 2023 """ 2024 logging.info(" --- SasView session was closed --- \n") 2021 2025 wx.Exit() 2022 2026 sys.exit() -
src/sas/perspectives/fitting/models.py
r2f4b430 r415fb82 6 6 import os 7 7 import sys 8 import math9 8 import os.path 10 9 # Time is needed by the log method … … 13 12 import py_compile 14 13 import shutil 15 from sas.guiframe.events import StatusEvent16 14 # Explicitly import from the pluginmodel module so that py2exe 17 15 # places it in the distribution. The Model1DPlugin class is used 18 16 # as the base class of plug-in models. 19 17 from sas.models.pluginmodel import Model1DPlugin 20 from sas.models.BaseComponent import BaseComponent21 18 from sas.guiframe.CategoryInstaller import CategoryInstaller 22 19 … … 24 21 25 22 def get_model_python_path(): 23 """ 24 Returns the python path for a model 25 """ 26 26 return os.path.dirname(__file__) 27 27 … … 60 60 except: 61 61 msg = "Plugin %s error in __init__ \n\t: %s %s\n" % (str(name), 62 str(sys.exc_type), sys.exc_value) 62 str(sys.exc_type), 63 sys.exc_info()[1]) 63 64 log(msg) 64 65 return None … … 68 69 value = new_instance.function() 69 70 except: 70 msg = "Plugin %s: error writing function \n\t :%s %s\n " % (str(name),71 str(sys.exc_type), sys.exc_value)71 msg = "Plugin %s: error writing function \n\t :%s %s\n " % \ 72 (str(name), str(sys.exc_type), sys.exc_info()[1]) 72 73 log(msg) 73 74 return None … … 126 127 127 128 class ReportProblem: 129 """ 130 Class to check for problems with specific values 131 """ 128 132 def __nonzero__(self): 129 133 type, value, traceback = sys.exc_info() … … 145 149 quiet=report_problem) 146 150 except: 147 type, value, traceback = sys.exc_info() 148 return value 151 return sys.exc_info()[1] 149 152 return None 150 153 … … 155 158 # List of plugin objects 156 159 plugins = {} 160 dir = find_plugins_dir() 157 161 # Go through files in plug-in directory 158 162 #always recompile the folder plugin 159 dir = find_plugins_dir()160 163 if not os.path.isdir(dir): 161 164 msg = "SasView couldn't locate Model plugin folder." … … 166 169 log("looking for models in: %s" % str(dir)) 167 170 compile_file(dir) 168 logging.info("plugin g model dir: %s\n" % str(dir))171 logging.info("plugin model dir: %s" % str(dir)) 169 172 try: 170 173 list = os.listdir(dir) … … 186 189 msg = "Error accessing Model" 187 190 msg += "in %s\n %s %s\n" % (name, 188 str(sys.exc_type), sys.exc_value) 191 str(sys.exc_type), 192 sys.exc_info()[1]) 189 193 log(msg) 190 194 except: 191 195 msg = "Error accessing Model" 192 196 msg += " in %s\n %s %s \n" % (name, 193 str(sys.exc_type), sys.exc_value) 197 str(sys.exc_type), 198 sys.exc_info()[1]) 194 199 log(msg) 195 200 finally: … … 199 204 except: 200 205 # Don't deal with bad plug-in imports. Just skip. 201 msg = "Could not import model plugin: %s \n" % sys.exc_value206 msg = "Could not import model plugin: %s" % sys.exc_info()[1] 202 207 log(msg) 203 pass204 208 return plugins 205 209 … … 247 251 ## dictionary of structure factor models 248 252 struct_factor_dict = {} 249 ##list of shape models -- this is superseded by categories 253 ##list of shape models -- this is superseded by categories 250 254 # shape_list = [] 251 255 ## shape independent model list-- this is superseded by categories … … 278 282 if self.is_changed(): 279 283 return _findModels(dir) 280 logging.info("plugin g model : %s\n" % str(temp))284 logging.info("plugin model : %s" % str(temp)) 281 285 return temp 282 286 … … 291 295 292 296 ## NOTE: as of April 26, 2014, as part of first pass on fixing categories, 293 ## all the appends to shape_list or shape_independent_list are 294 ## commented out. They should be possible to remove. They are in 295 ## fact a "category" of model whereas the other list are actually 297 ## all the appends to shape_list or shape_independent_list are 298 ## commented out. They should be possible to remove. They are in 299 ## fact a "category" of model whereas the other list are actually 296 300 ## "attributes" of a model. In other words is it a structure factor 297 301 ## that can be used against a form factor, is it a form factor that is … … 302 306 ## structure where each model will provide a method to interrogate it 303 307 ## about its "attributes" -- then this long list becomes a loop reading 304 ## each model in the category list to populate the "attribute"lists. 305 ## We should also refactor the whole category vs attribute list 308 ## each model in the category list to populate the "attribute"lists. 309 ## We should also refactor the whole category vs attribute list 306 310 ## structure when doing this as now the attribute lists think they are 307 311 ## also category lists. … … 310 314 311 315 # regular model names only 316 base_message = "Unable to load model {0}" 312 317 try: 313 318 self.model_name_list = [] … … 318 323 self.model_name_list.append(SphereModel.__name__) 319 324 except: 320 pass325 logging.error(base_message.format(SphereModel.__name__)) 321 326 322 327 try: … … 326 331 self.model_name_list.append(BinaryHSModel.__name__) 327 332 except: 328 pass333 logging.error(base_message.format(BinaryHSModel.__name__)) 329 334 330 335 try: … … 335 340 self.model_name_list.append(FuzzySphereModel.__name__) 336 341 except: 337 pass342 logging.error(base_message.format(FuzzySphereModel.__name__)) 338 343 339 344 try: … … 343 348 self.model_name_list.append(RaspBerryModel.__name__) 344 349 except: 345 pass350 logging.error(base_message.format(RaspBerryModel.__name__)) 346 351 347 352 try: … … 353 358 self.model_name_list.append(CoreShellModel.__name__) 354 359 except: 355 pass360 logging.error(base_message.format(CoreShellModel.__name__)) 356 361 357 362 try: … … 361 366 self.model_name_list.append(Core2ndMomentModel.__name__) 362 367 except: 363 pass364 368 logging.error(base_message.format(Core2ndMomentModel.__name__)) 369 365 370 try: 366 371 from sas.models.CoreMultiShellModel import CoreMultiShellModel … … 370 375 self.multi_func_list.append(CoreMultiShellModel) 371 376 except: 372 pass377 logging.error(base_message.format(CoreMultiShellModel.__name__)) 373 378 374 379 try: … … 379 384 self.model_name_list.append(VesicleModel.__name__) 380 385 except: 381 pass386 logging.error(base_message.format(VesicleModel.__name__)) 382 387 383 388 try: … … 388 393 self.model_name_list.append(MultiShellModel.__name__) 389 394 except: 390 pass395 logging.error(base_message.format(MultiShellModel.__name__)) 391 396 392 397 try: … … 397 402 self.multi_func_list.append(OnionExpShellModel) 398 403 except: 399 pass404 logging.error(base_message.format(OnionExpShellModel.__name__)) 400 405 401 406 try: … … 407 412 self.multi_func_list.append(SphericalSLDModel) 408 413 except: 409 pass414 logging.error(base_message.format(SphericalSLDModel.__name__)) 410 415 411 416 try: … … 416 421 self.model_name_list.append(LinearPearlsModel.__name__) 417 422 except: 418 pass423 logging.error(base_message.format(LinearPearlsModel.__name__)) 419 424 420 425 try: … … 425 430 self.model_name_list.append(PearlNecklaceModel.__name__) 426 431 except: 427 pass432 logging.error(base_message.format(PearlNecklaceModel.__name__)) 428 433 429 434 try: … … 435 440 self.model_name_list.append(CylinderModel.__name__) 436 441 except: 437 pass442 logging.error(base_message.format(CylinderModel.__name__)) 438 443 439 444 try: … … 445 450 self.model_name_list.append(CoreShellCylinderModel.__name__) 446 451 except: 447 pass452 logging.error(base_message.format(CoreShellCylinderModel.__name__)) 448 453 449 454 try: … … 455 460 self.model_name_list.append(CoreShellBicelleModel.__name__) 456 461 except: 457 pass462 logging.error(base_message.format(CoreShellBicelleModel.__name__)) 458 463 459 464 try: … … 465 470 self.model_name_list.append(HollowCylinderModel.__name__) 466 471 except: 467 pass472 logging.error(base_message.format(HollowCylinderModel.__name__)) 468 473 469 474 try: … … 474 479 self.model_name_list.append(FlexibleCylinderModel.__name__) 475 480 except: 476 pass481 logging.error(base_message.format(FlexibleCylinderModel.__name__)) 477 482 478 483 try: … … 483 488 self.model_name_list.append(FlexCylEllipXModel.__name__) 484 489 except: 485 pass490 logging.error(base_message.format(FlexCylEllipXModel.__name__)) 486 491 487 492 try: … … 493 498 self.model_name_list.append(StackedDisksModel.__name__) 494 499 except: 495 pass500 logging.error(base_message.format(StackedDisksModel.__name__)) 496 501 497 502 try: … … 503 508 self.model_name_list.append(ParallelepipedModel.__name__) 504 509 except: 505 pass510 logging.error(base_message.format(ParallelepipedModel.__name__)) 506 511 507 512 try: … … 513 518 self.model_name_list.append(CSParallelepipedModel.__name__) 514 519 except: 515 pass520 logging.error(base_message.format(CSParallelepipedModel.__name__)) 516 521 517 522 try: … … 523 528 self.model_name_list.append(EllipticalCylinderModel.__name__) 524 529 except: 525 pass530 logging.error(base_message.format(EllipticalCylinderModel.__name__)) 526 531 527 532 try: … … 532 537 self.model_name_list.append(CappedCylinderModel.__name__) 533 538 except: 534 pass539 logging.error(base_message.format(CappedCylinderModel.__name__)) 535 540 536 541 try: … … 542 547 self.model_name_list.append(EllipsoidModel.__name__) 543 548 except: 544 pass549 logging.error(base_message.format(EllipsoidModel.__name__)) 545 550 546 551 try: … … 552 557 self.model_name_list.append(CoreShellEllipsoidModel.__name__) 553 558 except: 554 pass559 logging.error(base_message.format(CoreShellEllipsoidModel.__name__)) 555 560 556 561 try: … … 562 567 self.model_name_list.append(CoreShellEllipsoidXTModel.__name__) 563 568 except: 564 pass569 logging.error(base_message.format(CoreShellEllipsoidXTModel.__name__)) 565 570 566 571 try: … … 572 577 self.model_name_list.append(TriaxialEllipsoidModel.__name__) 573 578 except: 574 pass579 logging.error(base_message.format(TriaxialEllipsoidModel.__name__)) 575 580 576 581 try: … … 581 586 self.model_name_list.append(LamellarModel.__name__) 582 587 except: 583 pass588 logging.error(base_message.format(LamellarModel.__name__)) 584 589 585 590 try: … … 590 595 self.model_name_list.append(LamellarFFHGModel.__name__) 591 596 except: 592 pass597 logging.error(base_message.format(LamellarFFHGModel.__name__)) 593 598 594 599 try: … … 599 604 self.model_name_list.append(LamellarPSModel.__name__) 600 605 except: 601 pass606 logging.error(base_message.format(LamellarPSModel.__name__)) 602 607 603 608 try: … … 608 613 self.model_name_list.append(LamellarPSHGModel.__name__) 609 614 except: 610 pass615 logging.error(base_message.format(LamellarPSHGModel.__name__)) 611 616 612 617 try: … … 617 622 self.model_name_list.append(LamellarPCrystalModel.__name__) 618 623 except: 619 pass624 logging.error(base_message.format(LamellarPCrystalModel.__name__)) 620 625 621 626 try: … … 626 631 self.model_name_list.append(SCCrystalModel.__name__) 627 632 except: 628 pass629 633 logging.error(base_message.format(SCCrystalModel.__name__)) 634 630 635 try: 631 636 from sas.models.FCCrystalModel import FCCrystalModel … … 635 640 self.model_name_list.append(FCCrystalModel.__name__) 636 641 except: 637 pass642 logging.error(base_message.format(FCCrystalModel.__name__)) 638 643 639 644 try: … … 644 649 self.model_name_list.append(BCCrystalModel.__name__) 645 650 except: 646 pass651 logging.error(base_message.format(BCCrystalModel.__name__)) 647 652 648 653 … … 655 660 self.model_name_list.append(SquareWellStructure.__name__) 656 661 except: 657 pass662 logging.error(base_message.format(SquareWellStructure.__name__)) 658 663 659 664 try: … … 664 669 self.model_name_list.append(HardsphereStructure.__name__) 665 670 except: 666 pass671 logging.error(base_message.format(HardsphereStructure.__name__)) 667 672 668 673 try: … … 673 678 self.model_name_list.append(StickyHSStructure.__name__) 674 679 except: 675 pass680 logging.error(base_message.format(StickyHSStructure.__name__)) 676 681 677 682 try: … … 682 687 self.model_name_list.append(HayterMSAStructure.__name__) 683 688 except: 684 pass689 logging.error(base_message.format(HayterMSAStructure.__name__)) 685 690 686 691 … … 694 699 self.model_name_list.append(PowerLawAbsModel.__name__) 695 700 except: 696 pass701 logging.error(base_message.format(PowerLawAbsModel.__name__)) 697 702 698 703 try: … … 704 709 self.form_factor_dict[str(wx.NewId())] = [SphereModel] 705 710 except: 706 pass711 logging.error(base_message.format(BEPolyelectrolyte.__name__)) 707 712 708 713 try: … … 713 718 self.model_name_list.append(BroadPeakModel.__name__) 714 719 except: 715 pass720 logging.error(base_message.format(BroadPeakModel.__name__)) 716 721 717 722 try: … … 722 727 self.model_name_list.append(CorrLengthModel.__name__) 723 728 except: 724 pass729 logging.error(base_message.format(CorrLengthModel.__name__)) 725 730 726 731 try: … … 731 736 self.model_name_list.append(DABModel.__name__) 732 737 except: 733 pass738 logging.error(base_message.format(DABModel.__name__)) 734 739 735 740 try: … … 740 745 self.model_name_list.append(DebyeModel.__name__) 741 746 except: 742 pass747 logging.error(base_message.format(DebyeModel.__name__)) 743 748 744 749 try: … … 749 754 self.model_name_list.append(FractalModel.__name__) 750 755 except: 751 pass756 logging.error(base_message.format(FractalModel.__name__)) 752 757 753 758 try: … … 758 763 self.model_name_list.append(FractalCoreShellModel.__name__) 759 764 except: 760 pass765 logging.error(base_message.format(FractalCoreShellModel.__name__)) 761 766 762 767 try: … … 767 772 self.model_name_list.append(GaussLorentzGelModel.__name__) 768 773 except: 769 pass774 logging.error(base_message.format(GaussLorentzGelModel.__name__)) 770 775 771 776 try: … … 776 781 self.model_name_list.append(GuinierModel.__name__) 777 782 except: 778 pass783 logging.error(base_message.format(GuinierModel.__name__)) 779 784 780 785 try: … … 785 790 self.model_name_list.append(GuinierPorodModel.__name__) 786 791 except: 787 pass792 logging.error(base_message.format(GuinierPorodModel.__name__)) 788 793 789 794 try: … … 794 799 self.model_name_list.append(LorentzModel.__name__) 795 800 except: 796 pass801 logging.error(base_message.format(LorentzModel.__name__)) 797 802 798 803 try: … … 803 808 self.model_name_list.append(MassFractalModel.__name__) 804 809 except: 805 pass810 logging.error(base_message.format(MassFractalModel.__name__)) 806 811 807 812 try: … … 812 817 self.model_name_list.append(MassSurfaceFractal.__name__) 813 818 except: 814 pass819 logging.error(base_message.format(MassSurfaceFractal.__name__)) 815 820 816 821 try: … … 821 826 self.model_name_list.append(PeakGaussModel.__name__) 822 827 except: 823 pass828 logging.error(base_message.format(PeakGaussModel.__name__)) 824 829 825 830 try: … … 830 835 self.model_name_list.append(PeakLorentzModel.__name__) 831 836 except: 832 pass837 logging.error(base_message.format(PeakLorentzModel.__name__)) 833 838 834 839 try: … … 839 844 self.model_name_list.append(Poly_GaussCoil.__name__) 840 845 except: 841 pass846 logging.error(base_message.format(Poly_GaussCoil.__name__)) 842 847 843 848 try: … … 848 853 self.model_name_list.append(PolymerExclVolume.__name__) 849 854 except: 850 pass855 logging.error(base_message.format(PolymerExclVolume.__name__)) 851 856 852 857 try: … … 857 862 self.model_name_list.append(PorodModel.__name__) 858 863 except: 859 pass864 logging.error(base_message.format(PorodModel.__name__)) 860 865 861 866 try: … … 866 871 self.multi_func_list.append(RPA10Model) 867 872 except: 868 pass873 logging.error(base_message.format(RPA10Model.__name__)) 869 874 870 875 try: … … 875 880 self.model_name_list.append(StarPolymer.__name__) 876 881 except: 877 pass882 logging.error(base_message.format(StarPolymer.__name__)) 878 883 879 884 try: … … 884 889 self.model_name_list.append(SurfaceFractalModel.__name__) 885 890 except: 886 pass891 logging.error(base_message.format(SurfaceFractalModel.__name__)) 887 892 888 893 try: … … 893 898 self.model_name_list.append(TeubnerStreyModel.__name__) 894 899 except: 895 pass900 logging.error(base_message.format(TeubnerStreyModel.__name__)) 896 901 897 902 try: … … 902 907 self.model_name_list.append(TwoLorentzianModel.__name__) 903 908 except: 904 pass909 logging.error(base_message.format(TwoLorentzianModel.__name__)) 905 910 906 911 try: … … 911 916 self.model_name_list.append(TwoPowerLawModel.__name__) 912 917 except: 913 pass918 logging.error(base_message.format(TwoPowerLawModel.__name__)) 914 919 915 920 try: … … 920 925 self.multi_func_list.append(UnifiedPowerRgModel) 921 926 except: 922 pass927 logging.error(base_message.format(UnifiedPowerRgModel.__name__)) 923 928 924 929 try: … … 929 934 self.model_name_list.append(LineModel.__name__) 930 935 except: 931 pass936 logging.error(base_message.format(LineModel.__name__)) 932 937 933 938 try: … … 938 943 self.multi_func_list.append(ReflectivityModel) 939 944 except: 940 pass945 logging.error(base_message.format(ReflectivityModel.__name__)) 941 946 942 947 try: … … 947 952 self.multi_func_list.append(ReflectivityIIModel) 948 953 except: 949 pass954 logging.error(base_message.format(ReflectivityIIModel.__name__)) 950 955 951 956 try: … … 956 961 self.model_name_list.append(GelFitModel.__name__) 957 962 except: 958 pass963 logging.error(base_message.format(GelFitModel.__name__)) 959 964 960 965 try: … … 965 970 self.model_name_list.append(PringlesModel.__name__) 966 971 except: 967 pass972 logging.error(base_message.format(PringlesModel.__name__)) 968 973 969 974 try: … … 975 980 self.model_name_list.append(RectangularPrismModel.__name__) 976 981 except: 977 pass982 logging.error(base_message.format(RectangularPrismModel.__name__)) 978 983 979 984 try: … … 985 990 self.model_name_list.append(RectangularHollowPrismInfThinWallsModel.__name__) 986 991 except: 987 pass992 logging.error(base_message.format(RectangularHollowPrismInfThinWallsModel.__name__)) 988 993 989 994 try: … … 995 1000 self.model_name_list.append(RectangularHollowPrismModel.__name__) 996 1001 except: 997 pass1002 logging.error(base_message.format(RectangularHollowPrismModel.__name__)) 998 1003 999 1004 try: … … 1005 1010 self.model_name_list.append(MicelleSphCoreModel.__name__) 1006 1011 except: 1007 pass1012 logging.error(base_message.format(MicelleSphCoreModel.__name__)) 1008 1013 1009 1014 … … 1063 1068 new_plugins = _findModels(dir) 1064 1069 for name, plug in new_plugins.iteritems(): 1065 for stored_name, stored_plugin self.stored_plugins.iteritems():1070 for stored_name, _ in self.stored_plugins.iteritems(): 1066 1071 if name == stored_name: 1067 1072 del self.stored_plugins[name]
Note: See TracChangeset
for help on using the changeset viewer.