Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
99404017
Commit
99404017
authored
10 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
various bugfixes
parent
b064b609
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bootstrap.py
+3
-4
3 additions, 4 deletions
bootstrap.py
containers.py
+3
-3
3 additions, 3 deletions
containers.py
util.py
+1
-1
1 addition, 1 deletion
util.py
with
7 additions
and
8 deletions
bootstrap.py
+
3
−
4
View file @
99404017
...
@@ -94,10 +94,9 @@ example:
...
@@ -94,10 +94,9 @@ example:
def
sort
(
args
):
def
sort
(
args
):
logging
.
basicConfig
(
level
=
logging
.
WARNING
)
logging
.
basicConfig
(
level
=
logging
.
WARNING
)
import
util
import
util
data_path
=
os
.
path
.
join
(
args
.
sort_path
,
'
nims
'
)
quarantine_path
=
os
.
path
.
join
(
args
.
sort_path
,
'
quarantine
'
)
quarantine_path
=
os
.
path
.
join
(
args
.
sort_path
,
'
quarantine
'
)
if
not
os
.
path
.
exists
(
data
_path
):
if
not
os
.
path
.
exists
(
args
.
sort
_path
):
os
.
makedirs
(
data
_path
)
os
.
makedirs
(
args
.
sort
_path
)
if
not
os
.
path
.
exists
(
quarantine_path
):
if
not
os
.
path
.
exists
(
quarantine_path
):
os
.
makedirs
(
quarantine_path
)
os
.
makedirs
(
quarantine_path
)
print
'
initializing DB
'
print
'
initializing DB
'
...
@@ -120,7 +119,7 @@ def sort(args):
...
@@ -120,7 +119,7 @@ def sort(args):
with
open
(
filepath
,
'
rb
'
)
as
fd
:
with
open
(
filepath
,
'
rb
'
)
as
fd
:
for
chunk
in
iter
(
lambda
:
fd
.
read
(
1048577
*
hash_
.
block_size
),
''
):
for
chunk
in
iter
(
lambda
:
fd
.
read
(
1048577
*
hash_
.
block_size
),
''
):
hash_
.
update
(
chunk
)
hash_
.
update
(
chunk
)
status
,
detail
=
util
.
insert_file
(
db
.
acquisitions
,
None
,
None
,
filepath
,
hash_
.
hexdigest
(),
data
_path
,
quarantine_path
)
status
,
detail
=
util
.
insert_file
(
db
.
acquisitions
,
None
,
None
,
filepath
,
hash_
.
hexdigest
(),
args
.
sort
_path
,
quarantine_path
)
if
status
!=
200
:
if
status
!=
200
:
print
detail
print
detail
...
...
This diff is collapsed.
Click to expand it.
containers.py
+
3
−
3
View file @
99404017
...
@@ -183,7 +183,7 @@ class Container(base.RequestHandler):
...
@@ -183,7 +183,7 @@ class Container(base.RequestHandler):
except
(
ValueError
,
jsonschema
.
ValidationError
)
as
e
:
except
(
ValueError
,
jsonschema
.
ValidationError
)
as
e
:
self
.
abort
(
400
,
str
(
e
))
self
.
abort
(
400
,
str
(
e
))
_id
=
bson
.
ObjectId
(
cid
)
_id
=
bson
.
ObjectId
(
cid
)
container
,
_
=
self
.
_get
(
_id
,
'
download
'
)
container
,
_
=
self
.
_get
(
_id
,
'
ro
'
)
for
file_info
in
container
[
'
files
'
]:
for
file_info
in
container
[
'
files
'
]:
if
'
name
'
in
file_spec
:
if
'
name
'
in
file_spec
:
if
file_info
[
'
name
'
]
==
file_spec
[
'
name
'
]
and
file_info
[
'
ext
'
]
==
file_spec
[
'
ext
'
]:
if
file_info
[
'
name
'
]
==
file_spec
[
'
name
'
]
and
file_info
[
'
ext
'
]
==
file_spec
[
'
ext
'
]:
...
@@ -324,7 +324,7 @@ class Container(base.RequestHandler):
...
@@ -324,7 +324,7 @@ class Container(base.RequestHandler):
"""
Download one attachment.
"""
"""
Download one attachment.
"""
fname
=
self
.
request
.
get
(
'
name
'
)
fname
=
self
.
request
.
get
(
'
name
'
)
_id
=
bson
.
ObjectId
(
cid
)
_id
=
bson
.
ObjectId
(
cid
)
container
,
_
=
self
.
_get
(
_id
,
'
download
'
)
container
,
_
=
self
.
_get
(
_id
,
'
ro
'
)
fpath
=
os
.
path
.
join
(
self
.
app
.
config
[
'
data_path
'
],
str
(
_id
)[
-
3
:]
+
'
/
'
+
str
(
_id
),
fname
)
fpath
=
os
.
path
.
join
(
self
.
app
.
config
[
'
data_path
'
],
str
(
_id
)[
-
3
:]
+
'
/
'
+
str
(
_id
),
fname
)
for
a_info
in
container
[
'
attachments
'
]:
for
a_info
in
container
[
'
attachments
'
]:
if
(
a_info
[
'
name
'
]
+
a_info
[
'
ext
'
])
==
fname
:
if
(
a_info
[
'
name
'
]
+
a_info
[
'
ext
'
])
==
fname
:
...
@@ -344,7 +344,7 @@ class Container(base.RequestHandler):
...
@@ -344,7 +344,7 @@ class Container(base.RequestHandler):
"""
Delete one attachment.
"""
"""
Delete one attachment.
"""
fname
=
self
.
request
.
get
(
'
name
'
)
fname
=
self
.
request
.
get
(
'
name
'
)
_id
=
bson
.
ObjectId
(
cid
)
_id
=
bson
.
ObjectId
(
cid
)
container
,
_
=
self
.
_get
(
_id
,
'
download
'
)
container
,
_
=
self
.
_get
(
_id
,
'
rw
'
)
fpath
=
os
.
path
.
join
(
self
.
app
.
config
[
'
data_path
'
],
str
(
_id
)[
-
3
:]
+
'
/
'
+
str
(
_id
),
fname
)
fpath
=
os
.
path
.
join
(
self
.
app
.
config
[
'
data_path
'
],
str
(
_id
)[
-
3
:]
+
'
/
'
+
str
(
_id
),
fname
)
for
a_info
in
container
[
'
attachments
'
]:
for
a_info
in
container
[
'
attachments
'
]:
if
(
a_info
[
'
name
'
]
+
a_info
[
'
ext
'
])
==
fname
:
if
(
a_info
[
'
name
'
]
+
a_info
[
'
ext
'
])
==
fname
:
...
...
This diff is collapsed.
Click to expand it.
util.py
+
1
−
1
View file @
99404017
...
@@ -18,6 +18,7 @@ PROJECTION_FIELDS = ['timestamp', 'permissions', 'public']
...
@@ -18,6 +18,7 @@ PROJECTION_FIELDS = ['timestamp', 'permissions', 'public']
def
insert_file
(
dbc
,
_id
,
file_info
,
filepath
,
digest
,
data_path
,
quarantine_path
,
flavor
=
'
file
'
):
def
insert_file
(
dbc
,
_id
,
file_info
,
filepath
,
digest
,
data_path
,
quarantine_path
,
flavor
=
'
file
'
):
"""
Insert a file as an attachment or as a file.
"""
"""
Insert a file as an attachment or as a file.
"""
filename
=
os
.
path
.
basename
(
filepath
)
filename
=
os
.
path
.
basename
(
filepath
)
flavor
+=
'
s
'
if
_id
is
None
:
if
_id
is
None
:
try
:
try
:
log
.
info
(
'
Parsing %s
'
%
filename
)
log
.
info
(
'
Parsing %s
'
%
filename
)
...
@@ -49,7 +50,6 @@ def insert_file(dbc, _id, file_info, filepath, digest, data_path, quarantine_pat
...
@@ -49,7 +50,6 @@ def insert_file(dbc, _id, file_info, filepath, digest, data_path, quarantine_pat
)
)
filename
=
dataset
.
nims_file_name
+
dataset
.
nims_file_ext
filename
=
dataset
.
nims_file_name
+
dataset
.
nims_file_ext
else
:
else
:
flavor
=
flavor
+
'
s
'
file_spec
=
dict
(
file_spec
=
dict
(
_id
=
_id
,
_id
=
_id
,
flavor
=
{
'
$elemMatch
'
:
{
flavor
=
{
'
$elemMatch
'
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment