Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sispub
datapool
Commits
e7574e87
Commit
e7574e87
authored
Jan 31, 2019
by
schmittu
🍺
Browse files
some improvements for delete command
parent
165165b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
datapool/commands/delete.py
View file @
e7574e87
...
...
@@ -104,9 +104,10 @@ def _setup_session(print_err):
def
_print_signals
(
q
,
max_rows
,
print_ok
):
num_signals
=
q
.
count
()
print_ok
(
"- deletion affects {} signal
s
"
.
format
(
num_signals
))
print_ok
(
"- deletion affects {} signal
(s)
"
.
format
(
num_signals
))
if
not
num_signals
:
return
rows
=
[
dbo
.
resolved_columns
()
for
dbo
in
itertools
.
islice
(
q
,
max_rows
)]
header
=
SignalDbo
.
resolved_column_names
()
table
=
format_table
(
header
,
rows
)
...
...
@@ -114,17 +115,10 @@ def _print_signals(q, max_rows, print_ok):
header
,
delim
,
*
rows
=
table
.
split
(
"
\n
"
)
print_ok
(
" "
+
header
)
print_ok
(
" "
+
delim
)
if
len
(
rows
)
>
max_rows
:
n_start
=
max_rows
//
2
n_end
=
max_rows
-
n_start
n_skipped
=
num_signals
-
max_rows
+
1
rows
=
(
rows
[:
n_start
]
+
[
"... skipped {} signals ..."
.
format
(
n_skipped
)]
+
rows
[
-
n_end
:]
)
for
row
in
rows
:
print_ok
(
" "
+
row
)
if
num_signals
>
max_rows
:
print_ok
(
" ... skipped {} signals"
.
format
(
num_signals
-
max_rows
))
print_ok
(
""
)
...
...
@@ -202,7 +196,7 @@ def _delete_source(
return
0
_delete_signals
(
session
,
SourceDbo
,
S
ource
Dbo
.
source_id
==
source
.
source_id
,
print_ok
session
,
SourceDbo
,
S
ignal
Dbo
.
source_id
==
source
.
source_id
,
print_ok
)
for
averaging
in
source
.
averaging
:
session
.
delete
(
averaging
)
...
...
@@ -265,7 +259,7 @@ def _delete_site(
# delete in right order:
for
picture
in
site
.
pictures
:
session
.
delete
(
picture
)
_delete_signals
(
session
,
SiteDbo
,
Si
te
Dbo
.
site_id
==
site
.
site_id
,
print_ok
)
_delete_signals
(
session
,
SiteDbo
,
Si
gnal
Dbo
.
site_id
==
site
.
site_id
,
print_ok
)
session
.
delete
(
site
)
_remove_yaml_including_folders
(
yaml_path
,
print_ok
,
print_err
)
...
...
@@ -307,7 +301,7 @@ def _delete_parameter(
_delete_signals
(
session
,
ParameterDbo
,
Parameter
Dbo
.
parameter_id
==
parameter
.
parameter_id
,
Signal
Dbo
.
parameter_id
==
parameter
.
parameter_id
,
print_ok
,
)
session
.
delete
(
parameter
)
...
...
datapool/http_server.py
View file @
e7574e87
...
...
@@ -2,6 +2,7 @@
# encoding: utf-8
from
__future__
import
absolute_import
,
division
,
print_function
import
atexit
import
importlib
import
json
# Copyright © 2018 Uwe Schmitt <uwe.schmitt@id.ethz.ch>
...
...
@@ -61,9 +62,12 @@ class DataPoolHttpServer:
def
run_http_server_in_background
(
config_http_server
,
print_ok
):
port
=
config_http_server
.
port
server
=
DataPoolHttpServer
(
port
)
print_ok
(
"- start background http server on port {}"
.
format
(
port
))
server
.
start
()
yield
print_ok
(
"- stop http server"
)
server
.
stop
()
print_ok
(
"- stopped http server"
)
datapool/landing_zone.py
View file @
e7574e87
...
...
@@ -10,13 +10,12 @@ import time
from
os.path
import
exists
,
join
,
relpath
from
.errors
import
DataPoolIOError
,
InvalidLandingZone
,
InvalidOperationError
from
.instance.landing_zone_structure
import
(
lock_file
,
ordered_fnmatch_patterns_for_update
,
raw_file_pattern_for_script
,
scripts_pattern
,
)
from
.utils
import
copy
,
here
,
hexdigest_file
,
iter_to_list
,
list_folder_recursive
from
.instance.landing_zone_structure
import
(
lock_file
,
ordered_fnmatch_patterns_for_update
,
raw_file_pattern_for_script
,
scripts_pattern
)
from
.utils
import
(
copy
,
here
,
hexdigest_file
,
iter_to_list
,
list_folder_recursive
)
def
disable_write
(
path
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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