Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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 GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Coughlin
GraceDB Server
Commits
f9ae1f19
Commit
f9ae1f19
authored
12 years ago
by
Brian Moe
Browse files
Options
Downloads
Patches
Plain Diff
Added access to /general/ data dir to cli api
parent
14e8085b
No related branches found
Branches containing commit
Tags
0.2.3
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gracedb/api.py
+24
-1
24 additions, 1 deletion
gracedb/api.py
gracedb/models.py
+6
-2
6 additions, 2 deletions
gracedb/models.py
with
30 additions
and
3 deletions
gracedb/api.py
+
24
−
1
View file @
f9ae1f19
...
@@ -17,7 +17,18 @@ def download(request, graceid, filename=""):
...
@@ -17,7 +17,18 @@ def download(request, graceid, filename=""):
except
Event
.
DoesNotExist
:
except
Event
.
DoesNotExist
:
return
HttpResponseNotFound
(
"
Event not found
"
)
return
HttpResponseNotFound
(
"
Event not found
"
)
filepath
=
os
.
path
.
join
(
event
.
datadir
(),
filename
)
# The plan to deal with that wretched general/ directory maybe
# should be to move it INTO private. Then externally, things
# would look like they do now, but the code here would be MUCH
# more sane and much shorter.
# UGLY hack to deal with /private vs /general dirs
general
=
False
if
os
.
path
.
split
(
filename
)[
0
]
==
"
general
"
:
filename
=
os
.
path
.
join
(
*
os
.
path
.
split
(
filename
)[
1
:])
general
=
True
filepath
=
os
.
path
.
join
(
event
.
datadir
(
general
),
filename
)
if
not
os
.
path
.
exists
(
filepath
):
if
not
os
.
path
.
exists
(
filepath
):
response
=
HttpResponseNotFound
(
"
File does not exist
"
)
response
=
HttpResponseNotFound
(
"
File does not exist
"
)
...
@@ -26,12 +37,24 @@ def download(request, graceid, filename=""):
...
@@ -26,12 +37,24 @@ def download(request, graceid, filename=""):
elif
not
filename
:
elif
not
filename
:
# Get list of files w/urls.
# Get list of files w/urls.
rv
=
{}
rv
=
{}
filepath
=
event
.
datadir
()
for
dirname
,
dirnames
,
filenames
in
os
.
walk
(
filepath
):
for
dirname
,
dirnames
,
filenames
in
os
.
walk
(
filepath
):
dirname
=
dirname
[
len
(
filepath
):]
# cut off base event dir path
dirname
=
dirname
[
len
(
filepath
):]
# cut off base event dir path
for
filename
in
filenames
:
for
filename
in
filenames
:
# relative path from root of event data dir
# relative path from root of event data dir
filename
=
os
.
path
.
join
(
dirname
,
filename
)
filename
=
os
.
path
.
join
(
dirname
,
filename
)
rv
[
filename
]
=
reverse
(
download
,
args
=
[
graceid
,
filename
])
rv
[
filename
]
=
reverse
(
download
,
args
=
[
graceid
,
filename
])
# XXX UGH... that awful general/ dir
filepath
=
event
.
datadir
(
general
=
True
)
for
dirname
,
dirnames
,
filenames
in
os
.
walk
(
filepath
):
# XXX HORRIBLE
dirname
=
dirname
[
len
(
filepath
)
-
len
(
"
general
"
):]
# cut off base event dir path
for
filename
in
filenames
:
# relative path from root of event data dir
filename
=
os
.
path
.
join
(
dirname
,
filename
)
rv
[
filename
]
=
reverse
(
download
,
args
=
[
graceid
,
filename
])
response
=
HttpResponse
(
simplejson
.
dumps
(
rv
),
content_type
=
"
application/json
"
)
response
=
HttpResponse
(
simplejson
.
dumps
(
rv
),
content_type
=
"
application/json
"
)
else
:
else
:
# get an actual file.
# get an actual file.
...
...
This diff is collapsed.
Click to expand it.
gracedb/models.py
+
6
−
2
View file @
f9ae1f19
...
@@ -95,9 +95,13 @@ class Event(models.Model):
...
@@ -95,9 +95,13 @@ class Event(models.Model):
#return "pcdev1.phys.uwm.edu:/archive/gracedb/data/%s" % self.graceid()
#return "pcdev1.phys.uwm.edu:/archive/gracedb/data/%s" % self.graceid()
return
"
file://pcdev1.phys.uwm.edu/archive/gracedb/data/%s
"
%
self
.
graceid
()
return
"
file://pcdev1.phys.uwm.edu/archive/gracedb/data/%s
"
%
self
.
graceid
()
def
datadir
(
self
):
def
datadir
(
self
,
general
=
False
):
# Move to this. Not the (more) ad hoc crap that's floating around.
# Move to this. Not the (more) ad hoc crap that's floating around.
return
os
.
path
.
join
(
settings
.
GRACEDB_DATA_DIR
,
self
.
graceid
(),
"
private
"
)
if
general
:
subdir
=
"
general
"
else
:
subdir
=
"
private
"
return
os
.
path
.
join
(
settings
.
GRACEDB_DATA_DIR
,
self
.
graceid
(),
subdir
)
def
ligoApproved
(
self
):
def
ligoApproved
(
self
):
return
self
.
approval_set
.
filter
(
approvingCollaboration
=
'
L
'
).
count
()
return
self
.
approval_set
.
filter
(
approvingCollaboration
=
'
L
'
).
count
()
...
...
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