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 William Coughlin
GraceDB Server
Commits
18976cac
Commit
18976cac
authored
12 years ago
by
Brian Moe
Browse files
Options
Downloads
Patches
Plain Diff
CLI file download. Begin transition to RESTier API
parent
ff04a660
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gracedb/api.py
+26
-0
26 additions, 0 deletions
gracedb/api.py
gracedb/models.py
+4
-0
4 additions, 0 deletions
gracedb/models.py
gracedb/urls_rest.py
+6
-0
6 additions, 0 deletions
gracedb/urls_rest.py
urls.py
+1
-0
1 addition, 0 deletions
urls.py
with
37 additions
and
0 deletions
gracedb/api.py
0 → 100644
+
26
−
0
View file @
18976cac
from
django.http
import
HttpResponse
,
HttpResponseNotFound
from
gracedb.models
import
Event
import
os
def
download
(
request
,
graceid
,
filename
=
None
):
#response = HttpResponse(buildVOEvent(event), content_type="application/xml")
if
not
filename
:
response
=
HttpResponseNotFound
(
"
Not Implemented.
"
)
response
.
status_code
=
404
try
:
event
=
Event
.
getByGraceid
(
graceid
)
filepath
=
os
.
path
.
join
(
event
.
datadir
(),
filename
)
if
not
os
.
path
.
exists
(
filepath
):
response
=
HttpResponseNotFound
(
"
File does not exist
"
)
elif
not
os
.
access
(
filepath
,
os
.
R_OK
):
response
=
HttpResponseNotFound
(
"
File not readable
"
)
else
:
response
=
HttpResponse
(
open
(
filepath
,
"
r
"
),
content_type
=
"
application/octet-stream
"
)
response
[
'
Content-Disposition
'
]
=
'
attachment; filename=%s
'
%
os
.
path
.
basename
(
filename
)
except
Event
.
DoesNotExist
:
response
=
HttpResponseNotFound
(
"
Event does not exist
"
)
return
response
This diff is collapsed.
Click to expand it.
gracedb/models.py
+
4
−
0
View file @
18976cac
...
...
@@ -95,6 +95,10 @@ class Event(models.Model):
#return "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
):
# Move to this. Not the (more) ad hoc crap that's floating around.
return
os
.
path
.
join
(
settings
.
GRACEDB_DATA_DIR
,
self
.
graceid
(),
"
private
"
)
def
ligoApproved
(
self
):
return
self
.
approval_set
.
filter
(
approvingCollaboration
=
'
L
'
).
count
()
...
...
This diff is collapsed.
Click to expand it.
gracedb/urls_rest.py
0 → 100644
+
6
−
0
View file @
18976cac
from
django.conf.urls.defaults
import
*
urlpatterns
=
patterns
(
'
gracedb.api
'
,
url
(
r
'
^event/(?P<graceid>[\w\d]+)/files/(?P<filename>.+)?$
'
,
'
download
'
,
name
=
"
download
"
),
)
This diff is collapsed.
Click to expand it.
urls.py
+
1
−
0
View file @
18976cac
...
...
@@ -16,6 +16,7 @@ urlpatterns = patterns('',
url
(
r
'
^$
'
,
'
gracedb.views.index
'
,
name
=
"
home
"
),
(
r
'
^events/
'
,
include
(
'
gracedb.urls
'
)),
(
r
'
^api/
'
,
include
(
'
gracedb.urls_rest
'
)),
(
r
'
^options/
'
,
include
(
'
userprofile.urls
'
)),
(
r
'
^cli/create
'
,
'
gracedb.views.create
'
),
(
r
'
^cli/ping
'
,
'
gracedb.views.ping
'
),
...
...
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