Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@

import ZipManager

from Utilities import replaceAll, GetActiveWindow, printOnStatusBar
from Utilities import replaceAll, GetActiveWindow, printOnStatusBar, install
from Decorators import BuzyCursorNotification
from NetManager import Net
from which import which

Expand Down Expand Up @@ -766,9 +767,19 @@ def OnEditor(self, event):
if val == wx.ID_YES:
### open with local editor
if wx.Platform == '__WXMAC__':
subprocess.call(" ".join(['open',python_path]), shell=True)
subprocess.call(" ".join(['open -a',python_path]), shell=True)
elif "wxMSW" in wx.PlatformInfo:
os.startfile(python_path)
### TODO : select dialog to chose editor (spyder, pyzo, etc..)
try:
import spyder
except ImportError:
if BuzyCursorNotification(install('spyder')):
dial = wx.MessageDialog(mainW, _('You need to restart DEVSimPy to use the Spyder code editor.'), name, wx.OK | wx.ICON_INFORMATION)
val = dial.ShowModal()
else:
subprocess.Popen(['spyder', python_path, '--multithread'])

#os.startfile(python_path)
elif "wxGTK" in wx.PlatformInfo:
### with gnome
if os.system('pidof gedit') == 256:
Expand Down
5 changes: 5 additions & 0 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
GREEN = '#90ee90'
BLACK = '#000000'
BLUE = '#add8e6'
ORANGE = '#ffa500'

import Components

Expand Down Expand Up @@ -4544,6 +4545,8 @@ def __init__(self, label = 'QuickScope'):

CodeBlock.__init__(self, label, 1, 0)

self.fill = [ORANGE]

### enable edition on properties panel
self.AddAttribute("xlabel")
self.AddAttribute("ylabel")
Expand Down Expand Up @@ -4572,6 +4575,8 @@ def __init__(self, label='DiskGUI'):
"""
CodeBlock.__init__(self, label, 1, 0)

self.fill = [ORANGE]

def OnLeftDClick(self, event):
""" Left Double Click has been appeared.
"""
Expand Down
2 changes: 1 addition & 1 deletion Domain/Collector/MessagesCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, fileName = "result", ext = '.dat', comma = ""):
DomainBehavior.__init__(self)

### a way to overcome the random initialization of the fileNam attr directly in the param list of the constructor!
fileName = fileName if fileName != "result" else os.path.join(tempfile.gettempdir(),"result%d"%random.randint(1,100))
fileName = fileName if fileName != "result" else os.path.join(tempfile.gettempdir(),"result%d"%random.randint(1,100000))

# local copy
self.fileName = fileName
Expand Down
2 changes: 1 addition & 1 deletion Domain/Collector/To_Disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, fileName = "result", eventAxis = False, comma = " ", ext = '.
QuickScope.__init__(self)

### a way to overcome the random initialization of the fileNam attr directly in the param list of the constructor!
fileName = fileName if fileName!= 'result' else os.path.join(tempfile.gettempdir(),"result%d"%random.randint(1,100))
fileName = fileName if fileName!= 'result' else os.path.join(tempfile.gettempdir(),"result%d"%random.randint(1,100000))

# local copy
self.fileName = fileName
Expand Down
37 changes: 20 additions & 17 deletions Mixins/Savable.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@
except:
subprocess.run(f'pip install {lib_name}'.split())

#try:
import yaml
builtins.__dict__['YAML_IMPORT'] = True
#except ImportError as info:
# builtins.__dict__['YAML_IMPORT'] = False
# sys.stdout.write("yaml module was not found! Install it if you want to save model in yaml format.\n")

#try:
import ruamel.yaml
builtins.__dict__['YAML_IMPORT'] = True
#except ImportError as info:
# builtins.__dict__['YAML_IMPORT'] = False
# sys.stdout.write("ruamel.yaml module was not found! Install it if you want to save model in yaml format.\n")
try:
import yaml
builtins.__dict__['YAML_IMPORT'] = True
except ImportError as info:
builtins.__dict__['YAML_IMPORT'] = False
sys.stdout.write("yaml module was not found! Install it if you want to save model in yaml format.\n")

try:
import ruamel.yaml as ruamel
builtins.__dict__['YAML_IMPORT'] = True
except ImportError as info:
try:
import ruamel_yaml as ruamel
except ImportError as info:
builtins.__dict__['YAML_IMPORT'] = False
sys.stdout.write("ruamel.yaml module was not found! Install it if you want to save model in yaml format.\n")

from tempfile import gettempdir

Expand Down Expand Up @@ -478,10 +481,10 @@ def Save(self, obj_dumped, fileName = None):
assert(fileName.endswith(tuple(DumpYAMLFile.ext)))

try:
yaml = ruamel.yaml.YAML()
yaml = ruamel.YAML()
yaml.register_class(PickledCollection)
with open(fileName, 'w') as yf:
ruamel.yaml.dump(PickledCollection(obj_dumped), stream=yf, default_flow_style=False)
ruamel.dump(PickledCollection(obj_dumped), stream=yf, default_flow_style=False)
except Exception as info:
tb = traceback.format_exc()
sys.stderr.write(_("\nProblem saving: %s -- %s\n")%(str(fileName),str(tb)))
Expand All @@ -495,10 +498,10 @@ def Load(self, obj_loaded, fileName = None):

## try to open f with compressed mode
try:
yaml = ruamel.yaml.YAML()
yaml = ruamel.YAML()
yaml.register_class(PickledCollection)
with open(fileName, 'r') as yf:
dsp = ruamel.yaml.load(yf, Loader=ruamel.yaml.Loader)
dsp = ruamel.load(yf, Loader=ruamel.Loader)

except Exception as info:
exc_type, exc_obj, exc_tb = sys.exc_info()
Expand Down
Loading