Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
File Transfer Service
fts-rest
Commits
a3ee3a0d
Commit
a3ee3a0d
authored
Sep 20, 2013
by
ayllon
Browse files
First shy steps complying with pep8
parent
ac363867
Changes
42
Hide whitespace changes
Inline
Side-by-side
src/fts3/cli/__init__.py
View file @
a3ee3a0d
...
...
@@ -8,16 +8,16 @@ import sys
class
FTS3CliFormatter
(
logging
.
Formatter
):
def
format
(
self
,
record
):
if
record
.
levelno
==
logging
.
CRITICAL
:
self
.
_fmt
=
'Error: %(msg)s'
elif
record
.
levelno
==
logging
.
DEBUG
:
self
.
_fmt
=
'# %(msg)s'
else
:
self
.
_fmt
=
'%(msg)s'
return
logging
.
Formatter
.
format
(
self
,
record
)
def
format
(
self
,
record
):
if
record
.
levelno
==
logging
.
CRITICAL
:
self
.
_fmt
=
'Error: %(msg)s'
elif
record
.
levelno
==
logging
.
DEBUG
:
self
.
_fmt
=
'# %(msg)s'
else
:
self
.
_fmt
=
'%(msg)s'
return
logging
.
Formatter
.
format
(
self
,
record
)
fmt
=
FTS3CliFormatter
()
handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
...
...
src/fts3/cli/base.py
View file @
a3ee3a0d
...
...
@@ -4,57 +4,57 @@ import logging
import
os
CONFIG_FILENAMES
=
[
'/etc/fts3/fts3client.cfg'
,
os
.
path
.
expanduser
(
'~/.fts3client.cfg'
)]
os
.
path
.
expanduser
(
'~/.fts3client.cfg'
)]
CONFIG_DEFAULTSECTION
=
'Main'
CONFIG_DEFAULTS
=
{
'verbose'
:
'false'
,
'endpoint'
:
'None'
,
'json'
:
'false'
,
'ukey'
:
'None'
,
'ucert'
:
'None'
}
'verbose'
:
'false'
,
'endpoint'
:
'None'
,
'json'
:
'false'
,
'ukey'
:
'None'
,
'ucert'
:
'None'
}
class
Base
(
object
):
def
__init__
(
self
,
extra_args
=
None
):
self
.
logger
=
logging
.
getLogger
()
# Common CLI options
usage
=
None
if
extra_args
:
usage
=
"usage: %prog [options] "
+
extra_args
def
__init__
(
self
,
extra_args
=
None
):
self
.
logger
=
logging
.
getLogger
()
# Common CLI options
usage
=
None
if
extra_args
:
usage
=
"usage: %prog [options] "
+
extra_args
config
=
SafeConfigParser
(
defaults
=
CONFIG_DEFAULTS
)
config
=
SafeConfigParser
(
defaults
=
CONFIG_DEFAULTS
)
section
=
CONFIG_DEFAULTSECTION
config
.
read
(
CONFIG_FILENAMES
)
section
=
CONFIG_DEFAULTSECTION
config
.
read
(
CONFIG_FILENAMES
)
# manually set the section in edge cases
if
not
config
.
has_section
(
'Main'
):
section
=
'DEFAULT'
# manually set the section in edge cases
if
not
config
.
has_section
(
'Main'
):
section
=
'DEFAULT'
# manually get values for which we need to support None
opt_endpoint
=
config
.
get
(
section
,
'endpoint'
)
if
opt_endpoint
==
'None'
:
opt_endpoint
=
None
opt_ukey
=
config
.
get
(
section
,
'ukey'
)
if
opt_ukey
==
'None'
:
opt_ukey
=
None
opt_ucert
=
config
.
get
(
section
,
'ucert'
)
if
opt_ucert
==
'None'
:
opt_ucert
=
None
self
.
optParser
=
OptionParser
(
usage
=
usage
)
self
.
optParser
.
add_option
(
'-v'
,
'--verbose'
,
dest
=
'verbose'
,
action
=
'store_true'
,
help
=
'verbose output.'
,
default
=
config
.
getboolean
(
section
,
'verbose'
))
self
.
optParser
.
add_option
(
'-s'
,
'--endpoint'
,
dest
=
'endpoint'
,
help
=
'FTS3 REST endpoint.'
,
default
=
opt_endpoint
)
self
.
optParser
.
add_option
(
'-j'
,
dest
=
'json'
,
action
=
'store_true'
,
help
=
'print the output in JSON format.'
,
default
=
config
.
getboolean
(
section
,
'json'
))
self
.
optParser
.
add_option
(
'--key'
,
dest
=
'ukey'
,
help
=
'the user certificate private key.'
,
default
=
opt_ukey
)
self
.
optParser
.
add_option
(
'--cert'
,
dest
=
'ucert'
,
help
=
'the user certificate.'
,
default
=
opt_ucert
)
# manually get values for which we need to support None
opt_endpoint
=
config
.
get
(
section
,
'endpoint'
)
if
opt_endpoint
==
'None'
:
opt_endpoint
=
None
opt_ukey
=
config
.
get
(
section
,
'ukey'
)
if
opt_ukey
==
'None'
:
opt_ukey
=
None
opt_ucert
=
config
.
get
(
section
,
'ucert'
)
if
opt_ucert
==
'None'
:
opt_ucert
=
None
self
.
optParser
=
OptionParser
(
usage
=
usage
)
self
.
optParser
.
add_option
(
'-v'
,
'--verbose'
,
dest
=
'verbose'
,
action
=
'store_true'
,
help
=
'verbose output.'
,
default
=
config
.
getboolean
(
section
,
'verbose'
))
self
.
optParser
.
add_option
(
'-s'
,
'--endpoint'
,
dest
=
'endpoint'
,
help
=
'FTS3 REST endpoint.'
,
default
=
opt_endpoint
)
self
.
optParser
.
add_option
(
'-j'
,
dest
=
'json'
,
action
=
'store_true'
,
help
=
'print the output in JSON format.'
,
default
=
config
.
getboolean
(
section
,
'json'
))
self
.
optParser
.
add_option
(
'--key'
,
dest
=
'ukey'
,
help
=
'the user certificate private key.'
,
default
=
opt_ukey
)
self
.
optParser
.
add_option
(
'--cert'
,
dest
=
'ucert'
,
help
=
'the user certificate.'
,
default
=
opt_ucert
)
src/fts3/cli/delegator.py
View file @
a3ee3a0d
...
...
@@ -8,27 +8,27 @@ import time
class
Delegator
(
Base
):
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
Delegator
,
self
).
__init__
()
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
Delegator
,
self
).
__init__
()
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
def
__call__
(
self
):
self
.
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
def
__call__
(
self
):
self
.
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
delegator
=
Deleg
(
self
.
context
)
delegationId
=
delegator
.
delegate
()
self
.
logger
.
info
(
"Delegation id: %s"
%
delegationId
)
return
delegationId
delegator
=
Deleg
(
self
.
context
)
delegationId
=
delegator
.
delegate
()
self
.
logger
.
info
(
"Delegation id: %s"
%
delegationId
)
return
delegationId
src/fts3/cli/jobcanceller.py
View file @
a3ee3a0d
...
...
@@ -6,33 +6,33 @@ import sys
class
JobCanceller
(
Base
):
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobCanceller
,
self
).
__init__
()
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
len
(
self
.
args
)
==
0
:
self
.
logger
.
critical
(
'Need a job id'
)
sys
.
exit
(
1
)
self
.
jobId
=
self
.
args
[
0
]
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__call__
(
self
):
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobCanceller
,
self
).
__init__
()
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
len
(
self
.
args
)
==
0
:
self
.
logger
.
critical
(
'Need a job id'
)
sys
.
exit
(
1
)
self
.
jobId
=
self
.
args
[
0
]
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__call__
(
self
):
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
submitter
=
Submitter
(
context
)
job
=
submitter
.
cancel
(
self
.
jobId
)
self
.
logger
.
info
(
job
[
'job_state'
])
submitter
=
Submitter
(
context
)
job
=
submitter
.
cancel
(
self
.
jobId
)
self
.
logger
.
info
(
job
[
'job_state'
])
src/fts3/cli/joblister.py
View file @
a3ee3a0d
...
...
@@ -7,36 +7,36 @@ import sys
class
JobLister
(
Base
):
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobLister
,
self
).
__init__
()
# Specific options
self
.
optParser
.
add_option
(
'-u'
,
'--userdn'
,
dest
=
'user_dn'
,
help
=
'query only for the given user.'
)
self
.
optParser
.
add_option
(
'-o'
,
'--voname'
,
dest
=
'vo_name'
,
help
=
'query only for the given VO.'
)
# And parse
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__call__
(
self
):
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
inquirer
=
Inquirer
(
context
)
jobList
=
inquirer
.
getJobList
(
self
.
options
.
user_dn
,
self
.
options
.
vo_name
)
if
not
self
.
options
.
json
:
self
.
logger
.
info
(
jobList2HumanReadable
(
jobList
))
else
:
self
.
logger
.
info
(
jobList2Json
(
jobList
))
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobLister
,
self
).
__init__
()
# Specific options
self
.
optParser
.
add_option
(
'-u'
,
'--userdn'
,
dest
=
'user_dn'
,
help
=
'query only for the given user.'
)
self
.
optParser
.
add_option
(
'-o'
,
'--voname'
,
dest
=
'vo_name'
,
help
=
'query only for the given VO.'
)
# And parse
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__call__
(
self
):
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
inquirer
=
Inquirer
(
context
)
jobList
=
inquirer
.
getJobList
(
self
.
options
.
user_dn
,
self
.
options
.
vo_name
)
if
not
self
.
options
.
json
:
self
.
logger
.
info
(
jobList2HumanReadable
(
jobList
))
else
:
self
.
logger
.
info
(
jobList2Json
(
jobList
))
src/fts3/cli/jobshower.py
View file @
a3ee3a0d
...
...
@@ -7,35 +7,35 @@ import sys
class
JobShower
(
Base
):
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobShower
,
self
).
__init__
(
extra_args
=
'JOB_ID'
)
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
len
(
self
.
args
)
==
0
:
self
.
logger
.
critical
(
'Need a job id'
)
sys
.
exit
(
1
)
self
.
jobId
=
self
.
args
[
0
]
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobShower
,
self
).
__init__
(
extra_args
=
'JOB_ID'
)
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
len
(
self
.
args
)
==
0
:
self
.
logger
.
critical
(
'Need a job id'
)
sys
.
exit
(
1
)
self
.
jobId
=
self
.
args
[
0
]
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__call__
(
self
):
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
inquirer
=
Inquirer
(
context
)
job
=
inquirer
.
getJobStatus
(
self
.
jobId
)
if
not
self
.
options
.
json
:
self
.
logger
.
info
(
job2HumanReadable
(
job
))
else
:
self
.
logger
.
info
(
job2Json
(
job
))
def
__call__
(
self
):
context
=
Context
(
self
.
options
.
endpoint
,
ukey
=
self
.
options
.
ukey
,
ucert
=
self
.
options
.
ucert
)
inquirer
=
Inquirer
(
context
)
job
=
inquirer
.
getJobStatus
(
self
.
jobId
)
if
not
self
.
options
.
json
:
self
.
logger
.
info
(
job2HumanReadable
(
job
))
else
:
self
.
logger
.
info
(
job2Json
(
job
))
src/fts3/cli/jobsubmitter.py
View file @
a3ee3a0d
...
...
@@ -7,144 +7,144 @@ import time
class
JobSubmitter
(
Base
):
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobSubmitter
,
self
).
__init__
(
extra_args
=
'SOURCE DESTINATION [CHECKSUM]'
)
# Specific options
self
.
optParser
.
add_option
(
'-b'
,
'--blocking'
,
dest
=
'blocking'
,
default
=
False
,
action
=
'store_true'
,
help
=
'blocking mode. Wait until the operation completes.'
)
self
.
optParser
.
add_option
(
'-i'
,
'--interval'
,
dest
=
'poll_interval'
,
type
=
'int'
,
default
=
30
,
help
=
'interval between two poll operations in blocking mode.'
)
self
.
optParser
.
add_option
(
'-e'
,
'--expire'
,
dest
=
'proxy_lifetime'
,
type
=
'int'
,
default
=
420
,
help
=
'expiration time of the delegation in minutes.'
)
self
.
optParser
.
add_option
(
'-o'
,
'--overwrite'
,
dest
=
'overwrite'
,
default
=
False
,
action
=
'store_true'
,
help
=
'overwrite files.'
)
self
.
optParser
.
add_option
(
'-r'
,
'--reuse'
,
dest
=
'reuse'
,
default
=
False
,
action
=
'store_true'
,
help
=
'enable session reuse for the transfer job.'
)
self
.
optParser
.
add_option
(
'--job-metadata'
,
dest
=
'job_metadata'
,
help
=
'transfer job metadata.'
)
self
.
optParser
.
add_option
(
'--file-metadata'
,
dest
=
'file_metadata'
,
help
=
'file metadata.'
)
self
.
optParser
.
add_option
(
'--file-size'
,
dest
=
'file_size'
,
type
=
'long'
,
help
=
'file size (in Bytes)'
)
self
.
optParser
.
add_option
(
'-g'
,
'--gparam'
,
dest
=
'gridftp_params'
,
help
=
'GridFTP parameters.'
)
self
.
optParser
.
add_option
(
'-t'
,
'--dest-token'
,
dest
=
'destination_token'
,
help
=
'the destination space token or its description.'
)
self
.
optParser
.
add_option
(
'-S'
,
'--source-token'
,
dest
=
'source_token'
,
help
=
'the source space token or its description.'
)
self
.
optParser
.
add_option
(
'-K'
,
'--compare-checksum'
,
dest
=
'compare_checksum'
,
help
=
'compare checksums between source and destination.'
)
self
.
optParser
.
add_option
(
'--copy-pin-lifetime'
,
dest
=
'pin_lifetime'
,
type
=
'long'
,
default
=
-
1
,
help
=
'pin lifetime of the copy in seconds.'
)
self
.
optParser
.
add_option
(
'--bring-online'
,
dest
=
'bring_online'
,
type
=
'long'
,
default
=
None
,
help
=
'bring online timeout in seconds.'
)
self
.
optParser
.
add_option
(
'--fail-nearline'
,
dest
=
'fail_nearline'
,
default
=
False
,
action
=
'store_true'
,
help
=
'fail the transfer is the file is nearline.'
)
self
.
optParser
.
add_option
(
'--dry-run'
,
dest
=
'dry_run'
,
default
=
False
,
action
=
'store_true'
,
help
=
'do not send anything, just print the JSON message.'
)
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
len
(
self
.
args
)
<
2
:
self
.
logger
.
critical
(
"Need a source and a destination"
)
sys
.
exit
(
1
)
elif
len
(
self
.
args
)
==
2
:
(
self
.
source
,
self
.
destination
)
=
self
.
args
self
.
checksum
=
None
elif
len
(
self
.
args
)
==
3
:
(
self
.
source
,
self
.
destination
,
self
.
checksum
)
=
self
.
args
else
:
self
.
logger
.
critical
(
"Too many parameters"
)
sys
.
exit
(
1
)
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
__init__
(
self
,
argv
=
sys
.
argv
[
1
:]):
super
(
JobSubmitter
,
self
).
__init__
(
extra_args
=
'SOURCE DESTINATION [CHECKSUM]'
)
# Specific options
self
.
optParser
.
add_option
(
'-b'
,
'--blocking'
,
dest
=
'blocking'
,
default
=
False
,
action
=
'store_true'
,
help
=
'blocking mode. Wait until the operation completes.'
)
self
.
optParser
.
add_option
(
'-i'
,
'--interval'
,
dest
=
'poll_interval'
,
type
=
'int'
,
default
=
30
,
help
=
'interval between two poll operations in blocking mode.'
)
self
.
optParser
.
add_option
(
'-e'
,
'--expire'
,
dest
=
'proxy_lifetime'
,
type
=
'int'
,
default
=
420
,
help
=
'expiration time of the delegation in minutes.'
)
self
.
optParser
.
add_option
(
'-o'
,
'--overwrite'
,
dest
=
'overwrite'
,
default
=
False
,
action
=
'store_true'
,
help
=
'overwrite files.'
)
self
.
optParser
.
add_option
(
'-r'
,
'--reuse'
,
dest
=
'reuse'
,
default
=
False
,
action
=
'store_true'
,
help
=
'enable session reuse for the transfer job.'
)
self
.
optParser
.
add_option
(
'--job-metadata'
,
dest
=
'job_metadata'
,
help
=
'transfer job metadata.'
)
self
.
optParser
.
add_option
(
'--file-metadata'
,
dest
=
'file_metadata'
,
help
=
'file metadata.'
)
self
.
optParser
.
add_option
(
'--file-size'
,
dest
=
'file_size'
,
type
=
'long'
,
help
=
'file size (in Bytes)'
)
self
.
optParser
.
add_option
(
'-g'
,
'--gparam'
,
dest
=
'gridftp_params'
,
help
=
'GridFTP parameters.'
)
self
.
optParser
.
add_option
(
'-t'
,
'--dest-token'
,
dest
=
'destination_token'
,
help
=
'the destination space token or its description.'
)
self
.
optParser
.
add_option
(
'-S'
,
'--source-token'
,
dest
=
'source_token'
,
help
=
'the source space token or its description.'
)
self
.
optParser
.
add_option
(
'-K'
,
'--compare-checksum'
,
dest
=
'compare_checksum'
,
help
=
'compare checksums between source and destination.'
)
self
.
optParser
.
add_option
(
'--copy-pin-lifetime'
,
dest
=
'pin_lifetime'
,
type
=
'long'
,
default
=
-
1
,
help
=
'pin lifetime of the copy in seconds.'
)
self
.
optParser
.
add_option
(
'--bring-online'
,
dest
=
'bring_online'
,
type
=
'long'
,
default
=
None
,
help
=
'bring online timeout in seconds.'
)
self
.
optParser
.
add_option
(
'--fail-nearline'
,
dest
=
'fail_nearline'
,
default
=
False
,
action
=
'store_true'
,
help
=
'fail the transfer is the file is nearline.'
)
self
.
optParser
.
add_option
(
'--dry-run'
,
dest
=
'dry_run'
,
default
=
False
,
action
=
'store_true'
,
help
=
'do not send anything, just print the JSON message.'
)
(
self
.
options
,
self
.
args
)
=
self
.
optParser
.
parse_args
(
argv
)
if
self
.
options
.
endpoint
is
None
:
self
.
logger
.
critical
(
'Need an endpoint'
)
sys
.
exit
(
1
)
if
len
(
self
.
args
)
<
2
:
self
.
logger
.
critical
(
"Need a source and a destination"
)
sys
.
exit
(
1
)
elif
len
(
self
.
args
)
==
2
:
(
self
.
source
,
self
.
destination
)
=
self
.
args
self
.
checksum
=
None
elif
len
(
self
.
args
)
==
3
:
(
self
.
source
,
self
.
destination
,
self
.
checksum
)
=
self
.
args
else
:
self
.
logger
.
critical
(
"Too many parameters"
)
sys
.
exit
(
1
)
if
self
.
options
.
verbose
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
_doSubmit
(
self
):
verify_checksum
=
None
if
self
.
options
.
compare_checksum
:
verify_checksum
=
True
delegator
=
Delegator
(
self
.
context
)
delegationId
=
delegator
.
delegate
(
timedelta
(
minutes
=
self
.
options
.
proxy_lifetime
))
submitter
=
Submitter
(
self
.
context
)
jobId
=
submitter
.
submit
(
self
.
source
,
self
.
destination
,
checksum
=
self
.
checksum
,
bring_online
=
self
.
options
.
bring_online
,
verify_checksum
=
verify_checksum
,
spacetoken
=
self
.
options
.
destination_token
,
source_spacetoken
=
self
.
options
.
source_token
,
fail_nearline
=
self
.
options
.
fail_nearline
,
file_metadata
=
self
.
options
.
file_metadata
,
filesize
=
self
.
options
.
file_size
,
gridftp
=
self
.
options
.
gridftp_params
,
job_metadata
=
self
.
options
.
job_metadata
,
overwrite
=
self
.
options
.
overwrite
,
copy_pin_lifetime
=
self
.
options
.
pin_lifetime
,
reuse
=
self
.
options
.
reuse
)
if
self
.
options
.
json
:
self
.
logger
.
info
(
jobId
)
else
:
self
.
logger
.
info
(
"Job successfully submitted."
)
self
.
logger
.
info
(
"Job id: %s"
%
jobId
)
if
jobId
and
self
.
options
.
blocking
:
inquirer
=
Inquirer
(
self
.
context
)
while
True
:
time
.
sleep
(
self
.
options
.
poll_interval
)
job
=
inquirer
.
getJobStatus
(
jobId
)
if
job
[
'job_state'
]
not
in
[
'SUBMITTED'
,
'READY'
,
'STAGING'
,
'ACTIVE'
]:
break
self
.
logger
.
info
(
"Job in state %s"
%
job
[
'job_state'
])
self
.
logger
.
info
(
"Job finished with state %s"
%
job
[
'job_state'
])
if
job
[
'reason'
]:
self
.
logger
.
info
(
"Reason: %s"
%
job
[
'reason'
])
return
jobId
def
_doSubmit
(
self
):
verify_checksum
=
None
if
self
.
options
.
compare_checksum
:
verify_checksum
=
True
delegator
=
Delegator
(
self
.
context
)
delegationId
=
delegator
.
delegate
(
timedelta
(
minutes
=
self
.
options
.
proxy_lifetime
))
submitter
=
Submitter
(
self
.
context
)
jobId
=
submitter
.
submit
(
self
.
source
,
self
.
destination
,
checksum
=
self
.
checksum
,
bring_online
=
self
.
options
.
bring_online
,
verify_checksum
=
verify_checksum
,
spacetoken
=
self
.
options
.
destination_token
,
source_spacetoken
=
self
.
options
.
source_token
,
fail_nearline
=
self
.
options
.
fail_nearline
,
file_metadata
=
self
.
options
.
file_metadata
,
filesize
=
self
.
options
.
file_size
,
gridftp
=
self
.
options
.
gridftp_params
,
job_metadata
=
self
.
options
.
job_metadata
,
overwrite
=
self
.
options
.
overwrite
,
copy_pin_lifetime
=
self
.
options
.
pin_lifetime
,
reuse
=
self
.
options
.
reuse
)
if
self
.
options
.
json
:
self
.
logger
.
info
(
jobId
)
else
:
self
.
logger
.
info
(
"Job successfully submitted."
)
self
.
logger
.
info
(
"Job id: %s"
%
jobId
)