Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
ec809ed4
Commit
ec809ed4
authored
May 17, 2019
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://code.df.uba.ar/martindrech/total_control_app
parents
1908d2d6
dfc963ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
storage.py
resources/storage.py
+16
-2
No files found.
resources/storage.py
View file @
ec809ed4
...
@@ -22,13 +22,19 @@ class Storage(object):
...
@@ -22,13 +22,19 @@ class Storage(object):
Class to handle data saving.
Class to handle data saving.
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
"""
self
.
directory
=
'.'
By default, directory is set to the current directory.
"""
self
.
directory
=
os
.
getcwd
()
def
set_directory
(
self
,
directory
):
def
set_directory
(
self
,
directory
):
self
.
directory
=
directory
self
.
directory
=
directory
def
create_data_file
(
self
,
*
args
):
def
create_data_file
(
self
,
*
args
):
"""
Creates a file to store data. Name is set automatically.
*args should be strings, with the column titles of the data to be saved.
"""
saving_directory
=
"/"
.
join
([
self
.
directory
,
self
.
get_date_string
()])
saving_directory
=
"/"
.
join
([
self
.
directory
,
self
.
get_date_string
()])
if
not
os
.
path
.
exists
(
saving_directory
):
if
not
os
.
path
.
exists
(
saving_directory
):
os
.
makedirs
(
saving_directory
)
os
.
makedirs
(
saving_directory
)
...
@@ -51,12 +57,20 @@ class Storage(object):
...
@@ -51,12 +57,20 @@ class Storage(object):
def
append_data_to_current_file
(
self
,
row
):
def
append_data_to_current_file
(
self
,
row
):
"""
This will append a row to the last data file created.
row should be a list with the values to append.
"""
with
open
(
self
.
get_current_data_filename
(),
'ab'
)
as
f
:
with
open
(
self
.
get_current_data_filename
(),
'ab'
)
as
f
:
#data = np.column_stack(args)
#data = np.column_stack(args)
np
.
savetxt
(
f
,
[
row
])
np
.
savetxt
(
f
,
[
row
])
f
.
flush
()
f
.
flush
()
def
append_metadata_to_current_file
(
self
,
*
args
):
def
append_metadata_to_current_file
(
self
,
*
args
):
"""
This appends metadata to the last metadata file created.
*args should be dictionaries, each of them will be stored.
"""
for
arg
in
args
:
for
arg
in
args
:
for
key
,
value
in
arg
.
items
():
for
key
,
value
in
arg
.
items
():
with
open
(
self
.
get_current_metadata_filename
(),
'a'
)
as
f
:
with
open
(
self
.
get_current_metadata_filename
(),
'a'
)
as
f
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment