Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Leo Pound Singer
gracedb-client
Commits
bf546e4a
Commit
bf546e4a
authored
Jun 11, 2012
by
Brian Moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added download command
parent
251881d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
debian/changelog
debian/changelog
+6
-0
ligo/gracedb/__init__.py
ligo/gracedb/__init__.py
+18
-3
No files found.
debian/changelog
View file @
bf546e4a
ligo-gracedb (1.2-1) unstable; urgency=low
* Added file download command.
-- Brian Moe <brian.moe@ligo.org> Mon, 11 Jun 2012 16:04:26 -0600
ligo-gracedb (1.1-1) unstable; urgency=low
* Bug Fix.
...
...
ligo/gracedb/__init__.py
View file @
bf546e4a
...
...
@@ -22,10 +22,11 @@ __all__ = ["utils"]
import
httplib
,
mimetypes
,
urllib
import
socket
import
os
,
sys
,
shutil
import
simplejson
DEFAULT_SERVICE_URL
=
"https://gracedb.ligo.org/gracedb/cli"
GIT_TAG
=
'gracedb-1.
1
-1'
GIT_TAG
=
'gracedb-1.
2
-1'
#-----------------------------------------------------------------
# Util routines
...
...
@@ -378,6 +379,10 @@ class Client:
files
=
[
(
'upload'
,
filename
,
filecontents
)
]
return
self
.
_upload
(
'upload'
,
fields
,
files
,
alert
)
def
listfiles
(
self
,
graceid
):
response
=
self
.
rest
(
'/event/%s/files/'
%
graceid
)
return
response
def
download
(
self
,
graceid
,
filename
,
destfile
):
# Check that we *could* write the file before we
# go to the trouble of getting it. Also, try not
...
...
@@ -514,9 +519,18 @@ Longer strings will be truncated.""" % {
comment
=
" "
.
join
(
args
[
3
:])
response
=
client
.
upload
(
graceid
,
filename
,
comment
=
comment
,
alert
=
options
.
alert
)
elif
args
[
0
]
==
'download'
:
if
len
(
args
)
not
in
[
3
,
4
]:
op
.
error
(
"not enough arguments for
up
load"
)
if
len
(
args
)
not
in
[
2
,
3
,
4
]:
op
.
error
(
"not enough arguments for
down
load"
)
graceid
=
args
[
1
]
if
len
(
args
)
==
2
:
# get/print listing.
response
=
client
.
listfiles
(
graceid
)
if
response
and
response
.
status
==
200
:
for
fname
in
simplejson
.
loads
(
response
.
read
()):
print
(
fname
)
exit
(
0
)
print
(
response
.
reason
)
exit
(
1
)
filename
=
args
[
2
]
if
len
(
args
)
==
4
:
outfile
=
args
[
3
]
...
...
@@ -524,6 +538,7 @@ Longer strings will be truncated.""" % {
outfile
=
os
.
path
.
basename
(
filename
)
response
=
client
.
download
(
graceid
,
filename
,
outfile
)
if
response
:
# no response means file saved. any other response is an error message.
print
response
exit
(
1
)
exit
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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