WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   File Management (

Uttama_vizard 06-28-2008 01:45 PM

File Management

I am trying to do a file management of a number of .py files each of which has a sequence of operations.

To mark the event (that is completion of execution of one .py file), I was trying to send something to the serial port by using........

character1.scale(0,0,0)# (say), this is end of execution of file.
ser = serial.Serial() #Use the Serial port
ser.baudrate = 9600
ser.port = 'COM3'
x =
print x

When I am executing my file, I am getting 's' in the input/output window.

Like this there will be,

From my master .py file, I am trying to execute one after another...

def FileManagement():
#Set variables
count = 0
if count == 0:
import 1.pyser = serial.Serial() ser.baudrate = 9600ser.port = 'COM3' = x
count += 1
if count == 1:import 2.pycount += 1
if count == 2:import
count += 1
if count == 3:import

Now, I want to mark the end of execution of each .py file.

In doing so when I am trying to read the serial port where I have written already during execution of the,, from my master .py file, I am getting error messages

Traceback (most recent call last):
File "C:\Program Files\WorldViz\Vizard3002701\Vizard30\python\vizta", line 676, in __onupdate
self.__task = [ t for t in self.__task if not t.update() ]
File "C:\Program Files\WorldViz\Vizard3002701\Vizard30\python\vizta", line 643, in update
val = self.__stack[-1].next()
File "", line 135, in StartStory
File "C:\Program Files\WorldViz\Vizard3002701\Vizard30\bin\lib\site-packages\serial\", line 49, in open
raise SerialException("could not open port %s: %s" % (self.portstr, msg))
serial.serialutil.SerialException: could not open port COM3: (5, 'CreateFile', 'Access is denied.')

Is it a problem with accessing the same port multiple times....or may be a synchronization problem...that is when the port is being written, it is not being opened for reading.

Thanks in advance for any valuable suggestion....regarding this problem....or for any other suggested better ways of doing the file management.



farshizzo 06-30-2008 05:35 PM

From the error you are getting the problem seems to be that you are trying to open the same COM port multiple times, which is failing. Instead of having multiple files for each operation, I would suggest using one file and implementing each operation as a function in the file. This way, you can open the serial port once in the global scope of the file and all the functions can use the existing handle to it.

Uttama_vizard 07-01-2008 09:44 AM


Yes, of course that would be the easiest solution. I have tried that out and it works. In fact, if I open and close the COM port multiple times from the same .py file, there is also no error. What, I feel that trying to access the same COM port simultaneously from different files is giving errors due to synchronization problem.

But, my application demands that I use separate .py files and one master .py file for managing the different .py files. I have found out a solution to this and now it is working fine.

What I have done is that I have tried to write in a separate .txt file some message conveying the end of execution of one .py file and then I have tried to access that .txt file, check its contents and when the condition matches, I have made my master .py file to recognize that as an event marker.

Now, it is working fine.

Thanks for your valuable suggestion.


All times are GMT -7. The time now is 12:08 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC