Exemplo n.º 1
0
 def store_coordinates(self, coordinates, file_name=uuid1().__str__()):
     '''
     Stores the coordinates object into a file. If the file name is not informed, a new unique name will be
     generated. Once the store operation is done, this function returns the file name used for future
     actions.
     
     @param coordinates: to be stored.
     @param file_name: has a default value when not informed. It uses uuid1() function to generate the file name.
     '''
     file = None
     try:
         file = fileOperation.open_file(file_name)
         fileOperation.write_to_file(file, coordinates.__str__() + '\n')
     except IOError as error:
         '''
         Logs errors occurred during store operation.
         '''
         self.error(error)
         raise error
     else:
         '''
         If nothing wrong occurred, log info.
         This statement is only executed if there is no return statement within the try block.
         '''
         self.info('Coordinates stored successfully.')
         return file_name
     finally:
         '''
         Closes the stream and flushes the file.
         '''
         try:
             if file:
                 fileOperation.close_file(file)
         except IOError as error:
             self.error(error)
Exemplo n.º 2
0
 def store_coordinates(self, coordinates, file_name = uuid1().__str__()):
     '''
     Stores the coordinates object into a file. If the file name is not informed, a new unique name will be
     generated. Once the store operation is done, this function returns the file name used for future
     actions.
     
     @param coordinates: to be stored.
     @param file_name: has a default value when not informed. It uses uuid1() function to generate the file name.
     '''
     file = None
     try:
         file = fileOperation.open_file(file_name)
         fileOperation.write_to_file(file, coordinates.__str__() + '\n')
     except IOError as error:
         '''
         Logs errors occurred during store operation.
         '''
         self.error(error)
         raise error
     else:
         '''
         If nothing wrong occurred, log info.
         This statement is only executed if there is no return statement within the try block.
         '''
         self.info('Coordinates stored successfully.')
         return file_name
     finally:
         '''
         Closes the stream and flushes the file.
         '''
         try:
             if file:
                 fileOperation.close_file(file)
         except IOError as error:
             self.error(error)
Exemplo n.º 3
0
'''
'''
Imports dictionaries module from com.irdeto.python.structure package.
'''
from com.irdeto.sample.python.io import fileOperation
'''
All calls in this module will use the file object wrapped by the module fileOperation.
'''
'''
Opens/Creates a file using the given name and default arguments.
'''
file = fileOperation.open_file('python_test.txt')
'''
Writes into the file.
'''
fileOperation.write_to_file(file, 'First line test\n')
fileOperation.write_to_file(file, 'Second line test\n')
fileOperation.write_to_file(file, 'Third line test\n')
'''
Flushes the file content and closes it.
'''
fileOperation.close_file(file)
'''
Open the already created file on Read mode.
'''
file = fileOperation.open_file('python_test.txt', 'r')
'''
Prints the first line from the file.
'''
print fileOperation.read_line(file)
'''
Exemplo n.º 4
0
"""
from com.irdeto.sample.python.io import fileOperation

"""
All calls in this module will use the file object wrapped by the module fileOperation.
"""

"""
Opens/Creates a file using the given name and default arguments.
"""
file = fileOperation.open_file("python_test.txt")

"""
Writes into the file.
"""
fileOperation.write_to_file(file, "First line test\n")
fileOperation.write_to_file(file, "Second line test\n")
fileOperation.write_to_file(file, "Third line test\n")

"""
Flushes the file content and closes it.
"""
fileOperation.close_file(file)

"""
Open the already created file on Read mode.
"""
file = fileOperation.open_file("python_test.txt", "r")

"""
Prints the first line from the file.