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
1 change: 0 additions & 1 deletion Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,6 @@ def DiagramModified(self):

This method manage the propagation of modification
from window where modifications are performed to DEVSimPy main window.

"""

if self.diagram.modify:
Expand Down
36 changes: 18 additions & 18 deletions Domain/Collector/MessagesCollector.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-

"""
Name: MessagesCollector.py
Brief descritpion: collect to disk received messages
Author(s): Laurent CAPOCCHI (capocchi@univ-corse.fr)
Version: 1.0
Last modified: 26/10/20
Name : MessagesCollector.py
Brief descritpion : collect to disk received messages
Author(s) : Laurent CAPOCCHI (capocchi@univ-corse.fr)
Version : 1.0
Last modified : 26/10/20
GENERAL NOTES AND REMARKS:
GLOBAL VARIABLES AND FUNCTIONS:
"""
Expand All @@ -15,6 +15,7 @@

import os
import random
import tempfile

from DomainInterface.DomainBehavior import DomainBehavior

Expand All @@ -27,22 +28,22 @@ class MessagesCollector(DomainBehavior):
def __init__(self, fileName = "result", ext = '.dat', comma = ""):
""" Constructor.

@param fileName: name of output fileName
@param ext: output file extension
@param comma: comma separated
@param fileName : name of output fileName
@param ext : output file extension
@param comma : comma separated
"""
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(os.getcwd(),"out","result%d"%random.randint(1,100))
fileName = fileName if fileName != "result" else os.path.join(tempfile.gettempdir(),"result%d"%random.randint(1,100))

# local copy
self.fileName = fileName
self.ext = ext
self.comma = comma

self.initPhase('IDLE',INFINITY)

for np in range(10000):
fn = "%s%d%s"%(self.fileName, np, self.ext)
if os.path.exists(fn):
Expand All @@ -55,27 +56,26 @@ def extTransition(self, *args):
for port in self.IPorts:
### adapted with PyPDEVS
msg = self.peek(port, *args)

np = self.getPortId(port)

if msg:
np = self.getPortId(port)

### filename
fn = "%s%s%s"%(self.fileName, str(np), self.ext)

with open(fn,'a') as f: f.write("%s\n"%(str(msg)))
del msg

self.holdIn('ACTIF',0)
self.holdIn('ACTIF',0.0)

return self.getState()

###
def intTransition(self):
self.passivateIn('IDLE')
return self.getState()

###
def timeAdvance(self):return self.getSigma()

###
def __str__(self):return "MessagesCollector"
def __str__(self):return "MessagesCollector"
2 changes: 1 addition & 1 deletion Domain/Collector/To_Disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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(os.getcwd(),"out","result%d"%random.randint(1,100))
fileName = fileName if fileName!= 'result' else os.path.join(tempfile.gettempdir(),"result%d"%random.randint(1,100))

# local copy
self.fileName = fileName
Expand Down
9 changes: 5 additions & 4 deletions LibraryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,11 @@ def GetPYFileList(dName, ext=".py"):
except Exception as info:
py_file_list = []
# if dName contains a python file, __init__.py is forced
for f in os.listdir(dName):
if f.endswith(ext):
sys.stderr.write(_("Exception, %s not imported: %s \n"%(dName,info)))
break
if os.path.isdir(dName):
for f in os.listdir(dName):
if f.endswith(ext):
sys.stderr.write(_("Exception, %s not imported: %s \n"%(dName,info)))
break

return py_file_list

Expand Down
2 changes: 1 addition & 1 deletion devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def MakeToolBar(self):
self.SetToolBar(tb)

def GetExportPathsList(self):
"""
""" Return the list of exported path.
"""
return self.exportPathsList

Expand Down