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
csst-dfs
csst-dfs-api-local
Commits
dd5a3c0d
Commit
dd5a3c0d
authored
Sep 14, 2022
by
Wei Shoulin
Browse files
bugs
parent
5402e595
Changes
2
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_local/cpic/ingest.py
View file @
dd5a3c0d
...
...
@@ -9,14 +9,18 @@ from csst_dfs_api_local.common.db import DBClient
log
=
logging
.
getLogger
(
'csst-dfs-api-local'
)
def
ingest
():
db
=
DBClient
()
parser
=
argparse
.
ArgumentParser
(
prog
=
f
"
{
sys
.
argv
[
0
]
}
"
,
description
=
"ingest the local files"
)
parser
.
add_argument
(
'-i'
,
'--infile'
,
dest
=
"infile"
,
help
=
"a file or a directory"
)
parser
.
add_argument
(
'-m'
,
'--copyfiles'
,
dest
=
"copyfiles"
,
action
=
'store_true'
,
default
=
False
,
help
=
"copy files after import"
)
args
=
parser
.
parse_args
(
sys
.
argv
[
1
:])
import_root_dir
=
args
.
infile
if
import_root_dir
is
None
or
(
not
os
.
path
.
isfile
(
import_root_dir
)
and
not
os
.
path
.
isdir
(
import_root_dir
)):
parser
.
print_help
()
sys
.
exit
(
0
)
db
=
DBClient
()
if
os
.
path
.
isfile
(
import_root_dir
):
log
.
info
(
f
"prepare import
{
import_root_dir
}
"
)
ingesst_one
(
import_root_dir
,
db
,
args
.
copyfiles
)
...
...
csst_dfs_api_local/msc/ingest.py
View file @
dd5a3c0d
...
...
@@ -68,7 +68,7 @@ def ingest_one(file_path, db, copyfiles):
filename
=
get_header_value
(
"FILENAME"
,
header
,
os
.
path
.
basename
(
file_path
))
existed
=
db
.
exists
(
"select * from
t
_level0_data where filename=?"
,
"select * from
msc
_level0_data where filename=?"
,
(
filename
,)
)
if
existed
:
...
...
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