Journal integration doubt
I am trying to associate a simple text file with the journal object. Within a logging session of Measure activity, many logs are created and the file that I am trying to associate with the journal object would basically contain the file paths of the logs made in that session so that when the session is resumed from the journal those log files can be opened and displayed on the oscilloscope like interface. The seperate log files get created and written properly. However, I am facing problems regarding the main file that I try and associate with the Journal object. This file does get created but disappears when I quit the activity. I have attached relevant code portions below. Please point me to some code that might be doing something similar to what I am trying to do or let me know where I am going wrong. many thanks, Arjun #Create a unique file name using the current time self._jobject.file_path = os.path.join(/tmp/myLogs + str(time.time())) #Create the metadata file to be associated with the journal object #and write a first line to it self.f = open(self._jobject.file_path, 'w') self.f.write(Measure Activity logs metadata file\n) #Now generate a unique name for the log file and write the name of the log file #created into the metadata file self.file_name = (/tmp/myLogs + str( time.time())) self.log_file = open(self.file_name, 'w') self.f.write(self.file_name + \n) #Close metadata file self.f.close() self.datastore.write(self._jobject) #Write the required values onto the log file(s) and then close it(them) self.log_file.write(str(value1)) self.log_file.write(str(value2)) self.log_file.close() ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Journal integration doubt
On Sun, 2007-10-21 at 16:40 +0530, Arjun Sarwal wrote: I am trying to associate a simple text file with the journal object. Within a logging session of Measure activity, many logs are created and the file that I am trying to associate with the journal object would basically contain the file paths of the logs made in that session so that when the session is resumed from the journal those log files can be opened and displayed on the oscilloscope like interface. The seperate log files get created and written properly. However, I am facing problems regarding the main file that I try and associate with the Journal object. This file does get created but disappears when I quit the activity. I have attached relevant code portions below. Please point me to some code that might be doing something similar to what I am trying to do or let me know where I am going wrong. I see you case similar to what Record does, here is the code: http://www.mediamods.com/public-svn/camera-activity/tags/33/ Most python activities just have to implement the read_file and write_file methods in their Activity subclass. Record is a bit more complicated, because apart from the session data, it also creates an object in the journal for every photograph and every recording, so they can be dragged around or opened with other activities. In your case, if you don't need to make each individual log accessible to other activities, you could just write a zip file containing all your logs in the write_file method. In this case, see this example activity from Marco: git-clone http://dev.laptop.org/~marco/edit-activity/ Hope this helps, Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Journal integration doubt
On Oct 21, 2007, at 1:10 PM, Arjun Sarwal wrote: am trying to associate with the journal object would basically contain the file paths of the logs made in that session Make sure you're storing the full files -- not paths -- in the journal, e.g. as a zip file. #Create a unique file name using the current time self._jobject.file_path = os.path.join(/tmp/myLogs + str(time.time ())) Don't do this. See os.tmpfile() or the tempfile module. (Journal/activity questions are more appropriate for sugar@; Reply-To set.) -- Ivan Krstić [EMAIL PROTECTED] | http://radian.org ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel