Added time stamp to csv_collect

Esse commit está contido em:
Rodrigo Ceballos
2015-02-28 20:58:05 -05:00
commit 18683f96ce
3 arquivos alterados com 13 adições e 7 exclusões
+12 -3
Ver Arquivo
@@ -1,17 +1,26 @@
import csv
import timeit
import datetime
from yapsy.IPlugin import IPlugin
class PluginCSVCollect(IPlugin):
def __init__(self, file_name="collect.csv", delim = ","):
self.file_name = file_name
now = datetime.datetime.now()
self.time_stamp = '%d-%d-%d_%d-%d-%d'%(now.year,now.month,now.day,now.hour,now.minute,now.second)
self.file_name = self.time_stamp
self.start_time = timeit.default_timer()
self.delim = delim
def activate(self, args):
if len(args) > 0:
self.file_name = args[0]
if len(args) > 1 and args[1] == 'no_time':
self.file_name = args[0]
else:
self.file_name = args[0] + '_' + self.file_name;
self.file_name = self.file_name + '.csv'
print "Will export CSV to:", self.file_name
open(self.file_name, 'w').close()
return True
@@ -43,4 +52,4 @@ class PluginCSVCollect(IPlugin):
#remove last comma
row += '\n'
with open(self.file_name, 'a') as f:
f.write(row)
f.write(row)
-1
Ver Arquivo
@@ -1,4 +1,3 @@
[Core]
Name = csv_collect
Module = csv_collect
+1 -3
Ver Arquivo
@@ -159,8 +159,6 @@ if __name__ == '__main__':
#Take user input
s = raw_input('--> ');
# We're all set, disconnect board, switch off plugins
board.disconnect()
for plug in plug_list:
plug.deactivate()