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
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: 0lYPQVdrYdZNaCbvjgXY6FqdZNaCXzdwx
114 changes: 58 additions & 56 deletions Mixins/Savable.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,81 +148,83 @@ class DumpZipFile(DumpBase):
ext = [".amd", ".cmd"]

def Save(self, obj_dumped, fileName = None):
""" Function that save the codeblock on the disk.
""" Function that save the codeblock on the disk.
"""
assert(fileName.endswith(tuple(DumpZipFile.ext)))
assert(fileName.endswith(tuple(DumpZipFile.ext)))

### local copy of paths
python_path = obj_dumped.python_path
image_path = obj_dumped.image_path
### local copy of paths
python_path = obj_dumped.python_path
image_path = obj_dumped.image_path

### Now, file paths are in the compressed file
if os.path.isabs(python_path):
path = os.path.join(fileName, os.path.basename(obj_dumped.python_path))
if os.path.exists(path):
obj_dumped.python_path = path
### Now, file paths are in the compressed file
if os.path.isabs(python_path):
path = os.path.join(fileName, os.path.basename(obj_dumped.python_path))
if os.path.exists(path):
obj_dumped.python_path = path

if os.path.isabs(image_path):
obj_dumped.image_path = os.path.join(fileName, os.path.basename(obj_dumped.image_path))
if os.path.isabs(image_path):
obj_dumped.image_path = os.path.join(fileName, os.path.basename(obj_dumped.image_path))

obj_dumped.model_path = fileName
obj_dumped.model_path = fileName

### args is constructor args and we save these and not the current value
if hasattr(obj_dumped, 'args'):
obj_dumped.args = Components.GetArgs(Components.GetClass(obj_dumped.python_path))
try:
### args is constructor args and we save these and not the current value
if hasattr(obj_dumped, 'args'):
obj_dumped.args = Components.GetArgs(Components.GetClass(obj_dumped.python_path))
try:

fn = 'DEVSimPyModel.dat'
fn = 'DEVSimPyModel.dat'

### dump attributes in fn file
pickle.dump( obj = PickledCollection(obj_dumped),
file = open(fn, "wb"),
protocol = 0)
### dump attributes in fn file
pickle.dump( obj = PickledCollection(obj_dumped),
file = open(fn, "wb"),
protocol = 0)

except Exception as info:
tb = traceback.format_exc()
sys.stderr.write(_("Problem saving (during the dump): %s -- %s\n")%(str(fileName),str(tb)))
return False
else:
except Exception as info:
tb = traceback.format_exc()
sys.stderr.write(_("Problem saving (during the dump): %s -- %s\n")%(str(fileName),str(tb)))
return False
else:

try:
try:

zf = ZipManager.Zip(fileName)
zf = ZipManager.Zip(fileName)

### create or update fileName
if os.path.exists(fileName):
zf.Update(replace_files = [fn, python_path, image_path])
else:
zf.Create(add_files = [fn, python_path, image_path])
### create or update fileName
if os.path.exists(fileName):
zf.Update(replace_files = [fn, python_path, image_path])
else:
zf.Create(add_files = [fn, python_path, image_path])

os.remove(fn)
os.remove(fn)

## abs path of the directory that contains the file to export (str() to avoid unicode)
newExportPath = str(os.path.dirname(fileName))
## abs path of the directory that contains the file to export (str() to avoid unicode)
newExportPath = str(os.path.dirname(fileName))

mainW = getTopLevelWindow()
### if export on local directory, we insert the path in the config file
if not os.path.basename(DOMAIN_PATH) in newExportPath.split(os.sep):
### update of .devsimpy config file
mainW.exportPathsList = eval(mainW.cfg.Read("exportPathsList"))
if newExportPath not in mainW.exportPathsList:
mainW.exportPathsList.append(str(newExportPath))
mainW.cfg.Write("exportPathsList", str(eval("mainW.exportPathsList")))
mainW = getTopLevelWindow()
### if export on local directory, we insert the path in the config file
if os.path.basename(DOMAIN_PATH) not in newExportPath.split(
os.sep
):
### update of .devsimpy config file
mainW.exportPathsList = eval(mainW.cfg.Read("exportPathsList"))
if newExportPath not in mainW.exportPathsList:
mainW.exportPathsList.append(str(newExportPath))
mainW.cfg.Write("exportPathsList", str(eval("mainW.exportPathsList")))

### if lib is already in the lib tree, we update the tree
mainW.tree.UpdateDomain(newExportPath)
### to sort lib tree
mainW.tree.SortChildren(mainW.tree.root)
### if lib is already in the lib tree, we update the tree
mainW.tree.UpdateDomain(newExportPath)
### to sort lib tree
mainW.tree.SortChildren(mainW.tree.root)

except Exception as info:
tb = traceback.format_exc()
NotificationMessage(_('Error'), _("Problem saving (during the zip handling): %s -- %s\n")%(str(fileName),info), parent=getTopLevelWindow(), timeout=5)
sys.stderr.write(_("Problem saving (during the zip handling): %s -- %s\n")%(str(fileName),str(tb)))
except Exception as info:
tb = traceback.format_exc()
NotificationMessage(_('Error'), _("Problem saving (during the zip handling): %s -- %s\n")%(str(fileName),info), parent=getTopLevelWindow(), timeout=5)
sys.stderr.write(_("Problem saving (during the zip handling): %s -- %s\n")%(str(fileName),str(tb)))

return False
else:
return False
else:

return True
return True

def Load(self, obj_loaded, fileName = None):
""" Load codeblock (obj_loaded) from fileName
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
</p>

[![Build Status](https://travis-ci.org/capocchi/DEVSimPy.svg?branch=master)](https://travis-ci.org/capocchi/DEVSimPy)

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
<a href="https://codeclimate.com/github/capocchi/DEVSimPy/maintainability"><img src="https://api.codeclimate.com/v1/badges/f5c94ecbfb6a3c8986be/maintainability" /></a>
<a href="https://codeclimate.com/github/capocchi/DEVSimPy/test_coverage"><img src="https://api.codeclimate.com/v1/badges/f5c94ecbfb6a3c8986be/test_coverage" /></a>

# What is DEVSimPy
DEVSimPy is an open Source project (under GPL V.3 license) supported by the [SPE](http://http://spe.univ-corse.fr/) (Sciences pour l'Environnement) team of the UMR CNRS 6134 Lab. of the [University of Corsica "Pasquale Paoli"](http://univ-corse.fr). This aim is to provide a GUI for the Modeling & Simulation of PyDEVS and [PyPDEVS](http://msdl.cs.mcgill.ca/projects/DEVS/PythonPDEVS) models. PyDEVS is an API allowing the implementation of the DEVS formalism in Python language. PyPDEVS is the parallel version of PyDEVS based on Parallel DEVS formalism which is an extension of the DEVS formalism.
Expand Down